
    Cj                   x   % S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSKrSSKJrJrJr  SSKJr  SSKJrJrJrJr  SSKJr  SSKJr  SS	KJr  SS
KJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0  SSK1J2r2J3r3  SSK4r4SSK5r4SSK6J7r7  SSK8J9r9J:r:J;r;J<r<  SSK=J>r>  SSK?J@r@  SSKAJBrBJCrC  SSKDJErE  SSKFJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrO  SSKPJQrQJRrRJSrSJTrT  SSKUJVrVJWrW  SSKXJYrYJZrZ  SSK[J\r\  SSK]J^r^  SSK_J`r`  SSKaJbrbJcrc  SSKaJdre  SSKfJgrg  SSKhJiriJjrj  SSKkJlrl  SSKmJnrnJoroJprp  SSKqJrrr  SS KsJtrt  SS!KuJvrvJwrw  SS"KxJyry  SS#KzJ{r{  SS$K|J}r}J~r~JrJr  SS%KJrJrJrJr  SS&KJr  SS'KJr  SS(KJr  SS)KJr  SS*KJrJr  SS+KJrJr  SS,KJr  SS-KJr  SS.KJrJr  SS/KJr  SS0KJrJrJrJr  SS1KJrJrJr  SS2KJrJrJrJrJr  SS3KJrJr  SS4KJrJrJrJr  SS5KJr  SS6KJr  SS7KJrJrJrJrJr  SS8KJr  SS9KJrJrJr  SS:KJr  SS;KJrJr  SS<KJrJr  SS=KJr  SS>KJrJr  SS?KJr  \(       a<  SS@KJr  SSAKJrJrJrJr  SSBKqJr  SSCKJr  SSDKJr  SSEKJr  SSFKJr  SSGKJr  SSHKJr  \
GR                  SI:H  r\KGR                  (       a  \GR                  " SJ\5        \
GR                  SK:  r\(\   rSLrSM\SN'    SOrSM\SP'    SQrSM\SR'    \/" SS\ST9r  " SU SV\+5      rStSW jr " SX SY\5      r " SZ S[\5      r " S\ S]\5      r " S^ S_\5      r " S` Sa\5      r " Sb Sc\5      r " Sd Se\5      r " Sf Sg\5      r " Sh Si\5      r " Sj Sk\5      r\/" Sl5      r\/" Sm5      r " Sn So5      Gr  " Sp Sq5      Gr\4GR                  GR                   " Sr Ss\'\   \5      5       Grg)uz

Here you will find the [App][textual.app.App] class, which is the base class for Textual apps.

See [app basics](/guide/app) for how to build Textual apps.
    )annotationsN)AbstractEventLoopTaskcreate_task)Future)asynccontextmanagercontextmanagerredirect_stderrredirect_stdout)partial)Path)perf_counter)TYPE_CHECKINGAnyAsyncGenerator	AwaitableBinaryIOCallableClassVar	GeneratorGenericIterableIteratorMapping
NamedTupleSequenceTextIOTypeTypeVaroverload)WeakKeyDictionaryWeakSet)user_downloads_path)ConsoleConsoleDimensionsConsoleOptionsRenderableType)Controlis_renderable)SegmentSegments)TerminalTheme)	LoggerLogGroupLogVerbosityactions	constantseventslogmessageson)DEFAULT_EASING
AnimatableAnimatorEasingFunction)SYNC_END
SYNC_START)	ALABASTERMONOKAI)invoke)cached_property)CompositorUpdate)
active_appactive_message_pump)message_hook)dispatch_key)	NoHandlerextract_handler_actions)generate_datetime_filename)CSSPathType_css_path_type_as_list_make_path_object_relative)AnimationLevel)wait_for_idle)ActionParseResult
SkipAction)AwaitComplete)AwaitRemove)BindingBindingsMapBindingTypeKeymap)CommandListItemCommandPaletteProviderSimpleProvider)compose)Content)StylesheetError)	NoMatches)RulesMap
Stylesheet)DOMNodeNoScreen)Driver)NoWidget)FeatureFlagparse_features)FileMonitor)ANSIToTruecolor	DimFilter
MonochromeNoColor)OffsetRegionSize)REPLACED_KEYS_character_to_key_get_unicode_name_from_key_normalize_key_list
format_key)CallbackTypePrune)NotificationNotificationsNotifySeverityLevel)Reactive)Blank)ActiveBindingScreenScreenResultCallbackTypeScreenResultTypeSystemModalScreen)Signal)BUILTIN_THEMESThemeThemeProvider)Timer)SupportsVisualVisual)
AwaitMountWidget)	ToastRack)NoActiveWorkerget_current_worker)WorkerManagerDevtoolsClient)	CoroutineLiteralSelf	TypeAlias)MessageTarget)	WrongType)
LineFilter)MessagePilotSystemCommandsProvider)
MountErrorwin32always)   
   r   z(RenderableType | Visual | SupportsVisualr   RenderResultz4Callable[[Pilot[object]], Coroutine[Any, Any, None]]AutopilotCallbackTypez0Callable[[], Awaitable[Any]] | Callable[[], Any]CommandCallback
ScreenTypeboundc                  L    \ rS rSr% SrS\S'    S\S'    S\S'    SrS	\S
'   Srg)SystemCommand   zDefines a system command used in the command palette (yielded from [`get_system_commands`][textual.app.App.get_system_commands]).strtitlehelpr   callbackTbooldiscover N)__name__
__module____qualname____firstlineno____doc____annotations__r   __static_attributes__r       ]/home/rurouni/.local/share/pipx/venvs/strix-agent/lib/python3.13/site-packages/textual/app.pyr   r      s.     LJ4
I6<Hd;r   r   c                     SSK Jn   U $ )zPCallable to lazy load the system commands.

Returns:
    System commands class.
r   r   )textual.system_commandsr   r   s    r   get_system_commands_providerr      s     ?!!r   c                      \ rS rSrSrSrg)AppError   z.Base class for general App related exceptions.r   Nr   r   r   r   r   r   r   r   r   r   r          8r   r   c                      \ rS rSrSrSrg)ActionError   z.Base class for exceptions relating to actions.r   Nr   r   r   r   r   r      r   r   r   c                      \ rS rSrSrSrg)ScreenError   z1Base class for exceptions that relate to screens.r   Nr   r   r   r   r   r      s    ;r   r   c                      \ rS rSrSrSrg)ScreenStackError   z>Raised when trying to manipulate the screen stack incorrectly.r   Nr   r   r   r   r   r      s    Hr   r   c                      \ rS rSrSrSrg)	ModeError   z+Base class for exceptions related to modes.r   Nr   r   r   r   r   r      s    5r   r   c                      \ rS rSrSrSrg)InvalidModeError   z-Raised if there is an issue with a mode name.r   Nr   r   r   r   r   r      s    7r   r   c                      \ rS rSrSrSrg)UnknownModeError   z7Raised when attempting to use a mode that is not known.r   Nr   r   r   r   r   r      s    Ar   r   c                      \ rS rSrSrSrg)ActiveModeError   z;Raised when attempting to remove the currently active mode.r   Nr   r   r   r   r   r      s    Er   r   c                      \ rS rSrSrSrg)SuspendNotSupported   zRaised if suspending the application is not supported.

This exception is raised if [`App.suspend`][textual.app.App.suspend] is called while
the application is running in an environment where this isn't supported.
r   Nr   r   r   r   r   r      s    r   r   c                      \ rS rSrSrSrg)InvalidThemeError   z$Raised when an invalid theme is set.r   Nr   r   r   r   r   r      s    .r   r   
ReturnTypeCallThreadReturnTypec                  6    \ rS rSrSrSS jrS	S jrS
S jrSrg)	_NullFile   z$A file-like where writes go nowhere.c                    g Nr   selftexts     r   write_NullFile.write       r   c                    g r   r   r   s    r   flush_NullFile.flush   r   r   c                    gNTr   r   s    r   isatty_NullFile.isatty   s    r   r   Nr   r   returnNoner   r   r   r   )	r   r   r   r   r   r   r   r   r   r   r   r   r   r      s    .r   r   c                  N    \ rS rSrSrS
SS jjrSS jrSS jrSS jrSS jr	Sr
g	)_PrintCapturei  z"A file-like which captures output.c                    Xl         X l        g)z>

Args:
    app: App instance.
    stderr: Write from stderr.
Nappstderr)r   r   r   s      r   __init___PrintCapture.__init__  s     r   c                J    U R                   R                  XR                  S9  g)zSCalled when writing to stdout or stderr.

Args:
    text: Text that was "printed".
r   N)r   _printr   r   s     r   r   _PrintCapture.write  s     	[[1r   c                J    U R                   R                  U R                  S9  g)z)Called when stdout or stderr was flushed.r   N)r   _flushr   r   s    r   r   _PrintCapture.flush  s    t{{+r   c                    g)zPretend we're a terminal.Tr   r   s    r   r   _PrintCapture.isatty       r   c                    g)zReturn invalid fileno.r   r   s    r   fileno_PrintCapture.fileno"  s    r   r   NF)r   Appr   r   r   r   r   r   r   r   int)r   r   r   r   r   r   r   r   r   r
  r   r   r   r   r   r     s    ,2,
r   r   c            	      *  ^  \ rS rSr% SrSrS\S'    S\S'   Sr0 rS\S	'    S
r	S\S'    0 r
S\S'    SrS\S'    SrS\S'    SrS\S'   SrS\S'    SrS\S'    SrS\S'    SrS\S'    SrS\S'    \1rS\S '    S!rS\S"'    SrS\S#'    S$rS\S%'    S&rS\S''    \" S(S)S*S+S,SS-9\" S.S/S,SS09/rS1\S2'    S3rS4\S5'    S&rS6\S7'    SrS\S8'    SrS\S9'    S:rS;\S<'    Sr S\S='    / r!S>\S?'    / r"S>\S@'    S,r#S\SA'    Sr$S\SB'    SCr%S;\SD'    SEr&S\SF'    SG SH SI SJ SK SL SM SN.r'SO\SP'   \(" SS,SQ9r)SR\SS'    \(" SS,SQ9r*SR\ST'    \(" SS,SQ9r+ \(" \,RZ                  5      r.SR\SU'    \(" \/S,SV9r0 \(" \1S,SV9r2 \(" S5      r3SW\SX'        GSN       GSOU 4SY jjjr4GSPSZ jr5\6GSQS[ j5       r7\8GSRS\ j5       r9GSSU 4S] jjr:S^ r;GSTS_ jr<GSUS` jr=GSVSa jr>\6GSWSb j5       r?\6GSXSc j5       r@\6GSYSd j5       rA\6GSZSe j5       rB\6GS[Sf j5       rC\6GS\Sg j5       rDGSSSh jrEGSSSi jrFGS]Sj jrG\HGS^Sk j5       rIGSSSl jrJGSSSm jrKGS_GS`Sn jjrL\HGS^So j5       rMGSaSp jrNSqSSSr\OSSsSt.                   GSbSu jjrPGScGSdSv jjrQ\6GSQSw j5       rR\6GSQSx j5       rS\6GSQSy j5       rT\6GSQSz j5       rU\6GSQS{ j5       rV\6GSQS| j5       rW\6GSeS} j5       rX\6GSeS~ j5       rY\6GS\S j5       rZ\6GSfS j5       r[GSgGShS jjr\   GSi       GSjS jjr]\6GSkS j5       r^\6GSlS j5       r_GSmS jr`GSWS jraGSnS jrbGSoS jrcGSoS jrdGSpS jreGSqS jrfGSrS jrg\6GSsS j5       rh\6GStS j5       riGSuS jrjGSrS jrkGSSS jrlGSvS jrmGSvS jrn\6GSwS j5       ro\6GSQS j5       rpGSvS jrqGSxS jrrGSyS jrs\6GSzS j5       rt\6GS{S j5       ru\6GS|S j5       rv\6GS}S j5       rw\6GS}S j5       rxGS~S jry\6GSS j5       rz          GSS jr{GSS jr|GSS jr}        GSS jr~GSSS jr GS     GSS jjrSS,S.     GSS jjr   GS       GSS jjr   GS       GSS jjr GS     GSS jjrGSSS jrSSSS.           GSS jjrGSS jrGSS jrGSGSS jjrGSGSS jjr GS       GSS jjrGSS jr\SSS,S,SS.           GSS jj5       rS,S,S,SSSS.             GSS jjrS,S,S,SSSSS.               GSS jjrGSSS jrGSS jr\" S\S9r\(       a  \GSS j5       r\      GSS j5       r GSg     GSS jjr\(       a  \GSS j5       r\      GSS j5       r GSg     GSS jjrGSS jrGScGSS jjrSSS.       GSS jjrSSS.       GSS jjrGSS jrGSS jrGSS jrGSS jrGSS jr\GSS j5       r\GSS j5       r\ GSg     GSS jj5       r\ GSg     GSS jj5       r GSg     GSS jjrGSS jrGSS jrGSS jr\(       a:  \  GSSS.         GSS jjj5       r\  GSSS.         GSS jjj5       r  GSSS.         GSS jjjr\(       a(  \SS.     GSS jj5       r\SS.     GSS jj5       rSS.     GSS jjrGSS jrGSS jrGSS jrGSS jrGSS jrGScGSS jjr      GSS jrGSS jrGSS jrGSS jrGSS jrGSSS jrGSSS jr          GSS jrS r       GS               GSS jjrGSQS jrGSSS jrGSSS jrGSSS jrGSSS jr          GSS jrSSSS.           GSS jjrGSS jrS rGSS jrGSS jrGSSS jrGSSS jrGSSS jrSS,S,S.       GSS jjrGScGSS jjrGSGS  jrGSSGS jrGSGS jrGSSGS jrGSGS jr\6GSGS j5       rGSGS jrGSGSGS jjrGSSGS jr\GSGS	 j5       rGSGS
 jrGSGS jr      GSGS jrGSU 4GS jjr\6GSQGS j5       r GSg       GSGS jjr      GSGS jr  GS       GSGS jjr        GSGS jr        GSGS jrGSGS jrGSGS jrGSGS jrGSGS jrGSGS jrGSGS jrSGS.GSGS jjrGSGS jrGSGS jrGSSGS jrGSSGS jrGSGS  jrGSGS! jrGSGS" jrGSSGS# jrGSGS$ jrGSSGS% jrGSGS& jrGSGS' jrGSGS( jrGSSGS) jrGSSGS* jrGSSGS+ jrGSSGS, jrGSSGS- jr GS       GSGS/ jjr    GSGS0 jrGSSGS1 jrGSSGS2 jrGSSGS3 jrGSSGS4 jrSGS.SSGS5.           GSGS6 jjrGSGS7 jrGScGSGS8 jjrGSSGS9 jGr GSSGS: jGrGSSGS; jGrG\" G\GR
                  5      GSSGS< j5       Gr\HGSGS= j5       GrGSSGS> jGrSGS?.GSGS@ jjGr	SSGSASSSGSB.               GSGSC jjGr
SSGSASSGSD.             GSGSE jjGrSSSGSF.               GSGSG jjGrG\" G\GR                  5      GSGSH j5       GrG\" G\GR                   5      GSGSI j5       GrG\" G\GR&                  5      GSGSJ j5       GrGSSGSK jGrGSSGSL jGrGSMGrU =Gr$ (  r  i'  z(The base class for Textual Applications. zClassVar[str]CSSDEFAULT_CSSa%  
    App {
        background: $background;
        color: $foreground;

        &:ansi {
            background: ansi_default;
            color: ansi_default;

            .-ansi-scrollbar {
                scrollbar-background: ansi_default;
                scrollbar-background-hover: ansi_default;
                scrollbar-background-active: ansi_default;
                scrollbar-color: ansi_blue;
                scrollbar-color-active: ansi_bright_blue;
                scrollbar-color-hover: ansi_bright_blue;    
                scrollbar-corner-color: ansi_default;           
            }

            .bindings-table--key {
                color: ansi_magenta;
            }
            .bindings-table--description {
                color: ansi_default;
            }

            .bindings-table--header {
                color: ansi_default;
            }

            .bindings-table--divider {
                color: transparent;
                text-style: dim;
            }
        }

        /* When a widget is maximized */
        Screen.-maximized-view {                    
            layout: vertical !important;
            hatch: right $panel;
            overflow-y: auto !important;
            align: center middle;
            .-maximized {
                dock: initial !important;                
            }
        }
        /* Fade the header title when app is blurred */
        &:blur HeaderTitle {           
            text-opacity: 50%;           
        }
    }
    *:disabled:can-focus {
        opacity: 0.7;
    }
    z/ClassVar[dict[str, str | Callable[[], Screen]]]MODES_defaultDEFAULT_MODEz.ClassVar[dict[str, Callable[[], Screen[Any]]]]SCREENS*zClassVar[str | None]
AUTO_FOCUSTzClassVar[bool]ALLOW_SELECTN
str | None
_BASE_PATHzClassVar[CSSPathType | None]CSS_PATHTITLE	SUB_TITLEENABLE_COMMAND_PALETTE   zClassVar[float]NOTIFICATION_TIMEOUTz<ClassVar[set[type[Provider] | Callable[[], type[Provider]]]]COMMANDSzctrl+pCOMMAND_PALETTE_BINDINGCOMMAND_PALETTE_DISPLAYFooterALLOW_IN_MAXIMIZED_VIEWg      ?CLICK_CHAIN_TIME_THRESHOLDzctrl+qquitQuitz.Quit the app and return to the command prompt.F)tooltipshowpriorityzctrl+c	help_quit)r,  systemzClassVar[list[BindingType]]BINDINGSg      @float | NoneCLOSE_TIMEOUTfloatTOOLTIP_DELAYBINDING_GROUP_TITLEESCAPE_TO_MINIMIZE   zClassVar[int]INLINE_PADDINGSUSPENDED_SCREEN_CLASSz&ClassVar[list[tuple[int, str]]] | NoneHORIZONTAL_BREAKPOINTSVERTICAL_BREAKPOINTSPAUSE_GC_ON_SCROLLENABLE_SELECT_AUTO_SCROLLr   SELECT_AUTO_SCROLL_LINESg      N@SELECT_AUTO_SCROLL_SPEEDc                    U R                   $ r   	app_focusr   s    r   <lambda>App.<lambda>  s    S]]r   c                $    U R                   (       + $ r   rA  rC  s    r   rD  rE    s    -r   c                .    U R                   R                  $ r   current_themedarkrC  s    r   rD  rE    s    C--22r   c                8    U R                   R                  (       + $ r   rH  rC  s    r   rD  rE    s    !2!2!7!77r   c                    U R                   $ r   )	is_inlinerC  s    r   rD  rE    s    cmmr   c                    U R                   $ r   )native_ansi_colorrC  s    r   rD  rE     s
    C11r   c                    U R                   $ r   )no_colorrC  s    r   rD  rE  !  s    s||r   )focusblurrJ  lightinlineansinocolorz/ClassVar[dict[str, Callable[[App[Any]], bool]]]_PSEUDO_CLASSES)computezReactive[str]r   	sub_titletheme)initzReactive[bool | None]
ansi_colorc                Z  > [        5       U l        [        TU ]  U R                  S9  [        [        R                  " SS5      5      U l        0 U l	         [        R                  " 5        H  nU R                  U5        M     U R                  R                  (       a  U R                  OU R                   nU R#                  [$        R&                  U5        [)        X`R*                  (       + S9/U l        [/        [        R0                  5      nUR3                  SS5      SLU l        U R4                  (       a>  U R,                  R7                  U R*                  (       a
  [9        5       O	[;        5       5        [<        R>                  RA                  S5       HL  nURC                  5       RE                  5       n	U	S:X  d  M)  U R,                  R7                  [G        5       5        MN     [I        [<        RJ                  [M        5       S	S
S
S
US	S
S
S9
U l'        [Q        U 5      U l)        [I        S
S
S	S9U l*        U=(       d    U RW                  5       U l,        U RZ                  / 0U l.         U RZ                  U l/         S
U l0        SU l1         SU l2         SU l3        SU l4        / U l5        1 SkU l6        [o        U 5      U l8        U Rp                  Rs                  U 5      U l:        [w        SS5      U l<         SU l=         SU l>         SU l?         SU l@         SU lA         [w        SS5      U lB         [w        SS5      U lC         SU lD         U R                  b  U R                  OU R                  R                   U lH         U R                  b  U R                  OSU lJ         U R                  U lL         [        U R                  U S9U lO        S
U lP        0 U lQ         [        U R                  5       S9U lT        U=(       d    U R                  nUb  [        U5      O/  Vs/ s H  n[        X 5      PM     n
nXlX        [        5       U lZ        0 U l[        SU l\         SU l]         0 U l^        U R                  R                  " S&0 U R                  D6  U R                  R                  5       U lc         / U ld        / U le        S
U lf        SU lg        SU lh        SU R                  ;   a?   SSKiJjn  SSKkJln  U" [<        R                  5      U lg        U" U R                  5      U lh        SU lo        SU lp         SU lq         S
U lr        S
U ls        S
U lt        U(       d  U R                  (       a   [        U R                  U R                  5      OSU lx        SU ly        S
U lz        SU l{        [        5       U l}        [        5       U l         G[        U S
S9U l         G[        U S	S9U l         G[        GR                  U l         G[        GR                  U l         G[        U S5      U l         G[        U S5      U l         G[        U S5      U l         G[        U S5      U l         G[        U S5      U l         U GR                  U R                  R                  SS
S9  U GR                  U R                  R                  (       + S S
S9  [<        GR                  U l         SU l         SU l         SU l         SU l        SU l         SU l         S
U l         SU l         SU l         U R                  (       aj  U GR4                   H  u  pUGR6                  S!;   d  M    OC   U GR4                  GR9                  G[;        U GR<                  S"S#S
U GR>                  S	S$S%95        SU l        gs  snf ! [         a     GNf = f)'a  Create an instance of an app.

Args:
    driver_class: Driver class or `None` to auto-detect.
        This will be used by some Textual tools.
    css_path: Path to CSS or `None` to use the `CSS_PATH` class variable.
        To load multiple CSS files, pass a list of strings or paths which
        will be loaded in order.
    watch_css: Reload CSS if the files changed. This is set automatically if
        you are using `textual run` with the `dev` switch.
    ansi_color: Allow ANSI colors if `True`, or convert ANSI colors to RGB if `False`, `None` to use "ansi" parameter from themes.

Raises:
    CssPathError: When the supplied CSS path(s) are an unexpected type.
)classesTEXTUALr  enabledNO_COLORN,dimTF)
color_systemfilemarkup	highlightemojilegacy_windows_environforce_terminalsafe_box	soft_wrap)rh  ri  r   >   r   screenfocusedr   )        rr  r7  rC  )	variablesg      @g       @devtoolsr   )StdoutRedirectorr   ztheme-changedzapp-suspendz
app-resumezmode-changezscreen-change
-dark-modeupdate-light-mode>   command_paletteapp.command_paletterz  palettezOpen the command palette)r,  key_displayr-  r+  r   )r   _start_timesuperr   DEFAULT_CLASSESre   osgetenvfeatures_registered_themesr   valuesregister_themerI  rJ  ansi_theme_darkansi_theme_lightset_reactiver  r]  rg   rO  _filtersdictenvironpoprQ  appendrj   ri   r2   FILTERSsplitlowerstriprh   r$   COLOR_SYSTEMr   consoler   _workerserror_consoleget_driver_classdriver_classr  _screen_stacks_current_mode_sync_available
mouse_over
hover_overmouse_captured_driver_exit_renderables_action_targetsr9   	_animatorbind_animaterk   mouse_positionmouse_position_high_resolution_mouse_down_widget_click_chain_last_offset_click_chain_last_time_chained_clicks_previous_cursor_positioncursor_position
_exceptionr  	__class__r   r   r  rZ  r   use_command_paletter.   _log_logger_css_has_errorstheme_variablesr_   get_css_variables
stylesheetr  rJ   rK   css_pathr"   	_registry_keymapscroll_sensitivity_xscroll_sensitivity_y_installed_screensrx  r  r  copy_modes_compose_stacks	_composed_recompose_requiredrt  _devtools_redirectortextual_dev.clientr   textual_dev.redirect_outputru  DEVTOOLS_HOSTImportError_loop_return_value_return_code_exit_disable_tooltips_disable_notificationsdebugrf   _on_css_changecss_monitor_screenshot
_dom_ready_batch_countrv   _notificationsr!   _capture_printr   _capture_stdout_capture_stderrsys
__stdout___original_stdout
__stderr___original_stderrr   theme_changed_signalapp_suspend_signalapp_resume_signalmode_change_signalscreen_change_signal	set_classTEXTUAL_ANIMATIONSanimation_level_last_focused_on_app_blur_previous_inline_height_resize_event_size_css_update_count
_clipboardsupports_smooth_scrolling_compose_screen_realtime_animation_count	_bindingsaction_add_bindingrR   r$  r%  _resize_timer)r   r  r  	watch_cssr]  r[  
ansi_themer  filter_namefilter	css_pathsr   ru  _keybindingr  s                  r   r   App.__init__<  s    , (>!5!560>ryyTV?W0X46	. $**,E& - %)$6$6$;$;D  AVAV 	 	#..*5J4J4J0JK+
 rzz"J5TA==MM  d.D.D*,W$,,2237K &&(..0F$$Y[1 8
 "// 
 &d+$EU4P(CD,A,A,C=A=N=NPR<S*"&"3"3-$)-2)-B-1&*79;!$++D1$Ql6CM+ 	O15[7;%I48#6$%J)/1&*%a|	8
 -1	M **0DJJ9P9P8Q 	
	 ,0>>+E2
	 *.)D)D 	 diiT2$/19 %t/E/E/GH,t}} 5=4H&x0bP
 Q  'x6P 	 
 "+29! ,/!T+.!RLN&&66=AZZ__=NI35-/#( /3=A!&L=H
 !/y/F/F G,<T]],K)7;
04J(,I
!&&+# DJJ t':':; 	
 (,+o  	 	[,T%@@,T$?@ #B #B39$3P!	
 06dM/J	 /5T<.H	 06dM/JF4:44Q!At))..UK4--222M%P/8/K/K	
 9=&	 48$-373"&
&'2!*/4&9.21)*&G&&!%>>%OO "0 ++44)!"$($@$@!% :
 ,01A
D  s   ^^ 
^*)^*c                j    U R                    Vs/ s H  oR                  (       d  M  UPM     sn$ s  snf )zpGet currently enabled line filters.

Returns:
    A list of [LineFilter][textual.filters.LineFilter] instances.
)r  rb  )r   r  s     r   get_line_filtersApp.get_line_filters~  s$     &*]]E]6nn]EEEs   00c                X    U R                   SL=(       a    U R                   R                  $ )z%Is the app connected to the devtools?N)rt  is_connectedr   s    r   _is_devtools_connectedApp._is_devtools_connected  s"     }}D(GT]]-G-GGr   c                ,    [         R                  " 5       $ )zBAn event that will be set when the first exception is encountered.)asyncioEventr   s    r   _exception_eventApp._exception_event  s     }}r   c           
       > SU R                   4SU R                  44 H  u  p4UR                  5        Hx  u  pV[        U[        5      (       a  M  [        U5      (       a  M.  [        U[        5      (       a(  [        U S[        U5      R                   SU< S35      e[        SU< 35      e   M     [        TU ]0  " U0 UD6$ )Nr  r  zL should contain a Screen type or callable, not an instance (got instance of  for )z#expected a callable or string, got )r  r  items
isinstancer   callabler|   
ValueErrortyper   	TypeErrorr  __init_subclass__)clsargskwargsvariable_namescreen_collectionscreen_namescreen_objectr  s          r   r  App.__init_subclass__  s    $cii 1
,M /@.E.E.G*"=#66(=:Q:Q!-88(,o .115m1D1M1M0NeT_Sbbce  $=m=NO  /H	1
 w($9&99r   c                    U R                     U R                    U R                    [        R                  " 5       U l        g)zlInitialize threading primitives for the current thread.

https://github.com/Textualize/textual/issues/5845

N)_message_queue_mounted_eventr  	threading	get_ident
_thread_idr   s    r   _thread_initApp._thread_init  s/     	#--/r   c                    U R                   $ )z@When querying from the app, we want to query the default screen.)default_screenr   s    r   _get_dom_baseApp._get_dom_base  s    """r   c                    [        U5      $ )z'Make sure the title is set to a string.r   )r   r   s     r   validate_titleApp.validate_title  s    5zr   c                    [        U5      $ )z*Make sure the subtitle is set to a string.r#  )r   rZ  s     r   validate_sub_titleApp.validate_sub_title  s    9~r   c                L    U R                   c  U R                  $ U R                   $ )zThe default screen instance.)r  rp  r   s    r   r  App.default_screen  s$     #22:t{{T@T@TTr   c                    U R                   $ )zRThe [worker](/guide/workers/) manager.

Returns:
    An object to manage workers.
)r  r   s    r   workersApp.workers  s     }}r   c                    U R                   $ )zThe return value of the app, or `None` if it has not yet been set.

The return value is set when calling [exit][textual.app.App.exit].
)r  r   s    r   return_valueApp.return_value  s     !!!r   c                    U R                   $ )aG  The return code with which the app exited.

Non-zero codes indicate errors.
A value of 1 means the app exited with a fatal error.
If the app hasn't exited yet, this will be `None`.

Example:
    The return code can be used to exit the process via `sys.exit`.
    ```py
    my_app.run()
    sys.exit(my_app.return_code)
    ```
)r  r   s    r   return_codeApp.return_code  s        r   c                p     [        S [        U R                  5       5       5      4$ ! [         a     gf = f)zA view onto the app's immediate children.

This attribute exists on all widgets.
In the case of the App, it will only ever contain a single child, which will
be the currently active screen.

Returns:
    A sequence of widgets.
c              3  T   #    U  H  n[        U[        5      (       a  M  Uv   M      g 7fr   )r  r   ).0rp  s     r   	<genexpr>App.children.<locals>.<genexpr>  s$      ">%f.?@ F">s   (	(r   )nextreversed_screen_stackStopIterationr   s    r   childrenApp.children  sE    		 "*4+=+=">    		s   %( 
55c                    U R                   $ )zThe value of the local clipboard.

Note, that this only contains text copied in the app, and not
text copied from elsewhere in the OS.
)r  r   s    r   	clipboardApp.clipboard  s     r   c                x    U R                   (       a  SSKnUR                  5         U =R                  S-  sl        g)z:A scroll or other animation that must be smooth has begun.r   Nr7  )r<  gcdisabler  r   rC  s     r   _realtime_animation_beginApp._realtime_animation_begin  s(    ""JJL&&!+&r   c                    U =R                   S-  sl         U R                   S:X  a'  U R                  (       a  SSKnUR                  5         ggg)z>A scroll or other animation that must be smooth has completed.r7  r   N)r  r<  rC  enablerE  s     r   _realtime_animation_complete App._realtime_animation_complete  s>    &&!+&))Q.43J3JIIK 4K.r   c                    [        U5      n[        U5      nU(       a'  [         R                  " USUR                  S5      5      $ U$ )zFormat the title for display.

Args:
    title: The title.
    sub_title: The sub title.

Returns:
    Content instance with title and subtitle.
)u    — re  re  )r[   assemblestylize)r   r   rZ  title_contentsub_title_contents        r   format_titleApp.format_title  sJ      #I.## !))%0  ! r   c              #     #    U R                  5          Sv   U R                  5         g! U R                  5         f = f7f)zEA context manager to suspend all repaints until the end of the batch.N)_begin_batch
_end_batchr   s    r   batch_updateApp.batch_update$  s/      		OODOOs   >) >;>c                .    U =R                   S-  sl         g)zBegin a batch update.r7  N)r  r   s    r   rT  App._begin_batch-  s    Qr   c                    U =R                   S-  sl         U R                   S:  d   S5       eU R                   (       d  U R                  5         gg)zEnd a batch update.r7  r   z+This won't happen if you use `batch_update`N)r  
check_idler   s    r   rU  App._end_batch1  sE    Q  A%T'TT%  OO !r   c                V   ^  T R                  5         SU 4S jjnT R                  XSS9  g)zDelay updates for a short period of time.

May be used to mask a brief transition.
Consider this method only if you aren't able to use `App.batch_update`.

Args:
    delay: Delay before updating.
c                 ~   > T R                  5         T R                  (       d  T R                  R                  5         gg)z&Re-enable updates, and refresh screen.N)rU  r  rp  refreshr   s   r   	end_batch#App.delay_update.<locals>.end_batchC  s+    OO$$##% %r   delay_updatenameNr   )rT  	set_timer)r   delayr`  s   `  r   rb  App.delay_update8  s(     		& 	un=r   c              #  (  #    [         R                  " U 5      n[        R                  " U 5      n Sv   [        R                  " U5        [         R                  " U5        g! [        R                  " U5        [         R                  " U5        f = f7f)z#Context manager to set ContextVars.N)rB   setrC   reset)r   app_reset_tokenmessage_pump_reset_tokens      r   _contextApp._contextK  sk      %...#6#:#:4#@ 	.%%&>?_-  %%&>?_-s   -BA! -B!.BBc                    Uc*  U R                  U R                  5      =nb  UR                  nU R                   H&  n[	        U[
        5      (       d  M  U(       + Ul        M(     g)z@Enable or disable the truecolor filter when the reactive changesN)	get_themer[  rV  r  r  rg   rb  )r   r]  r[  r  s       r   _watch_ansi_colorApp._watch_ansi_colorV  sM    

33@"ZZ
mmF&/22%/ $r   .rr  fullfinal_valuedurationspeedrf  easingon_completelevelc               2    U R                  UUUUUUUUU	S9	  g)a>  Animate an attribute.

See the guide for how to use the [animation](/guide/animation) system.

Args:
    attribute: Name of the attribute to animate.
    value: The value to animate to.
    final_value: The final value of the animation.
    duration: The duration (in seconds) of the animation.
    speed: The speed of the animation.
    delay: A delay (in seconds) before the animation starts.
    easing: An easing method.
    on_complete: A callable to invoke when the animation is finished.
    level: Minimum level required for the animation to take place (inclusive).
rt  N)r  )
r   	attributevalueru  rv  rw  rf  rx  ry  rz  s
             r   animateApp.animate`  s0    8 	## 	 
	
r   c                X   #    U R                   R                  XU5      I Sh  vN   g N7f)zStop an animation on an attribute.

Args:
    attribute: Name of the attribute whose animation should be stopped.
    complete: Should the animation be set to its final value?

Note:
    If there is no animation scheduled or running, this is a no-op.
N)r  stop_animation)r   r|  completes      r   r  App.stop_animation  s!      nn++DXFFFs    *(*c                    g)z#Is this a root node (i.e. the App)?Tr   r   s    r   is_dom_rootApp.is_dom_root  r  r   c                    g)z/Is this node linked to the app through the DOM?Tr   r   s    r   is_attachedApp.is_attached  r  r   c                N    SU R                   ;   =(       d    [        R                  $ )zIs debug mode enabled?r  )r  r2   DEBUGr   s    r   r  	App.debug  s     $--':9??:r   c                L    U R                   c  S$ U R                   R                  $ )z|Is the app running in 'headless' mode?

Headless mode is used when running tests with [run_test][textual.app.App.run_test].
F)r  is_headlessr   s    r   r  App.is_headless  s"     ,uJ$,,2J2JJr   c                L    U R                   c  S$ U R                   R                  $ )z$Is the app running in 'inline' mode?F)r  rM  r   s    r   rM  App.is_inline  s"     ,uH$,,2H2HHr   c                L    U R                   c  S$ U R                   R                  $ )z/Is the app running in 'web' mode via a browser?F)r  is_webr   s    r   r  
App.is_web  s"     ,uE$,,2E2EEr   c                P    U R                   U R                     R                  5       $ )zkA snapshot of the current screen stack.

Returns:
    A snapshot of the current state of the screen stack.
)r  r  r  r   s    r   screen_stackApp.screen_stack  s$     ""4#5#56;;==r   c                4    U R                   U R                     $ )zA reference to the current screen stack.

Note:
    Consider using [`screen_stack`][textual.app.App.screen_stack] instead.

Returns:
    A reference to the current screen stack.
)r  r  r   s    r   r;  App._screen_stack  s     ""4#5#566r   c                    U R                   $ )z&The name of the currently active mode.)r  r   s    r   current_modeApp.current_mode  s     !!!r   c           
         [        U R                  6 nU R                  n[        UR                  UUR
                  SUR                  UR                  UR                  S9$ )zoGet options for the Rich console.

Returns:
    Console options (same object returned from `console.options`).
r7  )
max_heightsizerk  	min_width	max_widthencodingis_terminal)	r%   r  r  r&   heightrk  widthr  r  )r   r  r  s      r   console_optionsApp.console_options  sW     !$)),,,{{"11jj%%++
 	
r   c                    Uc  U R                   n U R                  U   nUR                  5       $ ! [         a    [        SU< 35      Sef = f)a  Get the screen stack for the given mode, or the current mode if no mode is specified.

Args:
    mode: Name of a model

Raises:
    KeyError: If there is no mode.

Returns:
    A list of screens. Note that this is a copy, and modifying the list will not impact the app's screen stack.
NzNo mode called )r  r  KeyErrorr  )r   modestacks      r   get_screen_stackApp.get_screen_stack  s_     <%%D	A''-E zz|  	A_TH56D@	As	   0 Ac                    SU l         Xl        X l        U R                  [        R
                  " 5       5        U(       a  U R                  R                  U5        gg)zExit the app, and return the supplied result.

Args:
    result: Return value.
    return_code: The return code. Use non-zero values for error codes.
    message: Optional message to display on exit.
TN)r  r  r  post_messager5   ExitAppr  r  )r   resultr2  messages       r   exitApp.exit  sJ     
#'(**,-""))'2 r   c                \    U R                   R                  nUb  UR                  (       a  gU$ )zThe widget that is focused on the currently active screen, or `None`.

Focused widgets receive keyboard input.

Returns:
    The currently focused widget, or `None` if nothing is focused.
N)rp  rq  loading)r   rq  s     r   rq  App.focused
  s'     ++%%7??r   c                .    U R                   R                  $ )a>  Get currently active bindings.

If no widget is focused, then app-level bindings are returned.
If a widget is focused, then any bindings present in the active screen and app are merged and returned.

This property may be used to inspect current bindings.

Returns:
    A dict that maps keys on to binding information.
)rp  active_bindingsr   s    r   r  App.active_bindings  s     {{***r   c              #    ^ #    [        SST R                  5      v   [        SST R                  5      v   UR                  S5      (       a  [        SST R                  5      v   O[        SST R
                  5      v   UR                  b  [        S
SUR                  5      v   OAUR                  b4  UR                  R                  (       a  [        SSUR                  5      v   [        SSU 4S j5      v   g	7f)a  A generator of system commands used in the command palette.

Args:
    screen: The screen where the command palette was invoked from.

Implement this method in your App subclass if you want to add custom commands.
Here is an example:

```python
def get_system_commands(self, screen: Screen) -> Iterable[SystemCommand]:
    yield from super().get_system_commands(screen)
    yield SystemCommand("Bell", "Ring the bell", self.bell)
```

!!! note
    Requires that [`SystemCommandsProvider`][textual.system_commands.SystemCommandsProvider] is in `App.COMMANDS` class variable.

Yields:
    [SystemCommand][textual.app.SystemCommand] instances.
r   zChange the current themer*  z(Quit the application as soon as possible	HelpPanelKeysz#Hide the keys and widget help panelz@Show help for the focused widget and a summary of available keysNMinimizez.Minimize the widget and restore to normal sizeMaximizezMaximize the focused widget
Screenshotz.Save an SVG 'screenshot' of the current screenc                 <   > T R                  ST R                  5      $ )Ng?)re  deliver_screenshotr   s   r   rD  )App.get_system_commands.<locals>.<lambda>a  s    DNN3(?(?@r   )r   action_change_themeaction_quitqueryaction_hide_help_panelaction_show_help_panel	maximizedaction_minimizerq  allow_maximizeaction_maximizer   rp  s   ` r   get_system_commandsApp.get_system_commands&  s    * &$$
 	

 6
 	
 <<$$5++   R++  '@&& 
 ^^'FNN,I,I96;Q;Q  <@
 	
s   C8C;c                    [        SS9$ )a  Get the default screen.

This is called when the App is first composed. The returned screen instance
will be the first screen on the stack.

Implement this method if you would like to use a custom Screen as the default screen.

Returns:
    A screen instance.
r  id)r|   r   s    r   get_default_screenApp.get_default_screend  s     $$r   c              #  $   #    S Sh  vN   g N7f)zWYield child widgets for a container.

This method should be implemented in a subclass.
r   Nr   r   s    r   rZ   App.composeq  s     
 s   c                    0 $ )a  Get the default values for the `variables` used in a theme.

If the currently specified theme doesn't define a value for a variable,
the value specified here will be used as a fallback.

If a variable is referenced in CSS but does not appear either here
or in the theme, the CSS will fail to parse on startup.

This method allows applications to define their own variables, beyond
those offered by Textual, which can then be overridden by a Theme.

Returns:
    A mapping of variable name (e.g. "my-button-background-color") to value.
    Values can be any valid CSS value, e.g. "red 50%", "auto 90%",
    "#ff0000", "rgb(255, 0, 0)", etc.
r   r   s    r   get_theme_variable_defaultsApp.get_theme_variable_defaultsx  s	    " 	r   c                    U R                   nUR                  5       R                  5       n0 UEUR                  EnU R	                  5       n0 UEUEnX@l        U$ )zGet a mapping of variables used to pre-populate CSS.

May be implemented in a subclass to add new CSS variables.

Returns:
    A mapping of variable name to value.
)rI  to_color_systemgeneraters  r  r  )r   r[  rs  r  combined_variabless        r   r  App.get_css_variables  se     "" ))+446	6y6U__6	::<==9=1!!r   c                    UR                  S5       Vs/ s H  o"R                  5       PM     nnU H#  nXR                  ;   d  M  U R                  U   s  $    gs  snf )zGet a theme by name.

Args:
    theme_name: The name of the theme to get. May also be a comma
        separated list of names, to pick the first available theme.

Returns:
    A Theme instance and None if the theme doesn't exist.
rd  N)r  r  available_themes)r   
theme_nametokentheme_namess       r   rp  App.get_theme  s[     3=2B2B32GH2G{{}2GH%J222,,Z88 & 	 Is   Ac                4    XR                   UR                  '   g)a  Register a theme with the app.

If the theme already exists, it will be overridden.

After registering a theme, you can activate it by setting the
`App.theme` attribute. To retrieve a registered theme, use the
`App.get_theme` method.

Args:
    theme: The theme to register.
N)r  rd  r   r[  s     r   r  App.register_theme  s     /4

+r   c                >    XR                   ;   a  U R                   U	 gg)z]Unregister a theme with the app.

Args:
    theme_name: The name of the theme to unregister.
Nr  )r   r  s     r   unregister_themeApp.unregister_theme  s#     000''
3 1r   c                    0 U R                   E$ )zAll available themes (all built-in themes plus any that have been registered).

A dictionary mapping theme names to Theme instances.
r  r   s    r   r  App.available_themes  s     +$))**r   c                n    U R                  U R                  5      nUc  U R                  S5      nUc   eU$ )Ntextual-dark)rp  r[  r  s     r   rI  App.current_theme  s8    tzz*=NN>2E   r   c                H    XR                   ;  a  SU< S3n[        U5      eU$ )NzTheme z] has not been registered. Call 'App.register_theme' before setting the 'App.theme' attribute.)r  r   )r   r  r  s      r   _validate_themeApp._validate_theme  s9    222 'V V  $G,,r   c                   U R                   nUR                  nU R                   Vs0 s H  oDR                  S5      (       d  M  US_M     nnSUSU R                   R                   3'   X5S'   U(       + US'   U R                  USS9  U R                  U R                  5        U R                  5         U R                  [        U R                  SS95        U R                  U R                  R                  U5        gs  snf )	zcApply a theme to the application.

This method is called when the theme reactive attribute is set.
z-theme-FTrv  ry  rw  r~  N)rI  rJ  r_  
startswithrd  update_classes_refresh_truecolor_filterr  _invalidate_css	call_nextr   refresh_cssr  publish)r   r  r[  rJ  rd  r_  s         r   _watch_themeApp._watch_theme  s    
 ""zz+/<<V<4??9;U;4;<V7;'$,,11234 $%)GE2&&t7wt//?@t0088%@ Ws   C<C<c                .    U =R                   S-  sl         g)z(Invalidate CSS, so it will be refreshed.r7  N)r  r   s    r   r  App._invalidate_css  s    !#r   c                    U R                   R                  (       a=  U R                  U5        U R                  5         U R	                  U R
                  5        g g r   rI  rJ  r  r  r  r  r  s     r   watch_ansi_theme_darkApp.watch_ansi_theme_dark  sB    ""**51  "NN4++, #r   c                    U R                   R                  (       d=  U R                  U5        U R                  5         U R	                  U R
                  5        g g r   r  r  s     r   watch_ansi_theme_lightApp.watch_ansi_theme_light  sB    !!&&**51  "NN4++, 'r   c                h    U R                   R                  (       a  U R                  $ U R                  $ )zThe ANSI TerminalTheme currently being used.

Defines how colors defined as ANSI (e.g. `magenta`) inside Rich renderables
are mapped to hex codes.
)rI  rJ  r  r  r   s    r   r  App.ansi_theme  s.     %)$6$6$;$;D  	
AEAVAV	
r   c                h    U R                   c  U R                  R                  nU$ U R                   nU$ )zUse native ANSI colors?

This will return `self.current_theme.ansi` if `self.ansi_color` is `None`,
otherwise it will return `self.ansi_color`.
)r]  rI  rV  )r   rV  s     r   rO  App.native_ansi_color  s5     +///*At!!&& HLr   c                    U R                   nU R                  n[        U5       H,  u  pE[        U[        5      (       d  M  [	        X(       + S9X$'     g   g)zUpdate the ANSI to Truecolor filter, if available, with a new theme mapping.

Args:
    theme: The new terminal theme to use for mapping ANSI to truecolor.
ra  N)r  rO  	enumerater  rg   )r   r[  filtersr]  indexr  s         r   r  App._refresh_truecolor_filter  sG     --++
&w/ME&/22!0!O 0r   c                \   [         R                  nUb{  UR                  S5      u  p#n[        R                  " U5      n[        XT5      n[        R                  " U5      (       a  [        U[        5      (       d  [        SU< SU< S35      eU$ [        (       a
  SSKJn  UnU$ SSKJn  UnU$ )zGet a driver class for this platform.

This method is called by the constructor, and unlikely to be required when
building a Textual app.

Returns:
    A Driver class which manages input and display.
:zUnable to import z; z is not a Driver class r   )WindowsDriver)LinuxDriver)r2   DRIVER	partition	importlibimport_modulegetattrinspectisclass
issubclassrb   RuntimeErrorWINDOWStextual.drivers.windows_driverr  textual.drivers.linux_driverr  )	r   driver_importmodule_import_driver_symboldriver_moduler  r  r  s	            r   r  App.get_driver_class%  s     "(($ /<.E.Ec.J+Mm%33MBM"=@L??<00
f9 9 #''8<:JJab   7D(L
  A&Lr   c              #  *  #    SU R                   4v   SU R                  S 4v   U R                  (       a  SU R                  4v   U R                  (       a  S[	        U R                  5      4v   U R
                  nU(       a  S[	        U5      4v   g g 7f)Nr   r  rd  r_  pseudo_classes)r   r  rd  r_  ri  r(  )r   r(  s     r   __rich_repr__App.__rich_repr__J  sy     tzz!!DGGT!!99$))##<<S...,,"C$777 s   BBc                    U R                   $ )zThe animator object.)r  r   s    r   animatorApp.animatorU  s     ~~r   c                     U R                   S   $ ! [         a    [        SU R                  < 35      Se[         a    [        S5      Sef = f)zThe current active screen.

Returns:
    The currently active (visible) screen.

Raises:
    ScreenStackError: If there are no screens on the stack.
r	  No known mode NzNo screens on stack)r;  r  r   r  
IndexErrorr   r   s    r   rp  
App.screenZ  s]    	D%%b)) 	V"^D4F4F3I#JKQUU 	D"#89tC	Ds	    :Ac                    / n[        U R                  SS 5       H:  nUR                  U5        UR                  R                  R
                  S:X  d  M:    O   USSS2   nU$ )zoA list of screens that may be visible due to background opacity (top-most first, not including current screen).Nr	  r7  )r:  r;  r  styles
backgrounda)r   screensrp  background_screenss       r   _background_screensApp._background_screensk  sb     !#t11#267FNN6"}}''))Q. 8 %TrT]!!r   c                2   U R                   b  U R                   $ U R                  b0  U R                  R                   b  U R                  R                   u  pO7U R                  R                  u  pU R                  b  X4U R                  l         [	        X5      $ )z>The size of the terminal.

Returns:
    Size of the terminal.
)r  r  r  r  rm   )r   r  r  s      r   r  App.sizev  sx     ::!::<<#(:(:(F LL..ME6 LL--ME||'&+_"E""r   c                t     U R                   R                  $ ! [        [        4 a    U R                  s $ f = f)z+Get the viewport size (size of the screen).)rp  r  r   ra   r   s    r   viewport_sizeApp.viewport_size  s5    	;;### (+ 	99	s    77c                Z   ^ U R                   m[        U4S jU R                   5       5      $ )zSGet the inline height (height when in inline mode).

Returns:
    Height in lines.
c              3  D   >#    U  H  oR                  T5      v   M     g 7fr   )_get_inline_height)r6  rp  r  s     r   r7  )App._get_inline_height.<locals>.<genexpr>  s     TASv,,T22ASs    )r  maxr;  )r   r  s    @r   rA  App._get_inline_height  s%     yyTASASTTTr   c                    U R                   $ )zThe textual logger.

Example:
    ```python
    self.log("Hello, World!")
    self.log(self.tree)
    ```

Returns:
    A Textual logger.
)r  r   s    r   r4   App.log  s     ||r   c                L   U R                   nUb  UR                  (       d  gUR                  [        R                  R                  :  a  UR
                  (       d  g SSKJn  [        U5      S:X  a  U(       d  UR                  U" XCS9UU5        gSR                  S U 5       5      nU(       a6  SR                  S UR                  5        5       5      n	U(       a  U SU	 3OU	nUR                  U" XS9UU5        g! [         a  n
U R                  U
5         Sn
A
gSn
A
ff = f)	a  Write to logs or devtools.

Positional args will be logged. Keyword args will be prefixed with the key.

Example:
    ```python
    data = [1,2,3]
    self.log("Hello, World", state=data)
    self.log(self.tree)
    self.log(locals())
    ```

Args:
    verbosity: Verbosity level 0-3.
Nr   )DevtoolsLogr7  )caller c              3  8   #    U  H  n[        U5      v   M     g 7fr   r#  )r6  args     r   r7  App._log.<locals>.<genexpr>  s     !>gs#c((g   c              3  6   #    U  H  u  pU S U< 3v   M     g7f)=Nr   )r6  keyr}  s      r   r7  rM    s       *=Kzs3%q	*^s   )rt  r  r}  r0   NORMALverboser  rH  lenr4   joinr  	Exception_handle_exception)r   group	verbosity_textual_calling_frameobjectsr  rt  rH  output
key_valueserrors              r   r  App._log  s    0 ==8#8#8??\00666x?O?O	*67|q G !>g!>>!$ *=C\\^* "J :@xq5ZFF
  	*""5))	*s   3C> A,C> >
D#DD#c                    SSK Jn  U" 5       $ )zGet a widget to be used as a loading indicator.

Extend this method if you want to display the loading state a little differently.

Returns:
    A widget to display a loading state.
r   )LoadingIndicator)textual.widgetsra  )r   ra  s     r   get_loading_widgetApp.get_loading_widget  s     	5!!r   c                    Xl         U R                  c  gSSKnUR                  UR	                  S5      5      R                  S5      nU R                  R                  SU S35        g)zCopy text to the clipboard.

!!! note

    This does not work on macOS Terminal, but will work on most other terminals.

Args:
    text: Text you wish to copy to the clipboard.
Nr   utf-8z]52;c;)r  r  base64	b64encodeencodedecoder   )r   r   rh  base64_texts       r   copy_to_clipboardApp.copy_to_clipboard  sX     <<&&t{{7';<CCGLZ}B78r   c                .  ^ ^ T R                   c  [        S5      eT R                  [        R                  " 5       :X  a  [        S5      e[        U/UQ70 UD6mSUU 4S jjn[        R                  " U" 5       T R                   S9nUR                  5       nU$ )a  Run a callable from another thread, and return the result.

Like asyncio apps in general, Textual apps are not thread-safe. If you call methods
or set attributes on Textual objects from a thread, you may get unpredictable results.

This method will ensure that your code runs within the correct context.

!!! tip

    Consider using [post_message][textual.message_pump.MessagePump.post_message] which is also thread-safe.

Args:
    callback: A callable to run.
    *args: Arguments to the callback.
    **kwargs: Keyword arguments for the callback.

Raises:
    RuntimeError: If the app isn't running or if this method is called from the same
        thread where the app is running.

Returns:
    The result of the callback.
zApp is not runningzIThe `call_from_thread` method must run in a different thread from the appc                    >#    TR                  5          [        T 5      I Sh  vN sSSS5        $  N! , (       d  f       g= f7f)z8Run the callback, set the result or error on the future.N)rm  r?   )callback_with_argsr   s   r   run_callback*App.call_from_thread.<locals>.run_callback$  s,     #$677 !7 !s$   A313
A3
AAloop)r   r   )	r  r  r  r  r  r   r   run_coroutine_threadsafer  )r   r   r  r  rr  futurer  rq  s   `      @r   call_from_threadApp.call_from_thread  s    < ::344??i1133[  %X???	8 	8 07/O/ON0
 r   c                $    U R                  5         g)z8An [action](/guide/actions) to change the current theme.N)search_themesr   s    r   r  App.action_change_theme0  s    r   c                &    U R                  X5        g)zThis [action](/guide/actions) will save an SVG file containing the current contents of the screen.

Args:
    filename: Filename of screenshot, or None to auto-generate.
    path: Path to directory. Defaults to the user's Downloads directory.
N)r  )r   filenamepaths      r   action_screenshotApp.action_screenshot4  s     	/r   )r   simplifyc               d   U R                   c   S5       eU R                  u  p4[        UU[        R                  " 5       SSSSSS9nU R
                  R                  R                  SU R                  R                  US9nUR                  U5        UR                  U=(       d    U R                  S9$ )aG  Export an SVG screenshot of the current screen.

See also [save_screenshot][textual.app.App.save_screenshot] which writes the screenshot to a file.

Args:
    title: The title of the exported screenshot or None
        to use app title.
    simplify: Simplify the segments by combining contiguous segments with the same style.
zApp must be runningT	truecolorF)r  r  rg  rm  rf  recordrk  rn  )rs  r  r  r   )r  r  r$   ioStringIOrp  _compositorrender_updater   r8  print
export_svgr   )r   r   r  r  r  r  screen_renders          r   export_screenshotApp.export_screenshot?  s     ||'>)>>'		$ 	
 //==DHH$@$@8 > 
 	m$!!(;!<<r   c                d   U=(       d    SnU(       d  [        U R                  SU5      nOUn[        R                  R	                  [        R                  R                  X$5      5      nU R                  5       n[        USSS9 nUR                  U5        SSS5        U$ ! , (       d  f       U$ = f)a  Save an SVG screenshot of the current screen.

Args:
    filename: Filename of SVG screenshot, or None to auto-generate
        a filename with the date and time.
    path: Path to directory for output. Defaults to current working directory.
    time_format: Date and time format to use if filename is None.
        Defaults to a format like ISO 8601 with some reserved characters replaced with underscores.

Returns:
    Filename of screenshot.
z./.svgwrf  )r  N)	rH   r   r  r  
expanduserrU  r  openr   )r   r~  r  time_formatsvg_filenamesvg_pathscreenshot_svgsvg_files           r   save_screenshotApp.save_screenshota  s    $ |t5djj&+VL#L77%%bggll4&FG//1(C'2hNN>* 3 32s   B  
B/c           	         U(       d  [        U R                  SU5      nOUnU R                  5       nU R                  [        R
                  " U5      UUSSSS9$ )a  Deliver a screenshot of the app.

This will save the screenshot when running locally, or serve it when the app
is running in a web browser.

Args:
    filename: Filename of SVG screenshot, or None to auto-generate
        a filename with the date and time.
    path: Path to directory for output when saving locally (not used when app is running in the browser).
        Defaults to current working directory.
    time_format: Date and time format to use if filename is None.
        Defaults to a format like ISO 8601 with some reserved characters replaced with underscores.

Returns:
    The delivery key that uniquely identifies the file delivery.
r  browserzimage/svg+xml
screenshotsave_directorysave_filenameopen_method	mime_typerd  )rH   r   r  deliver_textr  r  )r   r~  r  r  r  r  s         r   r  App.deliver_screenshot~  s_    , 5djj&+VL#L//1  KK'&!% ! 
 	
r   c                ^    U R                  [        [        U R                  U5      /US95      $ )zShow a list of commands in the app.

Args:
    commands: A list of SimpleCommand instances.
    placeholder: Placeholder text for the search field.

Returns:
    AwaitMount: An awaitable that resolves when the commands are shown.
	providersplaceholder)push_screenrW   rY   rp  )r   commandsr  s      r   search_commandsApp.search_commands  s3     )$++x@A'
 	
r   c                @    U R                  [        [        /SS95        g)zShow a fuzzy search command palette containing all registered themes.

Selecting a theme in the list will change the app's theme.
u   Search for themes…r  N)r  rW   r   r   s    r   r{  App.search_themes  s"    
 	(/2	
r   )descriptionr,  r}  c               :    U R                   R                  XX4US9  g)a  Bind a key to an action.

!!! warning
    This method may be private or removed in a future version of Textual.
    See [dynamic actions](/guide/actions#dynamic-actions) for a more flexible alternative to updating bindings.

Args:
    keys: A comma separated list of keys, i.e.
    action: Action to bind to.
    description: Short description of action.
    show: Show key in UI.
    key_display: Replacement text for key, or None to use default.
)r,  r}  N)r  r  )r   keysr  r  r,  r}  s         r   r  App.bind  s"    , 	+k 	 	
r   c                    UR                   (       a  UR                   $ UR                  5       u  p#[        U5      nSU;   a%  UR                  UR	                  S5      5        SU 3nX#/-   nSR                  U5      $ )zFormat a bound key for display in footer / key panel etc.

!!! note
    You can implement this in a subclass if you want to change how keys are displayed in your app.

Args:
    binding: A Binding.

Returns:
    A string used to represent the key.
ctrl^+)r}  	parse_keyrr   r  r  rU  )r   r  	modifiersrQ  
key_tokenss        r   get_key_displayApp.get_key_display  sy     &&& !**,	 o YMM)//&12cU)C&
xx
##r   c                Z  #    SSK nU nUR                  nUc   eU GH[  nUR                  S5      (       aa  UR                  S5      u  pg[        R
                  " [        U5      S-  5      I Sh  vN   UR                  R                  5       I Sh  vN   M{  [        U5      S:X  a   UR                  5       (       d  [        U5      n[        R                  " XU5      n UR                  [        U5      5      n	["        R$                  " XY5      n
U
R'                  U5        UR)                  U
5        [+        S5      I Sh  vN   UR                  R                  5       I Sh  vN   [+        S5      I Sh  vN   GM^     g GN N! [          a    [        U5      S:X  a  UOSn	 Nf = f Ng NG N67f)zA task to send key events.r   Nzwait:r    r7  )unicodedatar  r  r  r   sleepr3  r  wait_until_completerT  isalnumro   rn   getlookuprp   r  r3   Key
set_sendersend_messagerM   )r   r  r  r   driverrQ  r#  wait_msoriginal_keychar	key_events              r   _press_keysApp._press_keys  sX    !!!C~~g&& YYs^
mmE'NT$9:::mm77999s8q=+C0C,00::&--.H.VWD #JJs1	$$S)##I.#A&&&mm77999#A&&&'  ;9   :"%c(a-3TD:
 '9&sz   A,F+.E=/!F+F AF+F7AF+=F%>!F+F' F+2F)3F+ F+F"F+!F""F+'F+)F+c                T    U R                   b  U R                   R                  5         gg)zsCalled when stdout or stderr is flushed.

Args:
    stderr: True if the print was to stderr, or False for stdout.

N)r  r   )r   r   s     r   r  
App._flush  s'     $$0%%++- 1r   c                   U R                   b?  [        R                  " 5       nU R                   R                  Xb  UR                  OS5        U R
                  (       a0  U(       a  U R                  OU R                  nUR                  U5        U R                  R                  5        HK  u  nu  pgU(       a  U(       d  U(       d  M  U(       a  M(  UR                  [        R                  " XS95        MM     g)a  Called with captured print.

Dispatches printed content to appropriate destinations: devtools,
widgets currently capturing output, stdout/stderr.

Args:
    text: Text that has been printed.
    stderr: True if the print was to stderr, or False for stdout.
Nr   )r  r  currentframer   f_backr  r  r  r  r  r  r3   Print)r   r   r   current_frametarget_streamtarget_stdout_stderrs           r   r   
App._print!  s     $$0#002M%%++.Gm**T
 5;D11AVAVM% +/*=*=*C*C*E&F&WF##FLL$EF +Fr   c                d    U(       d  U(       d  U R                  U5        gX#4U R                  U'   g)a  Capture content that is printed (or written to stdout / stderr).

If printing is captured, the `target` will be sent an [events.Print][textual.events.Print] message.

Args:
    target: The widget where print content will be sent.
    stdout: Capture stdout.
    stderr: Capture stderr.
N)end_capture_printr  )r   r  stdoutr   s       r   begin_capture_printApp.begin_capture_print;  s*     f""6*+1*:D'r   c                :    U R                   R                  U5        g)zREnd capturing of prints.

Args:
    target: The widget that was capturing prints.
N)r  r  )r   r  s     r   r  App.end_capture_printL  s     	'r   )P      )headlessr  tooltipsnotificationsrD   c              F  ^^^^^#    SSK Jn  U nU(       + Ul        U(       + Ul        [        R
                  " 5       mSU4S jjmS	UUUUU4S jjn[        U" U5      SU 3S9=U l        n	TR                  5       I Sh  vN   UR                  5           U" U5      n
U
R                  5       I Sh  vN   U
7v   [        R                  " S5      I Sh  vN   UR                  5       I Sh  vN   U	I Sh  vN   U R                  (       a  U R                  e SSS5        g N Nr NQ N; N3! [        R                  " S5      I Sh  vN    UR                  5       I Sh  vN    U	I Sh  vN    U R                  (       a  U R                  ef = f! , (       d  f       g= f7f)
a  An asynchronous context manager for testing apps.

!!! tip

    See the guide for [testing](/guide/testing) Textual apps.

Use this to run your app in "headless" mode (no output) and drive the app via a [Pilot][textual.pilot.Pilot] object.

Example:

    ```python
    async with app.run_test() as pilot:
        await pilot.click("#Button.ok")
        assert ...
    ```

Args:
    headless: Run in headless mode (no output or input).
    size: Force terminal size to `(WIDTH, HEIGHT)`,
        or None to auto-detect.
    tooltips: Enable tooltips when testing.
    notifications: Enable notifications when testing.
    message_hook: An optional callback that will be called each time any message arrives at any
        message pump in the app.
r   r   c                 &   > T R                  5         g)z+Called when app is ready to process events.N)ri  )app_ready_events   r   on_app_ready"App.run_test.<locals>.on_app_ready~  s    !r   c                  >#    U R                  5           Tb  [        R                  " T5        [        R                  " 5       U l        [        R                  " 5       U l        U R                  TTTS9I Sh  vN   TR                  5          SSS5        g N! TR                  5         f = f! , (       d  f       g= f7f)z7Run the apps message loop.

Args:
    app: App to run.
N)ready_callbackr  terminal_size)
rm  message_hook_context_varri  r   get_running_loopr  r  r  r  _process_messages)r   r  r  rD   r  r  s    r   run_appApp.run_test.<locals>.run_app  s      *#/044\B ' 8 8 :CI%.%8%8%:CN//'3!)&* 0    $'')   $'')  sF   B>B-A!B7B8B<B-	B>BB**B--
B;7B>z	run_test rc  Nr   )r   zApp[ReturnType]r   r   )textual.pilotr   r  r  r   r  r   _taskwaitrm  _wait_for_screenr  	_shutdownr  )r   r  r  r  r  rD   r   r   r  app_taskpilotr  r  s    ``  `     @@r   run_testApp.run_testT  sE    F 	($,)6%6"!--/	"	* 	*. !,GCL3%?P QQ
X ""$$$\\^*c
,,...mmA&&&mmo%%??//) # ^ 	%
 / '% mmA&&&mmo%%??//) # ^s   A7F!>D!?F!FD+0D#1	D+:FD%F+D',	F5D)6!F
F!#D+%F'F)F+FE
FE!

F)E,
*#FF
FF!r  rU  inline_no_clearmouser  
auto_pilotc          
     (  ^ ^^
^^^#    SSK Jm
  T mSmTc>  [        R                  (       a)  [        R                  R	                  S5      mS	U4S jjnUmS
U
UUUU 4S jjnT R                  5         [        R                  " 5       =n	Tl        [        [        S5      (       a  U	R                  [        R                  5        TR                  5           TR                  Tc  SOUUUUUUS9I Sh  vN    Tb
  TI Sh  vN    [        R                  " TR                  5       5      I Sh  vN   STl        STl         SSS5        TR$                  $  Nb NV N+! [        R                    a     N?f = f!  [        R                  " TR                  5       5      I Sh  vN    f ! [        R                    a     f f = f= f!  Tb  TI Sh  vN     [        R                  " TR                  5       5      I Sh  vN    Og! [        R                    a     OQf = f!  [        R                  " TR                  5       5      I Sh  vN    f ! [        R                    a     f f = f= fSTl        STl        f = f! , (       d  f       TR$                  $ = f7f)a  Run the app asynchronously.

Args:
    headless: Run in headless mode (no output).
    inline: Run the app inline (under the prompt).
    inline_no_clear: Don't clear the app output when exiting an inline app.
    mouse: Enable mouse support.
    size: Force terminal size to `(WIDTH, HEIGHT)`,
        or None to auto-detect.
    auto_pilot: An autopilot coroutine.

Returns:
    App return value.
r   r   Nrd  c                @   >#    U R                   " T6 I Sh  vN   g N7f)zAuto press keys.N)press)r  r  s    r   
press_keys!App.run_async.<locals>.press_keys  s     kk4(((s   c                 x   >#    Tb2        SUU4S jjn T" T5      n[        U " TU5      [        U5      S9mgg7f)z1Called by the message loop when the app is ready.Nc                   >#    TR                  5           U " U5      I S h  vN    S S S 5        g  N! [         a    TR                  5         e f = f! , (       d  f       g = f7fr   )rm  rV  r  )r   r  r   r   s     r   run_auto_pilot8App.run_async.<locals>.app_ready.<locals>.run_auto_pilot  sP      "",U"333 )3( "HHJ!" )s6   A"A202	A"2AA
AA"rc  )r   r   r  r   r   r   )r   repr)r  r  r   r   r   auto_pilot_taskr   s     r   	app_ready App.run_async.<locals>.app_ready  sZ      %" 5">C"" " c
"-":u5DK# &s   7:eager_task_factory)r  r  rU  r  r  r  )r  zPilot[ReturnType]r   r   r   )r  r   r2   PRESSr  r  r   r  r  hasattrset_task_factoryr  rm  r  shieldr  CancelledErrorr  r/  )r   r  rU  r  r  r  r   r  r  ru  r   r   r  r  s   `     `   @@@@r   	run_asyncApp.run_async  s&    0 	('+)//??((-D) $J	 	* 	"3355sy7011!!'"<"<=\\^#+++5+=49%!$3"& ,   &2---%nnS]]_=== !	!") , ) . >"11 %nnS]]_==="11 &2---%nnS]]_==="11 %nnS]]_==="11  	!") ^, sJ  CJI6F>.E/F>4E1<E=E1'E)E*E.I6=JF>E1EE.+I6-E..I61F;3'F!F
F! F;!F8	5F;7F8	8F;;I6>I3 HG
	H'G=6G9
7G=<I3=H	I3H	I3I!	'I
 II
I!	II!	II!	!I33I66
J J)r  rU  r  r  r  r   ru  c               X  ^ ^^^^^^ SUUUUUU U4S jjnUcR  [         (       a  [        R                  " U" 5       5      $  [        R                  " 5       n	U	R	                  U" 5       5      $ UR	                  U" 5       5      $ ! [
         a     Of = f[        R                  " U" 5       5      $ )a  Run the app.

Args:
    headless: Run in headless mode (no output).
    inline: Run the app inline (under the prompt).
    inline_no_clear: Don't clear the app output when exiting an inline app.
    mouse: Enable mouse support.
    size: Force terminal size to `(WIDTH, HEIGHT)`,
        or None to auto-detect.
    auto_pilot: An auto pilot coroutine.
    loop: Asyncio loop instance, or `None` to use default.
Returns:
    App return value.
c            	     H   >#    TR                  TTTTTT S9I Sh  vN $  N7f)zRun the app.r  N)r  )r   r  rU  r  r  r   r  s   r   r  App.run.<locals>.run_app	  s8     ! /% (    s   " "r   ReturnType | None)%_ASYNCIO_GET_EVENT_LOOP_IS_DEPRECATEDr   runget_event_looprun_until_completer  )
r   r  rU  r  r  r  r   ru  r  global_loops
   ```````   r   r  App.run	  s    4		 		 <44 {{79--	A%446 #55gi@@&&wy11   
  ;;wy))s    B 
BBc           	       #    U R                   b  U R                   R                  OU R                  nU(       Ga+   [        5       nU R                  R                  5       n UR                  U5        UR                  5         [        5       U-
  S-  nU R                  (       a@  SSKJn  U R                  R                  U" SSR!                  S U 5       5      -   SSS	95        U R                  R                  S
[#        U5       SUS S35        SU l        X0l        U R                  R%                  U 5        U R&                   H  nU R                  R%                  U5        M      gg! [         a.  nU R                  R                  [        U5      5         SnAgSnAff = f! [(         a<  nSU l        U R                  R+                  U5        U R-                  5          SnAgSnAff = f7f)z<Callback for the file monitor, called when CSS files change.Nr  r   )Panelz7CSS files successfully loaded after previous error:

- z
- c              3  8   #    U  H  n[        U5      v   M     g 7fr   r#  )r6  r  s     r   r7  %App._on_css_change.<locals>.<genexpr>V	  s     )J	#d))	rN  green)styleborder_stylez<stylesheet> loaded z CSS files in z.0fz msFT)r  _pathsr  r   r  r  read_allr\   r4   warningr   parser  
rich.panelr"  r/  rU  rT  rx  r  rV  r^  bell)r   r  timer  r^  elapsedr"  rp  s           r   r  App._on_css_change<	  s     (,'7'7'CD## 	 &3#~!__113
''	2   "'>D0D8''0HHOOW$kk)J	)JJK"))0	 *3y>*:.QTUXY (-$",&&t,"//FOO**62 0M  ' 
 HH$$SZ0.  '+$u%			s`   8G*$F!  E& 1BF! AG*&
F0$FF! G*FF! !
G'+2G"G*"G''G*c                @    [        U R                  R                  5      $ )z~Render method, inherited from widget, to render the screen's background.

May be overridden to customize background visuals.

)rz   r3  r4  r   s    r   render
App.renderj	  s     T[[++,,r   
ExpectTyper   c                    g r   r   r   r  s     r   get_child_by_idApp.get_child_by_idv	  s    69r   c                    g r   r   r   r  expect_types      r   r7  r8  y	       r   c                t    Uc  U R                   R                  U5      $ U R                   R                  X5      $ )a  Get the first child (immediate descendant) of this DOMNode with the given ID.

Args:
    id: The ID of the node to search for.
    expect_type: Require the object be of the supplied type,
        or use `None` to apply no type restriction.

Returns:
    The first child of this node with the specified ID.

Raises:
    NoMatches: If no children could be found for this ID.
    WrongType: If the wrong type was found.
)rp  r7  r:  s      r   r7  r8  ~	  s<    & " KK''+	
 ,,R=	
r   c                    g r   r   r6  s     r   get_widget_by_idApp.get_widget_by_id	  s    7:r   c                    g r   r   r:  s      r   r?  r@  	  r<  r   c                t    Uc  U R                   R                  U5      $ U R                   R                  X5      $ )a  Get the first descendant widget with the given ID.

Performs a breadth-first search rooted at the current screen.
It will not return the Screen if that matches the ID.
To get the screen, use `self.screen`.

Args:
    id: The ID to search for in the subtree
    expect_type: Require the object be of the supplied type, or None for any type.
        Defaults to None.

Returns:
    The first descendant encountered with this ID.

Raises:
    NoMatches: if no children could be found for this ID
    WrongType: if the wrong type was found.
)rp  r?  r:  s      r   r?  r@  	  s<    . " KK((,	
 --b>	
r   c                8    U R                   R                  U5      $ )zGet a child of a give type.

Args:
    expect_type: The type of the expected child.

Raises:
    NoMatches: If no valid child is found.

Returns:
    A widget.
)rp  get_child_by_type)r   r;  s     r   rD  App.get_child_by_type	  s     {{,,[99r   c                D   [        U[        5      (       ac  [        U R                  5       HI  nUR	                  US9  UR
                  (       a&  UR                  R                  R                  S:  a  MI    g   gUR                  SS9nU R                  R                  XBS9  g)a\  Immediately update the styles of this node and all descendant nodes.

Called by Textual whenever CSS classes / pseudo classes change.
For example, when you hover over a button, the :hover pseudo class
will be added, and this method is called to apply the corresponding
:hover styles.

Args:
    node: Node to update.
    animate: Enable animation?
r  r7  T	with_selfN)r  r  r:  r  update_node_stylesis_modalr3  r4  r5  walk_childrenr  update_nodes)r   noder~  rp  descendantss        r   update_stylesApp.update_styles	  s     dC  "4#4#45))'):FMM,D,D,F,F,J 6
 ,,t,<KOO(((Fr   beforeafterc               :    U R                   R                  " X1US.6$ )a  Mount the given widgets relative to the app's screen.

Args:
    *widgets: The widget(s) to mount.
    before: Optional location to mount before. An `int` is the index
        of the child to mount before, a `str` is a `query_one` query to
        find the widget to mount before.
    after: Optional location to mount after. An `int` is the index
        of the child to mount after, a `str` is a `query_one` query to
        find the widget to mount after.

Returns:
    An awaitable object that waits for widgets to be mounted.

Raises:
    MountError: If there is a problem with the mount request.

Note:
    Only one of `before` or `after` can be provided. If both are
    provided a `MountError` will be raised.
rQ  )rp  mount)r   rR  rS  widgetss       r   rU  	App.mount	  s    6 {{  'FFr   c               &    U R                   " XUS.6$ )a  Mount widgets from an iterable.

Args:
    widgets: An iterable of widgets.
    before: Optional location to mount before. An `int` is the index
        of the child to mount before, a `str` is a `query_one` query to
        find the widget to mount before.
    after: Optional location to mount after. An `int` is the index
        of the child to mount after, a `str` is a `query_one` query to
        find the widget to mount after.

Returns:
    An awaitable object that waits for widgets to be mounted.

Raises:
    MountError: If there is a problem with the mount request.

Note:
    Only one of `before` or `after` can be provided. If both are
    provided a `MountError` will be raised.
rQ  )rU  )r   rV  rR  rS  s       r   	mount_allApp.mount_all	  s    8 zz7??r   c                r   U R                   R                  U/ 5      nU(       a  [        US   / 5      $ XR                  ;   a  U R                  U   n[	        U[
        5      (       a&  [        S[        U5      R                   SU< S35      e[        U5      (       a  U" 5       OUnU R                  U5      u  pVUR                  U5        U R                  U5        UR                  U R                  :w  a  U R                  5         UR                  [         R"                  " 5       5        OeU R%                  5       nUR                  U5        U R'                  X5        UR                  [         R"                  " 5       5        [        US   / 5      nUR)                  U R*                  5        X R                   U'   U$ )zDo internal initialization of a new screen stack mode.

Args:
    mode: Name of the mode.

Returns:
    An optionally awaitable object which can be awaited until the screen
    associated with the mode has been mounted.
r   zDMODES cannot contain instances, use a type instead (got instance of r  r  )r  r  r   r  r  r|   r  r  r   r	  _get_screenr  _load_screen_cssr  r  r  r3   ScreenResumer  	_register_screen_resizedr  )r   r  r  _screen
new_screenrp  await_mounts          r   
_init_modeApp._init_mode
  su    ##''b1 eAh++;;kk$'G'6**((,W(>(>'?uTHAO  5=W4E4Ewy7J"&"2"2:">FLL !!&)''4+A+AA  " 3 3 56 ,,.FLL NN4( 3 3 56$U1Xr2Ktyy)$)D!r   c                   XR                   :X  a  [        U R                  / 5      $ XR                  ;  a  [	        SU< 35      eU R                  5         U R                  R                  [        R                  " 5       5        U R                  R                  5         XR                  ;  a  U R                  U5      nO[        U R                  / 5      nXl         U R                  R                  U R                  :w  a  U R                  5         U R                  R                  U5        U R                   R                  U R                  5        U R                  R#                  U R$                  5        U R                  R                  [        R&                  " 5       5        U R(                  R+                  U R                   < S35        U R(                  R+                  U R                   S35        U$ )a   Switch to a given mode.

Args:
    mode: The mode to switch to.

Returns:
    An optionally awaitable object which waits for the screen associated
        with the mode to be mounted.

Raises:
    UnknownModeError: If trying to switch to an unknown mode.

r/  z is the current mode
 is active)r  r   rp  r  r   rb  r  r3   ScreenSuspendr_  r  rd  r  r  r  r  r  r`  r  r^  r4   r/  )r   r  rc  s      r   switch_modeApp.switch_modeF
  se    %%%dkk2..{{""^D8#<==  !5!5!78***//$/K$T[["5K!;;((D,B,BB''-!!))$++6##DII.  !4!4!674--00DEF4;;-z23r   c                    US:X  a  [        S5      eXR                  ;   a  [        SU< S35      e[        U[        5      (       a"  [	        S[        U5      R                   S35      eX R                  U'   g)zAdds a mode and its corresponding base screen to the app.

Args:
    mode: The new mode.
    base_screen: The base screen associated with the given mode.

Raises:
    InvalidModeError: If the name of the mode is not valid/duplicated.
r  z'Cannot use '_default' as a custom mode.zDuplicated mode name .zOadd_mode() must be called with a Screen type, not an instance (got instance of r  N)r   r  r  r|   r  r  r   )r   r  base_screens      r   add_modeApp.add_modeu
  s}     :"#LMM[[ "%:4(!#DEEk6**%%)+%6%?%?$@C  (Dr   c                n  ^ ^ UT R                   :X  a  [        SU< 35      eUT R                  ;  a  [        SU< 35      eT R                  U	 UT R                  ;  a  [
        R                  " 5       $ T R                  U   mT R                  U	 SU U4S jjn[        U" 5       5      R                  T 5      $ )a,  Removes a mode from the app.

Screens that are running in the stack of that mode are scheduled for pruning.

Args:
    mode: The mode to remove. It can't be the active mode.

Raises:
    ActiveModeError: If trying to remove the active mode.
    UnknownModeError: If trying to remove an unknown mode.
zCan't remove active mode zUnknown mode c                 h   >#    [        T5       H  n TR                  U 5      I Sh  vN   M     g N	7f)zRemove screens.N)r:  _replace_screen)rp  r   r  s    r   remove_screens'App.remove_mode.<locals>.remove_screens
  s+     "5/**6222 *2s   #20
2r   )r  r   r  r   r  rP   nothingr  )r   r  rs  r  s   `  @r   remove_modeApp.remove_mode
  s     4%%%!$=dX"FGG$"]4(#;<<D!t*** ((**##D)%	3 	3
 ^-.88>>r   c                    [        U[        5      (       a  XR                  ;   $ XR                  R                  5       ;   $ )zCheck if a given screen has been installed.

Args:
    screen: Either a Screen object or screen name (the `name` argument when installed).

Returns:
    True if the screen is currently installed,
)r  r   r  r  r  s     r   is_screen_installedApp.is_screen_installed
  s8     fc""444444;;===r   c                    g r   r   r  s     r   
get_screenApp.get_screen
  s    <?r   c                    g r   r   r  s     r   r|  r}  
  s    14r   c                    g r   r   r   rp  screen_classs      r   r|  r}  
       r   c                    g r   r   r  s      r   r|  r}  
  r  r   c                8   [        U[        5      (       a6   U R                  U   n[	        U5      (       a  U" 5       nX0R                  U'   OUnUb*  [        X25      (       d  [        SU S[        U5       35      eU$ ! [         a    [        SU< S35      Sef = f)au  Get an installed screen.

Example:
    ```python
    my_screen = self.get_screen("settings", MyScreen)
    ```

Args:
    screen: Either a Screen object or screen name (the `name` argument when installed).
    screen_class: Class of expected screen, or `None` for any screen class.

Raises:
    KeyError: If the named screen doesn't exist.

Returns:
    A screen instance.
zNo screen called z
 installedNzExpected a screen of type z, got )r  r   r  r  r	  r  r  )r   rp  r  next_screens       r   r|  r}  
  s    ( fc""S"55f= $$)m2=''/ K#J{,Q,Q,\N&kAR@ST    S!26*JGHdRSs   A= =Bc                    U R                  U5      nUR                  (       d0  U R                  X5      n[        X#5      nU R	                  U5        X$4$ [        U/ 5      nU R	                  U5        X$4$ )ae  Get an installed screen and an AwaitMount object.

If the screen isn't running, it will be registered before it is run.

Args:
    screen: Either a Screen object or screen name (the `name` argument when installed).

Raises:
    KeyError: If the named screen doesn't exist.

Returns:
    A screen instance and an awaitable that awaits the children mounting.
)r|  
is_runningr_  r   r  )r   rp  ra  rV  rc  s        r   r\  App._get_screen
  si     //&)!!nnT3G$W6KNN;'))$Wb1KNN;'))r   c                4   U R                   b%  U R                   R                  UR                  5        SnUR                   HL  nU R                  R	                  [        U5      S5      (       a  M/  U R                  R                  U5        SnMN     UR                  (       a   [        R                  " UR                  5      nUR                  R                   S3nXE4nU R                  R	                  XE5      (       dE  U R                  R                  UR                  USUR                  (       a  UR                   OSS9  SnU(       a6  U R                  R#                  5         U R                  R%                  U 5        gg! [        [        4 a    Sn Nf = f)z'Loads the CSS associated with a screen.NFr  T.CSS)	read_fromis_default_cssscope)r  	add_pathsr  r  
has_sourcer   readr  r  getfiler  r  OSErrorr   
add_source
SCOPED_CSS_css_type_namereparserx  )r   rp  rx  r  screen_pathscreen_class_varr  s          r   r]  App._load_screen_css  sK    '&&v7OOD??--c$i<<$$T* $ ::!%oof.>.>? #)"2"2";";!<DA$7I??--kLL**JJ'#(393D3D&//"	 +  OO##%OO""4(  w' ! !s   # F FFc                  ^#    U R                   (       a  U R                  R                  5         TR                  [        R
                  " 5       5        U R                  R                  T S35        U R                  T5      (       dy  [        U4S jU R                  R                  5        5       5      (       aG  U R                  S5        TR                  5       I Sh  vN   U R                  R                  T S35        T$  N$7f)zlHandle the replaced screen.

Args:
    screen: A screen object.

Returns:
    The screen that was replaced.
z
 SUSPENDEDc              3  .   >#    U  H
  nTU;  v   M     g 7fr   r   r6  r  rp  s     r   r7  &App._replace_screen.<locals>.<genexpr>1  s      8
-IEF%-I   Nz REMOVED)r;  rp  r_  r  r3   rh  r4   r/  ry  allr  r  capture_mouseremover  s    `r   rr  App._replace_screen$  s      KK!F00236(*-.''//C 8
-1-@-@-G-G-I8
 5
 5
 t$--/!!HHOOvhh/0 "s   CDD%D)r  c                   g r   r   r   rp  r   wait_for_dismissr  s        r   r  App.push_screen;  s     r   c                   g r   r   r  s        r   r  r  E  s     03r   c               X   [        U[        [        45      (       d  [        SU< 35      e [        R
                  " 5       nUR                  5       nUc  U R                  n U R                  U   nU(       ah  US   R                  (       aT  U R                  R                  S5        US   nUR!                  ["        R$                  " 5       5        UR'                  5         U R)                  U5      u  p [*        R,                  " 5       nU	R1                  XU5        U R3                  U	5        U	R5                  5         UR7                  U	5        U	R                  (       a$  U	R!                  ["        R8                  " 5       5        U R:                  R=                  U	5        U(       a   [?        5         U$ U
$ ! [         a    [        R                  " 5       n GNf = f! [         a    [        SU< 35      ef = f! [.         a    U R                  n GNf = f! [@         a    [A        S5      Sef = f)a  Push a new [screen](/guide/screens) on the screen stack, making it the current screen.

Args:
    screen: A Screen instance or the name of an installed screen.
    callback: An optional callback function that will be called if the screen is [dismissed][textual.screen.Screen.dismiss] with a result.
    wait_for_dismiss: If `True`, awaiting this method will return the dismiss value from the screen. When set to `False`, awaiting
        this method will wait for the screen to be mounted. Note that `wait_for_dismiss` should only be set to `True` when running in a worker.
    mode: The mode to push the screen to, or `None` to the currently active mode. If pushing to a non-current mode, the screen will not be immediately visible.

Raises:
    NoActiveWorker: If using `wait_for_dismiss` outside of a worker.

Returns:
    An optional awaitable that awaits the mounting of the screen and its children, or an asyncio Future
        to await the result of the screen.
z3push_screen requires a Screen instance or str; not NzNo such mode r	  zEpush_screen must be run from a worker when `wait_for_dismiss` is True)!r  r|   r   r  r   r  create_futurer  r   r  r  r  r   	is_activer   r  r  r3   rh  r_  r\  rC   r  LookupError_push_result_callbackr]  _update_auto_focusr  r^  r  r  r   r   )r   rp  r   r  r  ru  rw  r  mode_screenr  rc  message_pumps               r   r  r  O  s   0 &63-00EfZP 	*++-D
 '')F<%%D	=..t4L L,66HH""4(&r*K$$V%9%9%;<!#'#3#3F#; 	$.224L 	)),&Ik*&&(K(  $$V%8%8%:;!!))+6"$
 MS  	H7>~~7GF	H  	="]4(#;<<	=  	$88L	$ " $[s;   F2 !G 3G5 $
H 2GGG25HHH)c                  #    g 7fr   r   r   rp  r  s      r   push_screen_waitApp.push_screen_wait  s
       #   c                  #    g 7fr   r   r  s      r   r  r    s
      r  c                  #    U R                  5       I Sh  vN   [        R                  " U R                  USUS95      I Sh  vN $  N1 N7f)a  Push a screen and wait for the result (received from [`Screen.dismiss`][textual.screen.Screen.dismiss]).

Note that this method may only be called when running in a worker.

Args:
    screen: A screen or the name of an installed screen.
    mode: The mode to push the screen to, or `None` to the currently active mode. If pushing to a non-current mode, the screen will not be immediately visible.

Returns:
    The screen's result.
NT)r  r  )_flush_next_callbacksr   r  r  r  s      r   r  r    sN      ((***^^VdF
 
 	
 	+
s!   AA,AA
A
Ac                  ^ ^^ [        U[        [        45      (       d  [        SU< 35      eT R	                  U5      u  nmUT R
                  L d  UT R
                  L a4  T R                  R                  SU S35        [        R                  " 5       $ T R                  R                  S5        T R                  R                  5       mTR                  5         T R                  U5        T R                  R!                  U5        T R
                  R#                  [$        R&                  " 5       5        T R
                  R)                  T R
                  S5        T R*                  R-                  T R
                  5        T R                  R                  T R
                   S35        SUU U4S jjn[        U" 5       5      R/                  T 5      $ )zSwitch to another [screen](/guide/screens) by replacing the top of the screen stack with a new screen.

Args:
    screen: Either a Screen object or screen name (the `name` argument when installed).
z5switch_screen requires a Screen instance or str; not Screen z is already current.Nz is current (SWITCHED)c                 f   >#    T " 5       I Sh  vN   TR                  T5      I Sh  vN   g N N7f)zTask to perform switch.Nrr  )rc  r   
top_screens   r   	do_switch$App.switch_screen.<locals>.do_switch  s/      -&&z222  2s   1-1/11r   )r  r|   r   r  r\  rp  r4   r/  rP   ru  r   r  r;  r  _pop_result_callbackr]  r  r  r3   r^  r  r  r  r  )r   rp  r  r  rc  r  s   `   @@r   switch_screenApp.switch_screen  sc    &63-00GzR  $(#3#3F#; [T[[ K4;;$>HHOOgfX-ABC ((**t$''++-
'')k*!!+.  !4!4!67))$++t<!!))$++64;;-'=>?	3 	3 Y[)33D99r   c                    X R                   ;   a  [        SU< S35      eXR                   R                  5       ;   a  [        SU< S35      eXR                   U'   U R                  R	                  U SU< 35        g)a  Install a screen.

Installing a screen prevents Textual from destroying it when it is no longer on the screen stack.
Note that you don't need to install a screen to use it. See [push_screen][textual.app.App.push_screen]
or [switch_screen][textual.app.App.switch_screen] to make a new screen current.

Args:
    screen: Screen to install.
    name: Unique name to identify the screen.

Raises:
    ScreenError: If the screen can't be installed.

Returns:
    An awaitable that awaits the mounting of the screen and its children.
zCan't install screen; z is already installedz has already been installedz INSTALLED name=N)r  r   r  r4   r/  )r   rp  rd  s      r   install_screenApp.install_screen  s    " *** 6th>STUU,,3355(
2MN  )/%6("24(;<r   c                  ^^ [        T[        5      (       a  TU R                  ;  a  gU R                  T   m[        U4S jU R                  R                  5        5       5      (       a  [        S5      eU R                  T	 U R                  R                  T ST< 35        T$ [        U4S jU R                  R                  5        5       5      (       a  [        S5      eU R                  R                  5        HJ  u  p#UTL d  M  U R                  R                  U5        U R                  R                  T SU< 35        Us  $    g)a(  Uninstall a screen.

If the screen was not previously installed, then this method is a null-op.
Uninstalling a screen allows Textual to delete it when it is popped or switched.
Note that uninstalling a screen is only required if you have previously installed it
with [install_screen][textual.app.App.install_screen].
Textual will also uninstall screens automatically on exit.

Args:
    screen: The screen to uninstall or the name of an installed screen.

Returns:
    The name of the screen that was uninstalled, or None if no screen was uninstalled.
Nc              3  .   >#    U  H
  nTU;   v   M     g 7fr   r   )r6  r  uninstall_screens     r   r7  'App.uninstall_screen.<locals>.<genexpr>	  s     W:V#u,:Vr  z&Can't uninstall screen in screen stackz UNINSTALLED name=c              3  .   >#    U  H
  nTU;   v   M     g 7fr   r   r  s     r   r7  r    s     M0Lu6U?0Lr  )r  r   r  anyr  r  r   r4   r/  r  r  )r   rp  rd  installed_screenr  s    `  @r   r  App.uninstall_screen  s    fc""T444#66v>W$:M:M:T:T:VWWW&'OPP''/HHOO/00B6*MNMM0C0C0J0J0LMMM&'OPP*.*A*A*G*G*I&#v-++//5HHOOvh.@$IJK	 +J
 r   c                  ^ ^ T R                   n[        U5      S::  a  [        S5      eUR                  5       mTR	                  5         T R
                  R                  [        R                  " TR                  R                  R                  S:  S95        T R                  R                  T R
                  5        T R                  R                  T R
                   S35        SUU 4S jjn[!        U" 5       5      R#                  T 5      $ )zPop the current [screen](/guide/screens) from the stack, and switch to the previous screen.

Returns:
    The screen that was replaced.
r7  z@Can't pop screen; there must be at least one screen on the stackr   )refresh_stylesrg  c                 D   >#    TR                  T 5      I Sh  vN   g N7f)zTask to pop the screen.Nr  )previous_screenr   s   r   do_popApp.pop_screen.<locals>.do_pop-  s     &&777s     r   )r;  rT  r   r  r  rp  r  r3   r^  r3  r4  r5  r  r  r4   r/  rP   r  )r   r  r  r  s   `  @r   
pop_screenApp.pop_screen  s     ))|!"R  '**,,,.  /E/E/P/P/R/RUV/VW	
 	!!))$++64;;-z23	8 	8 VX&0066r   c                   ^ ^ / m[        T R                  5       H  nX!La  TR                  U5        M    O   [        SU< S35      eSUU 4S jjnT(       a  T R	                  U5        gg)zPop screens until the given screen is active.

Args:
    screen: desired active screen

Raises:
    ScreenError: If the screen doesn't exist in the stack.
r  z not in screen stackc                    >#    TR                  5          T H  n U R                  5       I Sh  vN   M     SSS5        g N! , (       d  f       g= f7f)z$Pop any screens in `screens_to_pop`.N)rV  dismiss)rp  screens_to_popr   s    r   pop_screens'App._pop_to_screen.<locals>.pop_screensE  s?     ""$,F ..*** - %$* %$s)   AA?A	AA
AANr   )r:  r  r  r   
call_later)r   rp  r  r  r  s   `   @r   _pop_to_screenApp._pop_to_screen3  sm     (*"4#4#45J'%%j1	 6 z1EFGG	+ 	+ OOK( r   c                :    U R                   R                  X5        g)zFocus (or unfocus) a widget. A focused widget will receive key events first.

Args:
    widget: Widget to focus.
    scroll_visible: Scroll widget into view.
N)rp  	set_focus)r   widgetscroll_visibles      r   r  App.set_focusN  s     	f5r   c                   UcP  U R                   bB   U R                   R                  [        R                  " U R                   5      5        SU l         OOU R                   ULau   U R                   b9  U R                   R                  [        R                  " U R                   5      5        Ub%  UR                  [        R                  " U5      5        Xl         U R
                  nUb  SUl        Ub(  SUl        UR                  (       a  UR                  5         Ub!  UR                  (       a  UR                  5         X l        g! SU l         f = f! Xl         f = f)zmCalled when the mouse is over another widget.

Args:
    widget: Widget under mouse, or None for no widgets.
NFT)	r  r  r3   LeaveEnterr  mouse_hover_has_hover_stylerI  )r   r  hover_widgetcurrent_hover_overs       r   _set_mouse_overApp._set_mouse_overW  s    >*+OO00doo1NO&*DO	 + f,-244V\\$//5RS)++FLL,@A&,O!__)-2*#'+L$,,//1).@.Q.Q113&+ '+DO '-Os   9E $A.E 	EEc                z   ^ ^ T R                   b  TR                  (       d  gSUU 4S jjnT R                  U5        g)zUpdates the mouse over after the next refresh.

This method is called whenever a widget is added or removed, which may change
the widget under the mouse.

Nc                    >#     TR                   " TR                  6 n U R                  u  pUTR                  Ld  UTR                  La  TR                  X5        gg! [         a     gf = f7f)z+Check if the mouse over widget has changed.N)get_hover_widgets_atr  rV  r  r  r  rc   )hover_widgetsr  r  rp  r   s      r   check_mouse+App._update_mouse_over.<locals>.check_mouse  sp     
A & ; ;T=P=P Q *7)>)>&
doo5!8((@ 9  s'   A-A ?A-
A*'A-)A**A-r   )r  r  call_after_refresh)r   rp  r  s   `` r   _update_mouse_overApp._update_mouse_over{  s6     ??"&*:*:	A 	A 	,r   c                T   XR                   :X  a  gU R                   b9  U R                   R                  [        R                  " U R                  5      5        Xl         Ub/  UR                  [        R
                  " U R                  5      5        U R                  R                  5         g)aK  Send all mouse events to the given widget or disable mouse capture.

Normally mouse events are sent to the widget directly under the pointer.
Capturing the mouse allows a widget to receive mouse events even when the pointer is over another widget.

Args:
    widget: Widget to capture mouse events, or `None` to end mouse capture.
N)r  r  r3   MouseReleaser  MouseCapturerp  update_pointer_shaper   r  s     r   r  App.capture_mouse  s     (((*,,V-@-@ATAT-UV$ 3 3D4G4G HI((*r   c                   ^  [        S U 5       5      (       d   S5       eSU 4S jjnU Vs/ s H  n[        U" U5      5      PM     nnT R                  R                  U5        T R	                  5         gs  snf )zExits the app and display error message(s).

Used in response to unexpected errors.
For a more graceful exit, see the [exit][textual.app.App.exit] method.

Args:
    *renderables: Text or Rich renderable(s) to display on exit.
c              3  8   #    U  H  n[        U5      v   M     g 7fr   r)   )r6  
renderables     r   r7  App.panic.<locals>.<genexpr>  s      
8C*M*%%rN  z4Can only call panic with strings or Rich renderablesc                z   > [        TR                  R                  U TR                  R                  5      5      nU$ )zRender a panic renderables.)listr  r2  options)r  segmentsr   s     r   r2  App.panic.<locals>.render  s-    DLL//
DLL<P<PQRHOr   N)r  r'   r   zlist[Segment])r  r,   r  extend_close_messages_no_wait)r   renderablesr2  r  pre_rendereds   `    r   panic	App.panic  s      
8C
 
 
 	BA	B 
	
 HSS{
!34{S%%l3$$& Ts   A5c                    SU l         U R                  c   Xl        U R                  R                  5         [	        US5      (       a  U R                  U5        gU R                  5         g)zqCalled with an unhandled exception.

Always results in the app exiting.

Args:
    error: An exception instance.
r7  N__rich__)r  r  r  ri  r  r  _fatal_error)r   r^  s     r   rW  App._handle_exception  sV      ??"#O!!%%'5*%%JJu r   c                   SSK Jn  U R                  5         U" SSS[        /S9nU R                  R                  [        U R                  R                  X R                  R                  5      5      5        U R                  5         g)z+Exits the app after an unhandled exception.r   )	TracebackTNr!  )show_localsr  locals_max_lengthsuppress)rich.tracebackr  r-  richr  r  r,   r  r2  r  r  )r   r  	tracebacks      r   r  App._fatal_error  sh    ,		DA
	 	%%T\\((LL4H4HIJ	
 	$$&r   c                   [        U R                  5      nSU R                  ;   aS  U R                   H  nU R                  R	                  U5        M      US:  a  U R                  R	                  SU S3SS9  O]U R                  (       aL  U R                  R	                  U R                  S   5        US:  a  U R                  R	                  SU S	3SS9  U R                  R                  5         g
)z!Print and clear exit renderables.r  r7  z
[b]NOTE:[/b] z errors shown above.Trh  r   z
[b]NOTE:[/b] 1 of zB errors shown. Run with [b]textual run --dev[/] to see all errors.N)rT  r  r  r  r  clear)r   error_countr  s      r   _print_error_renderablesApp._print_error_renderables  s    $001dmm#"44
""((4 5Q""((%k]2FGPT )  ##$$T%;%;A%>?Q""((*;-7yz ) 
 	$$&r   c                    U(       a	  SSK Jn  UnO'U(       a  [        (       d	  SSKJn  UnOU R
                  nU" U [        R                  UUS9=ol        U$ )zConstruct a driver instance.

Args:
    headless: Request headless driver.
    inline: Request inline driver.
    mouse: Request mouse support.
    size: Initial size.

Returns:
    Driver instance.
r   )HeadlessDriver)LinuxInlineDriver)r  r  r  )	textual.drivers.headless_driverr  r  #textual.drivers.linux_inline_driverr  r  r2   r  r  )	r   r  rU  r  r  r  r  r  r  s	            r   _build_driverApp._build_driver  sQ      F)LGGM,L,,L ,//	!
 	
 r   c                b  #    U R                   b]  SSKJn   U R                   R                  5       I Sh  vN   U R                  R                  SU R                   R                   S35        gg N9! U a6    U R                  R                  SU R                   R                   S35         gf = f7f)zInitialize developer tools.Nr   )DevtoolsConnectionErrorzConnected to devtools ( z )zCouldn't connect to devtools ( )rt  r  r%  connectr4   r/  url)r   r%  s     r   _init_devtoolsApp._init_devtools  s     ==$BYmm++---":4==;L;L:MR PQ % .* Y"A$--BSBSATTV WXYs8   B/A0 A.7A0 ,B/.A0 09B,)B/+B,,B/c           	       ^ ^#    T R                  5         SU 4S jjnUU 4S jn	T R                  5          U" 5       I S h  vN (       d
   S S S 5        g ST l         [        R                  " 5       n
T R                  U
5      I S h  vN   T R                  UUUUS9=nT l        T R                  US9  T R                  (       Gd  UR                  5          [        T R                  5         [        T R                  5         U	" 5       I S h  vN   S S S 5        S S S 5        [        R                   " T 5        T R                  R"                  (       Ga  T R$                  u  pT R                  R'                  [(        R*                  " U* U* 5      R,                  R.                  5        T R                  R1                  5         U(       aL  T R2                  R4                  (       d1  [7        5       n UR9                  T R:                  R<                  5        OOT R                  R'                  [(        R*                  " ST R@                  * 5      R,                  R.                  5        URC                  5         O S S S 5        g  GN= GN GNx! , (       d  f       GN}= f! , (       d  f       GN= f! [>         a    UR9                  5          Ndf = f! [        R                   " T 5        T R                  R"                  (       Ga0  T R$                  u  pT R                  R'                  [(        R*                  " U* U* 5      R,                  R.                  5        T R                  R1                  5         U(       al  T R2                  R4                  (       dQ  [7        5       n UR9                  T R:                  R<                  5        Oo! [>         a    UR9                  5          OSf = fT R                  R'                  [(        R*                  " ST R@                  * 5      R,                  R.                  5        URC                  5         f = f! [D         a  nT RG                  U5         S nAGNS nAff = f! , (       d  f       g = f7f)Nc            	       >#    TR                  5       I Sh  vN   TR                  R                  S5        TR                  R                  [        R                  " 5       S9  TR                  R                  TR
                  S9  [        R                  bL  [        R                  R                  [        R                  5      n TR                  R                  SU < 35         TR                  (       a%  TR                  R                  TR                  5        TR                  5        H#  u  pp4TR                  R                  UUSUUS9  M%     TR                   (       aa   ["        R$                  " TR&                  5      nUTR&                  R,                   S	34nTR                  R                  TR                   US
S9  TR4                  (       aA  TR7                  STR4                  SS9  TR                  R                  STR4                  5        g GN! [(        [*        4 a    Sn Nf = f! [.         a+  nTR1                  U5        TR3                  5          SnAg
SnAff = f7f)zWork required before running the app.

Returns:
    `True` if the app should continue, or `False` if there was a problem starting.
Nz---rt  )r  zWriting logs to T)r  r  tie_breakerr  r  r  F)r  r  g      ?zcss monitorrc  STARTED)r(  r4   r/  r   r  r  r2   LOG_FILEr  r  abspathr  r  r)  _get_default_cssr  r  r  r  r  r  r  r   rV  rW  r  r  set_interval)	_log_pathr  cssr,  r  app_pathr^  r   s          r   app_prelude*App._process_messages.<locals>.app_prelude0  s     %%'''HHOOE"HHOO!9!9!;O<HHOOT]]O3!!-GGOOI,>,>?	"29- @A==OO,,T]];:>:O:O:Q6IKOO.."+'+$/# /  ;R 88&#*??4>>#B "*dnn.E.E-Fd+K LIOO..Ie /  !!$(8(8}!M	4+;+;<I (, &w/ &#%&  &&u---/sa   I)HCI)$A>H1 # H A H1 AI)H.+H1 -H..H1 1
I&;!I!I)!I&&I)c                   >#    SU4S jjn TR                  5            TR                  [        R                  " 5       5      I Sh  vN   TR                  [        R                  R                  TR                  S5      5      I Sh  vN   TR                  nTR                  R                  T5        TR                  [        R                  " 5       5      I Sh  vN   TR                  5         TR                  R                  5         STl        [        R                   " T5        TR                  ULa  TR                  R                  U5        TR"                  R%                  5       I Sh  vN    STl        TR-                  5       I Sh  vN   U " 5       I Sh  vN    SSS5         TR/                  5       I Sh  vN   TR4                  R7                  5         STl         TR"                  R)                  5       I Sh  vN   [8        R:                  " TR<                  5      I Sh  vN   g GN GN GN\! TR                  R                  5         STl        f = f N! [&         a%    TR"                  R)                  5       I Sh  vN    e f = f GN N! STl        TR-                  5       I Sh  vN    U " 5       I Sh  vN    f = f! , (       d  f       GN2= f GN!! [0        R2                   a     GN6f = f N N! [8        R:                  " TR<                  5      I Sh  vN    f = f! TR4                  R7                  5         STl         TR"                  R)                  5       I Sh  vN    [8        R:                  " TR<                  5      I Sh  vN    f ! [8        R:                  " TR<                  5      I Sh  vN    f = f= f7f)z$The main message loop, invoke below.c                 t   >#    Tb.  T" 5       n [         R                  " U 5      (       a  U I S h  vN   g g g  N7fr   )r  isawaitable)ready_resultr  s    r   invoke_ready_callbackRApp._process_messages.<locals>.run_process_messages.<locals>.invoke_ready_callback_  s=     !-#1#3L**<88*** 9 . +s   +868NTFr   )rV  _dispatch_messager3   ComposeResizefrom_dimensionsr  rp  r  applyMountr[  r  ri  _is_mountedry   _initialize_objectr,  startrV  stop_running_ready_process_messages_loopr   r  r,  
cancel_allr   	_stop_all_timers)r;  r  r  r   s     r   run_process_messages3App._process_messages.<locals>.run_process_messages\  s    + ""$20"44V^^5EFFF"44"MM99$))TJ   *.--d3"44V\\^DDD)++//1+/(//5{{.8--n=----/// %)DM++-''/111; %>
811333 '') %8--,,...//$,,777M G
 E ++//1+/( 0  --,,... (1 %)DM++-''/111; %$@ 4))  /7%//$,,777 '') %8--,,...//$,,777%//$,,777s  OK'H9H0A H9H3AH9H6H9/A>I!-I.I!3KJKJK"O+K" >K?K" !O%L K=L #O*K?+O0H93H96H99#II!!'JJ	JJKKK
3J6
4K
K
K

K
KOK" "K:6L/ 9K::L/ =L ?O$L,%L(&L,,O/"ON/M20N5#ONO$O
OO

OOT)r  rU  r  r  )r  r   r   )$r  rm  rG  r3   Loadr=  r"  r  r4   r  start_application_moder   r  r
   r  ry   _clear_watchersrM  r  r   r(   movesegmentr   r   r   r  r$   r  rp  r  r   r8  stop_application_moderV  rW  )r   r  r  rU  r  r  r  rD   r5  rM  
load_eventr  cursor_xcursor_yr  r^  s   ``              r   r  App._process_messages$  sH     	*	X2	8h ]]_$&& _ !DM(.#[[]
,,Z888(,(:(:%!&	 ); )  'zzz1137,T-A-AB!01E1E!F&:&< < < "G C
 !006<<111151O1O.H LL.. 'hY	 B J J O O !LL..0.txx7Q7Q*1)!4$+MM$++2I2I$J !% 2 2$+LLT5H5H4H$I$Q$Q$V$V!" 4465 "! _&
 9 != "G!F CB  (8 !4$+MMO!4 !006<<111151O1O.H LL.. 'hY	 B J J O O !LL..0.txx7Q7Q*1)!4$+MM$++2I2I$J'7 !4$+MMO!4 !% 2 2$+LLT5H5H4H$I$Q$Q$V$V!" 446 .&&u--.W _s  0Q:Q)I< 
Q)
	Q:Q))Q I?AQ K	)J?J
J
JJK	CQ ,%J)A Q 1Q)3	Q:<Q)?Q J
JJ
J&	!K	)KQ KQ 	CP=%N=<P==O	P=O	A#P==Q  
Q&
Q!Q)!Q&&Q))
Q73Q:c                   #    g7f)zNSpecial case for the app, which doesn't need the functionality in MessagePump.Tr   r   s    r   _pre_processApp._pre_process  s     r  c                   ^ #    [        5       T R                  -
  S-  nT R                  R                  SUS S35        S
U 4S jjn[        R
                  S:  a   T R                  [        R
                  USS9  g	g	7f)zrCalled immediately prior to processing messages.

May be used as a hook for any operations that should run first.
r  z	ready in z0.0fz millisecondsc                    >#    T R                  [        R                  [        R                  S9  T R	                  5         g7f)zTake a screenshot and exit.)r  r~  N)r  r2   SCREENSHOT_LOCATIONSCREENSHOT_FILENAMEr  r   s   r   take_screenshot#App._ready.<locals>.take_screenshot  s6       22"66 !  IIKs   >Ar   zscreenshot timerrc  Nr   )r   r~  r4   r/  r2   SCREENSHOT_DELAYre  )r   
ready_timer`  s   `  r   rH  
App._ready  st      #nt'7'774?
)Jt#4MBC	 %%*NN**OBT   +s   A8A;c                   #    SnU R                   U l         / U R                   R                  Q[        U 5      QnU R                  U5      I S h  vN   g ! [         a  n[	        U < SU 35      UeS nAff = f N)7f)NTz. compose() method returned an invalid result; )rp  r  _nodesrZ   r  rY  )r   _rich_traceback_omitrV  r^  s       r   _on_composeApp._on_compose  s     ##{{	;**;WT];G nnW%%%  	(HP	
 	&s3   A:#A A:A8A:
A5A00A55A:c                r   #    U R                   (       a   SU l         U R                  5       I Sh  vN   gg N7f)z!Check if a recompose is required.FN)r  	recomposer   s    r   _check_recomposeApp._check_recompose  s.     ##',D$..""" $"s   ,757c                  #    U R                   (       a  g U R                  R                  5        ISh  vN   U R                  R                  S5      R	                  S5      R                  5       I Sh  vN   U R                  R                  [        U 5      5      I Sh  vN   SSS5      ISh  vN   g N NC N N! , ISh  vN  (       d  f       g= f! [         a     gf = f7f)zbRecompose the widget.

Recomposing will remove children and call `self.compose` again to remount.
Nr  z.-textual-system)	r  rp  batchr  excluder  rY  rZ   r   r   s    r   rk  App.recompose  s     
 ::	{{((**kk'',445GHOOQQQkk++GDM::: +**Q: +***   		s   C(C B6C <B>4B85+B> B:!B>%C 0B<1C 5C(6C 8B>:B><C >CCCC C(C 
C%"C($C%%C(c                   Ub  Ub  [        S5      eX R                  ;  a  Ub  UR                  R                  X25        ODUb&  US:w  a   UR                  R                  US-   U5        OUR                  R	                  U5        U R                  R                  U5        UR                  U5        UR                  U 5        gg)zRegister a widget as a child of another.

Args:
    parent: Parent node.
    child: The child widget to register.
    before: A location to mount before.
    after: A location to mount after.
Nz2Only one of 'before' and 'after' may be specified.r	  r7  )r   r  rf  _insert_appendadd_attach_post_register)r   parentchildrR  rS  s        r   _register_childApp._register_child  s    " %"3OPP &!%%f4"u{ %%eai7
 %%e, NNu%MM&!  &- 'r   )rR  rS  cachec               J   U(       d  / $ Uc  0 nUc  Ub  [        U5      nOUnU R                  R                  n/ nUR                  n	U H  n
SU
l        SU
l        SU
l        [        U
[        5      (       d  [        SU
< S35      eXR                  ;  d  MN  U	" U
5        U R                  XX#5        U
R                  (       d  M{  U R                  " U
/U
R                  Q7SU06  M     U H  n
U" XS9  U
R                  5         M     U R                  (       d  / $ [!        U5      $ )a  Register widget(s) so they may receive events.

Args:
    parent: Parent node.
    *widgets: The widget(s) to register.
    before: A location to mount before.
    after: A location to mount after.
    cache: Optional rules map cache.

Returns:
    List of modified widgets.
FzCan't register z; expected a Widget instancer|  )r|  )r:  r  rA  r  _closing_closed_pruningr  r   r   r  rz  rf  r_  _start_messagesrG  r   )r   rx  rR  rS  r|  rV  widget_listapply_stylesheetnew_widgetsadd_new_widgetr  s              r   r_  App._register%  s   * I=E!2 #7+K!K??00$&$++!F#FO"FN#FOff--
:VWXX^^+v&$$VVC===NN6GFMMGG " "FV1""$ " }}IG}r   c                   UR                  5         [        UR                  [        5      (       a5  UR                  R                  R                  U5        UR                  5         U R                  R                  U5        g)z?Unregister a widget.

Args:
    widget: A Widget to unregister
N)	rS  r  _parentr   rf  _remove_detachr  discardr  s     r   _unregisterApp._unregister`  sR     	fnnf--NN!!))&1NNv&r   c                p   #    U R                   b#  U R                   R                  5       I S h  vN   g g  N7fr   )rt  
disconnectr   s    r   _disconnect_devtoolsApp._disconnect_devtoolsl  s-     ==$--**,,, %,s   +646c                    UR                  U5        UR                  5         U R                  R                  R	                  U5        g)zStart a widget (run its task) so that it can receive messages.

Args:
    parent: The parent of the Widget.
    widget: The Widget to start.
N)rv  r  r   r  ru  )r   rx  r  s      r   _start_widgetApp._start_widgetp  s4     	v v&r   c                    XR                   ;   $ )zhCheck if a widget is mounted.

Args:
    widget: A widget.

Returns:
    True of the widget is mounted.
)r  r  s     r   
is_mountedApp.is_mounted|  s     ''r   c                  #    U R                   R                  5        HQ  n[        U5       H/  nUR                  (       d  M  U R	                  U5      I Sh  vN   M1     UR                  5         MS     U R                  R                  5         U R                  R                  5         [        U R                  5      nU H  nUR                  5       I Sh  vN   M     g N N7f)zClose all message pumps.N)r  r  r:  rG  _pruner  r  r  r   r  _close_messages)r   r  stack_screenremaining_nodesry  s        r   
_close_allApp._close_all  s      ((//1E ((((++l333 !0 KKM	 2
 	%%' t~~.$E''))) % 4 *s*   ;C!C!CA=C!C
C!C!c                  #    U R                  5         U R                  nSU l        Ub  UR                  5         U R	                  5       I S h  vN   U R                  5       I S h  vN   U R                  [        R                  " 5       5      I S h  vN   U R                  b  U R                  R                  5         U R                  R                  5         U R                  b3  U R                  R                  (       a  U R                  5       I S h  vN   U R                  5         [         R"                  (       aF  SSKJn  SSKJn  U" 5       nUR-                  S5        UR-                  U" U R.                  5      5        g g  GN6 GN! N Nx7f)NFr   )r$   )Prettyz[b]The app returned:)rT  r  rG  disable_inputr  r  r=  r3   Unmountcloserf  _clearrt  r  r  r  r2   SHOW_RETURNrich.consoler$   rich.prettyr  r  r  )r   r  r$   r  r  s        r   r  App._shutdown  s      "oo""$$$$$V^^%5666<<#LL ==$)C)C++---%%'  ,*iGMM01MM&!3!345 ! 	 $6 .sJ   A
FFF$F%+FFB FF
A1FFF
Fc                b   #    U R                  5         U R                  R                  S 5        g 7fr   )rT  r  
put_nowaitr   s    r   _on_exit_appApp._on_exit_app  s%     &&t,s   -/)repaintlayoutrk  c                   U(       a#  X0l         U R                  U R                  5        U $ U R                  (       a  U R                  R                  XS9  U R                  5         U $ )zRefresh the entire screen.

Args:
    repaint: Repaint the widget (will call render() again).
    layout: Also layout widgets in the view.
    recompose: Re-compose the widget (will remove and re-mount children).

Returns:
    The `App` instance.
)r  r  )r  r  rl  r;  rp  r_  r[  )r   r  r  rk  s       r   r_  App.refresh  sQ    " '0$NN4001KKK?r   c                "   U R                   R                  nUR                  U R                  5       5        UR	                  5         UR                  U R                   US9   U R                  R                  (       a@  U R                  R                  U R                  5        U R                  U R                  l
        U R                   H4  nX0R                  :w  d  M  UR                  X1S9  U R                  Ul
        M6     g! [         a     NQf = f)z>Refresh CSS.

Args:
    animate: Also execute CSS animations.
r  N)r   r  set_variablesr  r  rx  rp  r  _refresh_layoutr  r  r   r  )r   r~  r  rp  s       r   r  App.refresh_css  s     XX((
  !7!7!9:$((G4	{{%%++DII6040F0F- ''F$!!&!:+/+A+A( (  		s   !AD 
DDc                  ^	^
  Uc   U R                  5         gU R                  (       a   U R                  5         gU R                  (       Ga  U R                  (       Gd  U R                  (       Gd  U R
                  Gb  U R                  nU R                  5           [        U[        5      (       a  U R                  R                  R                  U R                  5      nU R
                  R                  (       aq  [        R                   " U R"                  * 6 R$                  R&                  m
T
UR)                  U5      -  m
T
[        R                   " U6 R$                  R&                  -  m
O;UR)                  U5      m
T
[        R*                  " U6 R$                  R&                  -  m
X@l        O"UR-                  U5      nUR/                  U5      m
[0        (       aI  Sm	U R
                  R2                  nU	U
4S j[5        S[7        T
5      T	5       5        H  nU" U5        M     OU R
                  R3                  T
5         U R=                  5         U R
                  R?                  5         U R                  5         g! [8         a  nU R;                  U5         SnAN[SnAff = f! U R=                  5         f = f! U R                  5         f = f)zjDisplay a renderable within a sync.

Args:
    screen: Screen instance
    renderable: A Rich renderable.
Ni    c              3  2   >#    U  H  nTXT-    v   M     g 7fr   r   )r6  offset
CHUNK_SIZEterminal_sequences     r   r7  App._display.<locals>.<genexpr>#  s&      */"F !2&J;N O/"s   r   ) post_display_hookr  rG  r  r  r  r  _begin_updater  rA   rp  
outer_sizeclamp_offsetr  rM  r(   rR  r  rS  r   render_segmentsmove_tor2  _render_bufferr  r   rangerT  rV  rW  _end_updater   )r   rp  r  r  r  r  r   chunkr^  r  r  s            @@r   _displayApp._display  sS   =	%!v ""$u   r ""$o (((LL,,,""$+'(B%j2BCC.2kk.D.D.Q.Q $ 4 4/O  $||554;LL'+'E'E&E5"")'$$ !2 !2Z5O5OPW5X X 1 1W\\%46"")'$$!/ 1 5?4N4Nw4W 1 1W__%46"")'$$!/ 1 >M:'.~~j'AH070F0Fx0P- #7
 *.J$(LL$6$6E*.3$%s+<'=z/"* !&e* !LL../@A$$&""$ ""$3 % 6..u556( $$&
 ""$sT   J: J: A J: D4I= A0J% *J: =
J"JJ% J""J% %J77J: :Kc                    g)z:Called immediately after a display is done. Used in tests.Nr   r   s    r   r  App.post_display_hook4  s    r   c                8    U R                   R                  X5      $ )zGet the widget under the given coordinates.

Args:
    x: X coordinate.
    y: Y coordinate.

Returns:
    The widget and the widget's screen region.
)rp  get_widget_at)r   xys      r   r  App.get_widget_at7  s     {{((..r   c                z    U R                   (       d*  U R                  b  U R                  R                  S5        ggg)zPlay the console 'bell'.

For terminals that support a bell, this typically makes a notification or error sound.
Some terminals may make no sound or display a visual bell indicator, depending on configuration.
Nrg  )r  r  r   r   s    r   r-  App.bellC  s0     DLL$<LLu% %=r   c                b    U R                   b"  SU S3nU R                   R                  U5        gg)a   Generate escape sequence to set pointer (cursor) shape using Kitty protocol.

Args:
    shape: The pointer shape name (e.g., "default", "pointer", "text", "crosshair", etc.)

Returns:
    The escape sequence to set the pointer shape.

See: https://sw.kovidgoyal.net/kitty/pointer-shapes/
Nz]22;rg  )r  r   )r   shapeshape_sequences      r   _set_pointer_shapeApp._set_pointer_shapeL  s3     <<#'wd3NLL~. $r   c                    U R                   nUc1  U R                  U R                  R                  4X R                  4/nU$ UR                   Vs/ s H  o3UR                  4PM     nnU$ s  snf )zGet a chain of nodes and bindings to consider.

If no widget is focused, returns the bindings from both the screen and the app level bindings.
Otherwise, combines all the bindings from the currently focused node up the DOM to the root App.
)rq  rp  r  ancestors_with_self)r   rq  namespace_bindingsrM  s       r   _binding_chainApp._binding_chain^  s}     ,, ?dkk334~~&" "! 4;3N3N"3N4t~~&3N  " "!	"s   A*c                P    U R                  [        R                  " US5      5        g)zSimulate a key press.

This will perform the same action as if the user had pressed the key.

Args:
    key: Key to simulate. May also be the name of a key, e.g. "space".
N)r  r3   r  r   rQ  s     r   simulate_keyApp.simulate_keyt  s     	&**S$/0r   c                `  #    U(       a  [        U R                  R                  5      OU R                  R                   Hh  u  p4UR                  R                  US5      nU HA  nUR                  U:X  d  M  U R                  UR                  U5      I Sh  vN (       d  M@      g   Mj     g N7f)zHandle a key press.

This method is used internally by the bindings system.

Args:
    key: A key.
    priority: If `True` check from `App` down, otherwise from focused up.

Returns:
    True if the key was handled by a binding, otherwise False
r   NTF)	r:  rp  r  _modal_binding_chainkey_to_bindingsr  r-  
run_actionr  )r   rQ  r-  	namespacebindingskey_bindingsr  s          r   _check_bindingsApp._check_bindings~  s       T[[//0112  I
 $3377R@L'##x/!__W^^YGGG# (2  Hs   A1B.7B.B,B."B.c                    U R                   R                  5        H5  u  pUR                  R                  S;   d  M!  U R	                  SU S3SS9    g   g)z:Bound to ctrl+C to alert the user that it no longer quits.)r)  zapp.quitz	Press [b]z[/b] to quit the appzDo you want to quit?r  N)r  r  r  r  notify)r   rQ  active_bindings      r   action_help_quitApp.action_help_quit  s\     $(#7#7#=#=#?C%%,,0DDu$89AW    $@r   c                l    UR                  5        VVs0 s H  u  p#U[        U5      _M     snn$ s  snnf )z]Normalizes the keys in a keymap, so they use long form, i.e. "question_mark" rather than "?".)r  rq   )r  keymap
binding_idr  s       r   _normalize_keymapApp._normalize_keymap  s;     KQ,,.
JX6FjJ+D11.
 	
 
s   0c                P    U R                  U5      U l        U R                  5         g)a`  Set the keymap, a mapping of binding IDs to key strings.

Bindings in the keymap are used to override default key bindings,
i.e. those defined in `BINDINGS` class variables.

Bindings with IDs that are present in the keymap will have
their key string replaced with the value from the keymap.

Args:
    keymap: A mapping of binding IDs to key strings.
N)r  r  refresh_bindingsr   r  s     r   
set_keymapApp.set_keymap  s"     --f5r   c                l    0 U R                   EU R                  U5      EU l         U R                  5         g)zUpdate the App's keymap, merging with `keymap`.

If a Binding ID exists in both the App's keymap and the `keymap`
argument, the `keymap` argument takes precedence.

Args:
    keymap: A mapping of binding IDs to key strings.
N)r  r  r  r  s     r   update_keymapApp.update_keymap  s1     J$,,I$*@*@*HIr   c                    g)a  Handle a clash between bindings.

Bindings clashes are likely due to users setting conflicting
keys via their keymap.

This method is intended to be overridden by subclasses.

Textual will call this each time a clash is encountered -
which may be on each keypress if a clashing widget is focused
or is in the bindings chain.

Args:
    clashed_bindings: The bindings that are clashing.
    node: The node that has the clashing bindings.
Nr   )r   clashed_bindingsrM  s      r   handle_bindings_clashApp.handle_bindings_clash  s    $ 	r   c                	  >#    [        U[        R                  5      (       a;  U R                  U R                  5      I S h  vN   [
        T
U ]  U5      I S h  vN   g [        U[        R                  5      (       Ga{  UR                  (       Gdi  U R                  (       d6  [        U[        R                  [        R                  45      (       a  SU l	        [        U[        R                  5      (       Ga  [        UR                  UR                  5      U l        UR"                  UR$                  4U l        [        U[        R                  5      (       a/   U R)                  UR                  UR                  5      u  U l        nU R.                  R1                  U5        [        U[        R2                  5      (       Ga#  U R*                  Gb   UR4                  nU R*                  nU R(                  " U6 u  pRXTL a  U R6                  S L=(       a    U R6                  U:H  nU R8                  S L=(       a&    UR:                  U R8                  -
  U R<                  :*  nU(       a  U(       a  U =R>                  S-  sl        OSU l        [        R@                  RC                  XAU R>                  S9nUR:                  U l        X0l        U R.                  R1                  U5        g g g g [        U[        R                  5      (       a  U R.                  RD                  b<  URF                  S:X  a,  U RH                  (       a  U R.                  RK                  5         g U RL                  (       a   U R.                  RO                  5         U RS                  URF                  SS9I S h  vN (       d1  U RL                  =(       d    U R.                  n	U	R1                  U5        g g U R.                  R1                  U5        g [        U[        RT                  5      (       aV  UR                  (       dE  U RL                  b  U RL                  R1                  U5        g U R.                  R1                  U5        g [
        T
U ]  U5      I S h  vN   g  GNE GN1! [,         a    S U l         GNf = f! [,         a     g f = f! [P         a     GN=f = f GN$ NG7f)NTr7  )chainescape)r-  )+r  r3   r>  rd  r  r  on_event
InputEventis_forwardedrB  r  	MouseDown
MouseEventrk   r  r  r  screen_xscreen_yr  r  r  rc   rp  _forward_eventMouseUpscreen_offsetr  r  r.  r(  r  Click
from_eventr  rQ  escape_to_minimizeminimizerq  _clear_tooltipra   r  Paste)r   eventr#  r	  mouse_down_widgetmouse_up_widgetsame_offsetwithin_time_thresholdclick_eventforward_targetr  s             r   r   App.on_event  s     eV^^,,//$"4"4555'"5)))v0011%:L:L:L>>jVEUEU8V&W&W!%%!2!233&,UWWegg&>#7<~~u~~6V3eV%5%5667595G5G!GGUWW62/ **51
 ufnn55//;(-(;(;,0,C,C)-1-?-?-O**? $ = =T I !S$($A$A]$R (
 !% ; ;4 G !C$)JJ1L1L$L#'#B#B%C 2  +/D $ 4 4 9 478 4*0,,*A*A 1@T@T +B +K ;@**D7<I9 KK66{C/ @ < 6D E6::.. KK))5		X-//KK((*<<224 "11%))d1KKK%)\\%@T[[N"11%8 L **51v||,,U5G5G||'++E2**51'"5)))i 6) $ 726/7P $   $ K *s   >S
RS
R	C?S
.R A	S
DR$ "BS
*R4 S
!S"CS
 SS
	S
R!S
 R!!S
$
R1.S
0R11S
4
S>S
SS
S
c                    [        U R                  R                  c  U R                  5      $ U R                  R                  5      $ )a  Use the escape key to minimize?

When a widget is [maximized][textual.screen.Screen.maximize], this boolean determines if the `escape` key will
minimize the widget (potentially overriding any bindings).

The default logic is to use the screen's `ESCAPE_TO_MINIMIZE` classvar if it is set to `True` or `False`.
If the classvar on the screen is *not* set (and left as `None`), then the app's `ESCAPE_TO_MINIMIZE` is used.

)r   rp  r6  r   s    r   r  App.escape_to_minimize6  sE     {{--5 ##
 	
 //
 	
r   c                >   [        U[        5      (       a  Uu  pEnO[        R                  " U5      u  pEnUc  SOUR	                  U5      nU(       a@  Uc=  X@R
                  ;  a  [        SU S35      e[        XS5      nUc  [        SU< S35      eUc  UUU4$ UUU4$ )aC  Parse an action.

Args:
    action: An action string.
    default_namespace: Namespace to user when none is supplied in the action.
    namespaces: Mapping of namespaces.

Raises:
    ActionError: If there are any errors parsing the action string.

Returns:
    A tuple of (node or None, action name, tuple of parameters).
NzAction namespace z is not knownzAction target z not available)r  tupler1   r+  r  r  r   r  )r   r  default_namespace
namespacesdestinationaction_nameparamsaction_targets           r   _parse_actionApp._parse_actionG  s    & fe$$/5,Kf/6}}V/D,Kf &DJNN;,G 	 =0"6"66!$5k]-"PQQ#Dt<M$!N;/"PQQ"/"7
 	
=J
 	
r   c                L    U R                  X5      u  p4nUR                  XE5      $ )zCheck if an action is enabled.

Args:
    action: An action string.
    default_namespace: The default namespace if one is not specified in the action.

Returns:
    State of an action.
)r"  check_action)r   r  r  r!  r  
parameterss         r   _check_action_stateApp._check_action_staten  s/     261C1C2
.J ))+BBr   c                   #    U R                  Xc  U OUU5      u  pEnUR                  XV5      (       a  U R                  XEU5      I Sh  vN $ g N7f)a{  Perform an [action](/guide/actions).

Actions are typically associated with key bindings, where you wouldn't need to call this method manually.

Args:
    action: Action encoded in a string.
    default_namespace: Namespace to use if not provided in the action,
        or None to use app.
    namespaces: Mapping of namespaces.

Returns:
    True if the event has been handled.
NF)r"  r%  _dispatch_action)r   r  r  r  r!  r  r   s          r   r  App.run_action  s[     & .2-?-?5D;Lj.
*F %%k::..}6RRR Ss   AAA	Ac           	       #    Sn[         R                  " SUUUS9   [        USU 3S5      n[        U5      (       a  [	        U/UQ76 I Sh  vN   g[        USU 3S5      n[        U5      (       a  [	        U/UQ76 I Sh  vN   g[         R                  " SU< SU S	U S
35        g N\ N)! [
         a    [         R                  " SU< S35         gf = f7f)zDispatch an action to an action method.

Args:
    namespace: Namespace (object) of action.
    action_name: Name of the action.
    params: Action parameters.

Returns:
    True if handled, otherwise False.
Tz<action>)r  r  r   _action_Naction_z	<action> z0 has no target. Could not find methods '_action_z' or 'action_'z	 skipped.F)r4   r/  r  r	  r?   rO   )r   r  r  r   _rich_traceback_guardprivate_methodpublic_methods          r   r*  App._dispatch_action  s      !%

#		
	=$Y(;-0H$ON''^5f555#I/FMM&&]4V444JJK? +44?=k]Z[]  6 5  	=JJ;/;<		=sd   C/B- B)B- C/B- B+B- C!B- (C)B- +B- -%CCCCc                X  #     [        US5      n [        XR                  5      u  pVUR	                  5         [        U[        5      (       a  U R                  Xc5      I Sh  vN   g[        U[        5      (       aI  [        U5      S:X  a:  Uu  px[        R                  " U5      u  pnU R                  XU4U5      I Sh  vN   g[        U[        5      (       a+  U R                  (       a  [        R                  " SU S35        g! [         a     gf = f! [
         a     gf = f N Nh7f)zAllow the app an opportunity to dispatch events to action system.

Args:
    event_name: _description_
    event: An event object.
    default_namespace: The default namespace, where one isn't supplied.

Returns:
    True if an action was processed.
r&  FN   zCan't parse @z9 action from style meta; check your console markup syntaxT)r  AttributeErrorrG   metarF  rF   r  r   r  r  rT  r1   r+  r  r4   r*  )r   
event_namer  r  r&  
_modifiersr  r  action_paramsr  parsed_actionr#  s               r   _broker_eventApp._broker_event  s    	E7+E	!8ZZ!PJ JJLfc""//&<<<" ! &&3v;!+;)/&K*1--*D'Ia//=9!    &%((TZZ #J</hi 5  		  		 =sd   D*D D 9D*!D&"AD*?D( AD*
DD*DD*
D# D*"D##D*(D*c                ,   #    UR                  5         g 7fr   rF  r   r  s     r   
_on_updateApp._on_update          c                ,   #    UR                  5         g 7fr   r?  r@  s     r   
_on_layoutApp._on_layout  rC  rD  c                   #    U R                  UR                  5      I S h  vN (       d  [        X5      I S h  vN   g g  N N7fr   )r  rQ  rE   r   r  s     r   _on_keyApp._on_key  s3     **599555t+++ 6+s   AA AAAAc                L  #    UR                  5         Xl        U R                  c"  UR                  U l        U R	                  5         g U R                  UR                  :X  a  g UR                  U l        U R
                  c"  U R                  SU R                  5      U l        g g 7f)Ng?)rF  r  r  r  _check_resizer  re  rI  s     r   
_on_resizeApp._on_resize  s     

"::DJ ::#ZZ
%!%9K9K!LD &s   B"B$c                N   #    SU l         U R                  R                  5         g7f)zApp has focus.TNrB  rp  r  rI  s     r   _on_app_focusApp._on_app_focus  s      $$&   #%c                N   #    SU l         U R                  R                  5         g7f)zApp has lost focus.FNrQ  rI  s     r   _on_app_blurApp._on_app_blur  s      $$&rT  )rx  c               F  ^ ^ U(       d  [        / 5      $ 1 UknU H:  nUR                  [        5       5        UR                  UR	                  SS95        M<      US   R
                  nUR                  (       a5  UR                  U;   a%  UR                  UR                  [        U5      5        U H
  nSUl        M     SUU 4S jjn[        U Vs/ s H  oDR                  =nc  M  UPM     snU5      nT R                  U5        U$ ! [        [        4 a     Nkf = fs  snf )zXPrune nodes from DOM.

Args:
    parent: Parent node.

Returns:
    Optional awaitable.
TrG  r   c                    > Tb?   TR                   n U R                  (       a  TR                  U 5        TR                  SS9  gg! [        [        4 a     N#f = f! TR                  SS9  f = f)zCalled after removing children.NTr  )rp  rG  r  r   ra   r_  )rp  rx  r   s    r   
post_mountApp._prune.<locals>.post_mount-  sm     !0#]]F //7NN$N/ " )(3  NN$N/s(   A "A AA AA A,r   )rQ   r  rt   rx  rK  rp  rq  _reset_focusr   r   ra   r  r  r  )	r   rx  nodespruning_nodesrM  rp  r[  taskawait_completes	   ``       r   r  
App._prune  s    r?"%-uXDeg&  !3!3d!3!CD 	I1X__F ~~&..M"A##FNND4GH!D DM "	0 	0 %#Hed

(:TeH
 	~&9 !(+ 		0 Is   D D'DDDc                   U R                   R                  5         U(       au   U R                  b_  U R                  R                   U R                   L a<  U R                   R                  c%  U R                   R	                  U R                  SSS9  SU l        gU R                   R                  U l        U R                   R	                  S5        g! [
         a     NKf = f)z Respond to changes in app focus.NFT)r  from_app_focus)rp  rI  r  rq  r  ra   )r   rR  s     r   _watch_app_focusApp._watch_app_focusB  s    &&(22>66==L++3 KK))66','+ *  .2D* .2[[-@-@D*KK!!$'  s   A,C 
CCc                .   #    U R                  U5        g7f)zAn [action](/guide/actions) to simulate a key press.

This will invoke the same actions as if the user had pressed the key.

Args:
    key: The key to process.
N)r  r  s     r   action_simulate_keyApp.action_simulate_keyb  s      	#   c                ,   #    U R                  5         g7f)z@An [action](/guide/actions) to quit the app as soon as possible.N)r  r   s    r   r  App.action_quitl       		rD  c                ,   #    U R                  5         g7f)z8An [action](/guide/actions) to play the terminal 'bell'.N)r-  r   s    r   action_bellApp.action_bellp  rm  rD  c                   #     U R                  SU 35      R                  5       n[        U[        5      (       a  U R	                  U5        gg! [
         a     gf = f7f)zdAn [action](/guide/actions) to focus the given widget.

Args:
    widget_id: ID of widget to focus.
#N)r  firstr  r   r  r]   )r   	widget_idrM  s      r   action_focusApp.action_focust  sZ     	%::)o.446D $''t$ (  		s'   A"A (A
AAAAc                .   #    U R                  U5        g7f)zVAn [action](/guide/actions) to switch screens.

Args:
    screen: Name of the screen.
N)r  r  s     r   action_switch_screenApp.action_switch_screen  s      	6"rj  c                .   #    U R                  U5        g7f)z|An [action](/guide/actions) to push a new screen on to the stack and make it active.

Args:
    screen: Name of the screen.
N)r  r  s     r   action_push_screenApp.action_push_screen  s      	 rj  c                ,   #    U R                  5         g7f)zaAn [action](/guide/actions) to remove the topmost screen and makes the new topmost screen active.N)r  r   s    r   action_pop_screenApp.action_pop_screen  s     rD  c                .   #    U R                  U5        g7f)z<An [action](/guide/actions) that switches to the given mode.N)ri  )r   r  s     r   action_switch_modeApp.action_switch_mode  s     rj  c                N   #     U R                  5         g! [         a     gf = f7f)zAn [action](/guide/actions) to go back to the previous screen (pop the current screen).

Note:
    If there is no screen to go back to, this is a non-operation (in
    other words it's safe to call even if there are no other screens
    on the stack.)
N)r  r   r   s    r   action_backApp.action_back  s%     	OO 		s   % %
"%"%c                `   #    U R                   R                  U5      R                  U5        g7f)zAn [action](/guide/actions) to add a CSS class to the selected widget.

Args:
    selector: Selects the widget to add the class to.
    class_name: The class to add to the selected widget.
N)rp  r  	add_classr   selector
class_names      r   action_add_classApp.action_add_class  s$      	(#--j9   ,.c                `   #    U R                   R                  U5      R                  U5        g7f)zAn [action](/guide/actions) to remove a CSS class from the selected widget.

Args:
    selector: Selects the widget to remove the class from.
    class_name: The class to remove from  the selected widget.N)rp  r  remove_classr  s      r   action_remove_classApp.action_remove_class  s$      	(#00<r  c                `   #    U R                   R                  U5      R                  U5        g7f)zAn [action](/guide/actions) to toggle a CSS class on the selected widget.

Args:
    selector: Selects the widget to toggle the class on.
    class_name: The class to toggle on the selected widget.
N)rp  r  toggle_classr  s      r   action_toggle_classApp.action_toggle_class  s$      	(#00<r  c                B    U R                   S:X  a  SU l         gSU l         g)zAn [action](/guide/actions) to toggle the theme between textual-light
and textual-dark. This is offered as a convenience to simplify backwards
compatibility with previous versions of Textual which only had light mode
and dark mode.ztextual-lightr  N)r[  r   s    r   action_toggle_darkApp.action_toggle_dark  s#     #jjO;N 	
AP 	
r   c                8    U R                   R                  5         g)z5An [action](/guide/actions) to focus the next widget.N)rp  
focus_nextr   s    r   action_focus_nextApp.action_focus_next  s     r   c                8    U R                   R                  5         g)z9An [action](/guide/actions) to focus the previous widget.N)rp  focus_previousr   s    r   action_focus_previousApp.action_focus_previous  s    ""$r   c                V    U R                   R                  S5      R                  5         g)z!Hide the keys panel (if present).r  N)rp  r  r  r   s    r   r  App.action_hide_help_panel  s    +&--/r   c                    SSK Jn   U R                  R                  U5        g! [         a#    U R                  R                  U" 5       5         gf = f)zShow the keys panel.r   )r  N)rb  r  rp  	query_oner]   rU  )r   r  s     r   r  App.action_show_help_panel  s?    -	+KK!!), 	+KKik*	+s   $ *AAinformationc                $    U R                  XUS9  g)zShow a notification.r   severityN)r  )r   r  r   r  s       r   action_notifyApp.action_notify  s     	G8<r   c                    [         R                  " S5        U R                  b$  U R                  R                  (       d  SU l        g g g )Nz$SynchronizedOutput mode is supportedT)r4   r/  r  rM  r  r@  s     r   )_on_terminal_supports_synchronized_output-App._on_terminal_supports_synchronized_output  s8     	

9:<<#DLL,B,B#'D  -C#r   c                    U R                   (       a.  U R                  b   U R                  R                  [        5        g g g r   )r  r  r   r<   r   s    r   r  App._begin_update  s.    DLL$<LLz* %=r   c                    U R                   (       a.  U R                  b   U R                  R                  [        5        g g g r   )r  r  r   r;   r   s    r   r  App._end_update  s.    DLL$<LLx( %=r   c                     U R                   n UR                  [        5      nU R	                  UR
                  U R                  5        g! [         a     gf = f! [         a     gf = f)zERefresh the notifications on the current screen, if one is available.N)rp  rD  r   r]   r  r,  r  r   )r   rp  
toast_racks      r   _refresh_notificationsApp._refresh_notifications  si    	B[[F#55i@
 OOJOOT-@-@A      		s"   A A 
AA
A('A(c                Z     U R                   R                  5         g! [         a     gf = f)z*Clear text selection on the active screen.N)rp  clear_selectionra   r   s    r   r  App.clear_selection  s)    	KK'') 		s    
**)r   r  timeoutrh  c               l    Uc  U R                   n[        XX4US9nU R                  [        U5      5        g)ap  Create a notification.

!!! tip

    This method is thread-safe.


Args:
    message: The message for the notification.
    title: The title for the notification.
    severity: The severity of the notification.
    timeout: The timeout (in seconds) for the notification, or `None` for default.
    markup: Render the message as content markup?

The `notify` method is used to create an application-wide
notification, shown in a [`Toast`][textual.widgets._toast.Toast],
normally originating in the bottom right corner of the display.

Notifications can have the following severity levels:

- `information`
- `warning`
- `error`

The default is `information`.

Example:
    ```python
    # Show an information notification.
    self.notify("It's an older code, sir, but it checks out.")

    # Show a warning. Note that Textual's notification system allows
    # for the use of Rich console markup.
    self.notify(
        "Now witness the firepower of this fully "
        "[b]ARMED[/b] and [i][b]OPERATIONAL[/b][/i] battle station!",
        title="Possible trap detected",
        severity="warning",
    )

    # Show an error. Set a longer timeout so it's noticed.
    self.notify("It's a trap!", severity="error", timeout=10)

    # Show an information notification, but without any sort of title.
    self.notify("It's against my programming to impersonate a deity.", title="")
    ```
Nr  )r"  ru   r  rw   )r   r  r   r  r  rh  notifications          r   r  
App.notify  s6    p ?//G#GHfU&./r   c                n    U R                   R                  UR                  5        U R                  5         g)zHandle notification message.N)r  ru  r  r  rI  s     r   
_on_notifyApp._on_notifyJ  s(     2 23##%r   c                N    U R                   U	 U(       a  U R                  5         gg)zRemove a notification from the notification collection.

Args:
    notification: The notification to remove.
    refresh: Flag to say if the display of notifications should be refreshed.
N)r  r  )r   r  r_  s      r   	_unnotifyApp._unnotifyO  s&     -'') r   c                X    U R                   R                  5         U R                  5         g)z$Clear all the current notifications.N)r  r  r  r   s    r   clear_notificationsApp.clear_notificationsZ  s     !!###%r   c                    U R                   (       a5  [        R                  " U 5      (       d  U R                  [        SS95        ggg)z!Show the Textual command palette.z--command-paletter  N)r  rW   is_openr  r   s    r   action_command_paletteApp.action_command_palette_  s8    ##N,B,B4,H,H^/BCD -I#r   c                :    U R                   R                  U 5        g)z/Signal that the application is being suspended.N)r  r  r   s    r   _suspend_signalApp._suspend_signald  s    ''-r   c                :    U R                   R                  U 5        g)z?Signal that the application is being resumed from a suspension.N)r  r  r   s    r   _resume_signalApp._resume_signalh  s     	&&t,r   c              #  v  #    U R                   c  gU R                   R                  (       a  U R                  5         U R                   R                  5         U R                   R	                  5          [        [        R                  5         [        [        R                  5         Sv   SSS5        SSS5        SSS5        U R                   R                  5         U R                  5         U R                  SS9  g[        S5      e! , (       d  f       Nc= f! , (       d  f       Nl= f! , (       d  f       Nu= f7f)a  A context manager that temporarily suspends the app.

While inside the `with` block, the app will stop reading input and
emitting output. Other applications will have full control of the
terminal, configured as it was before the app started running. When
the `with` block ends, the application will start reading input and
emitting output again.

Example:
    ```python
    with self.suspend():
        os.system("emacs -nw")
    ```

Raises:
    SuspendNotSupported: If the environment doesn't support suspending.

!!! note
    Suspending the application is currently only supported on
    Unix-like operating systems and Microsoft Windows. Suspending is
    not supported in Textual Web.
NTrZ  z1App.suspend is not supported in this environment.)r  can_suspendr  suspend_application_modeno_automatic_restartr   r  r  r
   r  resume_application_moder  r_  r   r   s    r   suspendApp.suspendm  s     0 <<<<##  "LL113 113// 0 0 4 LL002!LLL%%C  0/ 0/ 43sO   A.D90D(
D$D)D1D(9AD9
DD
D%	!D((
D62D9c                    [         (       ds  U R                  be  U R                  R                  (       aI  U R                  5         [        R
                  " [        R                  " 5       [        R                  5        gggg)zSuspend the process into the background.

Note:
    On Unix and Unix-like systems a `SIGTSTP` is sent to the
    application's process. Currently on Windows and when running
    under Textual Web this is a non-operation.
N)	r  r  r  r  r  killgetpidsignalSIGTSTPr   s    r   action_suspend_processApp.action_suspend_process  sO     w4<<38P8P   "GGBIIK0 9Q3wr   )new_tabc               V    U R                   b  U R                   R                  X5        gg)z{Open a URL in the default web browser.

Args:
    url: The URL to open.
    new_tab: Whether to open the URL in a new tab.
N)r  open_url)r   r'  r  s      r   r  App.open_url  s%     <<#LL!!#/ $r   downloadr  r  r  r  r  rd  c          
        [        U[        [        45      (       a2  [        U5      nUR                  S5      n	U=(       d    UR                  n
O7U=(       d    [        USS5      =(       d    SnUn	U=(       d    [        USS5      n
U
(       a  U(       d  [        R                  " U
5      u  pkUc  SnU R                  U	UU
UUUUS9$ )a  Deliver a text file to the end-user of the application.

If a TextIO object is supplied, it will be closed by this method
and *must not be used* after this method is called.

If running in a terminal, this will save the file to the user's
downloads directory.

If running via a web browser, this will initiate a download via
a single-use URL.

After the file has been delivered, a `DeliveryComplete` message will be posted
to this `App`, which contains the `delivery_key` returned by this method. By
handling this message, you can add custom logic to your application that fires
only after the file has been delivered.

Args:
    path_or_file: The path or file-like object to save.
    save_directory: The directory to save the file to.
    save_filename: The filename to save the file to.  If `path_or_file`
        is a file-like object, the filename will be generated from
        the `name` attribute if available. If `path_or_file` is a path
        the filename will be generated from the path.
    encoding: The encoding to use when saving the file. If `None`,
        the encoding will be determined by supplied file-like object
        (if possible). If this is not possible, 'utf-8' will be used.
    mime_type: The MIME type of the file or None to guess based on file extension.
        If no MIME type is supplied and we cannot guess the MIME type, from the
        file extension, the MIME type will be set to "text/plain".
    name: A user-defined named which will be returned in [`DeliveryComplete`][textual.events.DeliveryComplete]
        and [`DeliveryComplete`][textual.events.DeliveryComplete].

Returns:
    The delivery key that uniquely identifies the file delivery.
rbr  Nrf  rd  z
text/plainr  	r  r   r   r  rd  r  	mimetypes
guess_type_deliver_binary)r   path_or_filer  r  r  r  r  rd  binary_pathbinary	file_namer#  s               r   r  App.deliver_text  s    ^ lS$K00|,K %%d+F%9)9)9IU7<T#JUgH!F%Lvt)LI Y$//	:LI $I##)## $ 
 	
r   r  c          
     L   [        U[        [        45      (       a2  [        U5      nUR                  S5      nU=(       d    UR                  n	OUnU=(       d    [        USS5      n	U	(       a  U(       d  [        R                  " U	5      u  pZUc  SnU R                  UUU	UUSUS9$ )a  Deliver a binary file to the end-user of the application.

If an IO object is supplied, it will be closed by this method
and *must not be used* after it is supplied to this method.

If running in a terminal, this will save the file to the user's
downloads directory.

If running via a web browser, this will initiate a download via
a single-use URL.

This operation runs in a thread when running on web, so this method
returning does not indicate that the file has been delivered.

After the file has been delivered, a `DeliveryComplete` message will be posted
to this `App`, which contains the `delivery_key` returned by this method. By
handling this message, you can add custom logic to your application that fires
only after the file has been delivered.

Args:
    path_or_file: The path or file-like object to save.
    save_directory: The directory to save the file to. If None,
        the default "downloads" directory will be used. This
        argument is ignored when running via the web.
    save_filename: The filename to save the file to. If None, the following logic
        applies to generate the filename:
        - If `path_or_file` is a file-like object, the filename will be taken from
          the `name` attribute if available.
        - If `path_or_file` is a path, the filename will be taken from the path.
        - If a filename is not available, a filename will be generated using the
          App's title and the current date and time.
    open_method: The method to use to open the file. "browser" will open the file in the
        web browser, "download" will initiate a download. Note that this can sometimes
        be impacted by the browser's settings.
    mime_type: The MIME type of the file or None to guess based on file extension.
        If no MIME type is supplied and we cannot guess the MIME type, from the
        file extension, the MIME type will be set to "application/octet-stream".
    name: A user-defined named which will be returned in [`DeliveryComplete`][textual.events.DeliveryComplete]
        and [`DeliveryComplete`][textual.events.DeliveryComplete].

Returns:
    The delivery key that uniquely identifies the file delivery.
r  rd  Nzapplication/octet-stream)r  r  r  r  r  rd  r  )r   r  r  r  r  r  rd  r  r  r  r#  s              r   deliver_binaryApp.deliver_binary
  s    l lS$K00|,K %%d+F%9)9)9I!F%Lvt)LI Y$//	:LI 2I##)## $ 
 	
r   )r  r  rd  c          
        U R                   c  gUc  [        U R                  S5      nUc
  [        5       O
[	        U5      n[        [        R                  " 5       R                  5      nU R                   R                  UUX#-  UUUUS9  U$ )z9Deliver a binary file to the end-user of the application.Nr  )delivery_key	save_pathr  r  r  rd  )
r  rH   r   r#   r   r   uuiduuid4hexr  )	r   r  r  r  r  r  r  rd  r  s	            r   r  App._deliver_binaryZ  s     <<  6tzz2FM &4%;!nAU 	
 4::<++,
 	##%$4# 	$ 	
 r   c                    UR                   S:X  aF  UR                  c  U R                  SSS9  gU R                  S[        UR                  5      < 3SS9  gg)z+Handle a successfully delivered screenshot.r  NzSaved screenshotr  r  z#Saved screenshot to [$text-success])rd  r  r  r   rI  s     r   _on_delivery_completeApp._on_delivery_complete  sW     ::%zz!.lC9#ejj/9LM&  	 &r   c                H    UR                   S:X  a  U R                  SSSS9  gg)z+Handle a failure to deliver the screenshot.r  zFailed to save screenshotr  r^  r  N)rd  r  rI  s     r   _on_delivery_failedApp._on_delivery_failed  s-     ::%KK+<'   &r   c                \    UR                   U l        U R                  R                  U5        g)z/In band window resize enables smooth scrolling.N)rb  r  r4   r  r@  s     r   _on_in_band_window_resizeApp._on_in_band_window_resize  s      *1&wr   c                \    U R                   b  U R                  c  U R                  5         g g g r   )r  r  rM  r   s    r   _on_idleApp._on_idle  s.    )d.@.@.H  /I)r   c                F   U R                   nU R                  b!  U R                  R                  5         SU l        UbT   U R                    SU l         U R                  R                  U5        U R                   H  nUR                  U5        M     gg! [         a     gf = f)zESend a resize event to screen(s) (invoked from `self._resize_timer`).N)r  r  rF  rp  r   r  r8  )r   r  rp  s      r   rM  App._check_resize  s    "")##%!%D "&DKK$$U+22##E* 3   s   B 
B B )Vr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rC  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rG  r  r  r  r~  r  r  r  r  r  rB  r  r  r  r  r  r  rt  r  r  r  r  r  r  r  r  r  rQ  r  r  r  r  rZ  r  r[  r  r  r   r  )NNFN)r  zType[Driver] | Noner  zCSSPathType | Noner  r   r]  bool | None)r   zSequence[LineFilter]r   )r   zasyncio.Eventr   )r   r`   )r   r   r   r   )rZ  r   r   r   )r   r|   )r   r   r  )r   
int | None)r   zSequence['Widget'])r   r   )r   r   rZ  r   r   r[   )r   zGenerator[None, None, None])g?)rf  r3  r   r   )r]  r  r   r   )r|  r   r}  zfloat | Animatableru  objectrv  r1  rw  r1  rf  r3  rx  zEasingFunction | strry  CallbackType | Nonerz  rL   r   r   )T)r|  r   r  r   r   r   )r   zlist[Screen[Any]])r   r&   r   )r  r  r   list[Screen])Nr   N)r  r  r2  r  r  RenderableType | Noner   r   )r   Widget | None)r   zdict[str, ActiveBinding])rp  r|   r   zIterable[SystemCommand])r   ComposeResult)r   zdict[str, str])r  r   r   zTheme | None)r[  r   r   r   )r  r   r   r   )r   zdict[str, Theme])r   r   )r  r   r   r   )r[  r-   r   r   )r   r-   )r   zType[Driver])r   zrich.repr.Result)r   r9   )r   zScreen[object])r   r  )r   rm   r  )r   r.   )
rX  r/   rY  r0   rZ  zinspect.Tracebackr[  r   r   r   )r   r   r   )r   zECallable[..., CallThreadReturnType | Awaitable[CallThreadReturnType]]r  r   r  r   r   r   )NN)r~  r  r  r  r   r   )r   r  r  r   r   r   )NNN)r~  r  r  r  r  r  r   r   )r~  r  r  r  r  r  r   r  )u   Search for commands…)r  zSequence[CommandListItem]r  r   r   r   )r  r   r  r   r  r   r,  r   r}  r  r   r   )r  rR   r   r   )r  zIterable[str]r   r   r  )r   r   r   r   )r   r   r   r   r   r   )TT)r  r   r  r   r   r   r   r   )r  r   r   r   )r  r   r  tuple[int, int] | Noner  r   r  r   rD    Callable[[Message], None] | Noner   z'AsyncGenerator[Pilot[ReturnType], None])r  r   rU  r   r  r   r  r   r  r  r   AutopilotCallbackType | Noner   r  )r  r   rU  r   r  r   r  r   r  r  r   r  ru  zAbstractEventLoop | Noner   r  )r   r   )r  r   r   r   )r  r   r;  type[ExpectType]r   r4  )r  r   r;  ztype[ExpectType] | Noner   zExpectType | Widget)r;  r  r   r4  )rM  r`   r~  r   r   r   )rV  r   rR  int | str | Widget | NonerS  r  r   r   )rV  zIterable[Widget]rR  r  rS  r  r   r   )r  r   r   r   )r  r   rm  zstr | Callable[[], Screen]r   r   )r  r   r   rP   )rp  Screen | strr   r   )rp  r   r   r   )rp  r   r   r|   )rp  r   r  Type[ScreenType] | Noner   r   )rp  r   r  r  r   r   )rp  r  r  zType[Screen] | Noner   r|   )rp  r  r   ztuple[Screen, AwaitMount])rp  r|   )rp  r|   r   r|   )NF)
rp  Screen[ScreenResultType] | strr   1ScreenResultCallbackType[ScreenResultType] | Noner  zLiteral[False]r  r  r   r   r   )
rp  r  r   r  r  zLiteral[True]r  r  r   z asyncio.Future[ScreenResultType])
rp  r  r   r  r  r   r  r  r   z-AwaitMount | asyncio.Future[ScreenResultType])rp  zScreen[ScreenResultType]r  r  r   r~   )rp  r   r  r  r   r   )rp  r  r  r  r   zScreenResultType | Any)rp  r  r   rP   )rp  r|   rd  r   r   r   )rp  r  r   r  )r   rP   )rp  r|   r   r   )r  r  r  r   r   r   )r  r  r  r  r   r   )r  r  r   r   )r  r'   r   r   )r^  rV  r   r   )
r  r   rU  r   r  r   r  r  r   rb   )NFFFTNN)r  r  r  r   rU  r   r  r   r  r   r  r  rD   r  r   r   )
rx  r`   ry  r   rR  r	  rS  r	  r   r   )rx  r`   rV  r   rR  r	  rS  r	  r|  zdict[tuple, RulesMap] | Noner   zlist[Widget])r  r   r   r   )rx  r   r  r   r   r   )r  r   r   r   )r  r   r  r   rk  r   r   r   )r~  r   r   r   )rp  r|   r  r  r   r   )r  r  r  r  r   ztuple[Widget, Region])r  r   r   r   )r   z!list[tuple[DOMNode, BindingsMap]])rQ  r   r   r   )rQ  r   r-  r   r   r   )r  rU   r   rU   )r  rU   r   r   )r  zset[Binding]rM  r`   r   r   )r  events.Eventr   r   )r  str | ActionParseResultr  r`   r  Mapping[str, DOMNode] | Noner   z'tuple[DOMNode, str, tuple[object, ...]])r  r   r  r`   r   r  )r  r  r  DOMNode | Noner  r  r   r   )r  r`   r  r   r   r   r   r   )r8  r   r  r  r  r`   r   r   )r  zmessages.Updater   r   )r  zmessages.Layoutr   r   )r  z
events.Keyr   r   )r  zevents.Resizer   r   )r  zevents.AppFocusr   r   )r  zevents.AppBlurr   r   )r^  r   rx  r  r   rQ   )rR  r   r   r   )rt  r   r   r   )rp  r   r   r   )r  r   r   r   )r  r   r  r   r   r   )r  r  )r  r   r   r   r  r   r   r   )r  z+messages.TerminalSupportsSynchronizedOutputr   r   )r  r   r   r   r  rx   r  r1  rh  r   r   r   )r  rw   r   r   )r  ru   r_  r   r   r   )r   zIterator[None])r'  r   r  r   r   r   )r  zstr | Path | TextIOr  str | Path | Noner  r  r  Literal['browser', 'download']r  r  r  r  rd  r  r   r  )r  zstr | Path | BinaryIOr  r  r  r  r  r  r  r  rd  r  r   r  )r  zBinaryIO | TextIOr  r  r  r  r  r  r  r  r  r  rd  r  r   r  )r  zevents.DeliveryCompleter   r   )r  zmessages.InBandWindowResizer   r   (  r   r   r   r   r   r  r   r  r  r  r  r  r  r  r  r  r  r   r"  r   r#  r$  r%  r'  r(  rR   r0  r2  r4  r5  r6  r8  r9  r:  r;  r<  r=  r>  r?  rX  ry   r   rZ  rB  r2   DEFAULT_THEMEr[  r>   r  r=   r  r]  r   r  propertyr  r@   r  r  r  r   r$  r'  r  r,  r/  r2  r=  r@  rF  rJ  rQ  r	   rV  rT  rU  rb  rm  rq  r7   r~  r  r  r  r  r  rM  r  r  r;  r  r  r  r  rq  r  r  r  rZ   r  r  rp  r  r  r  rI  r  r  r  r  r  r  rO  r  r  r)  r,  rp  r8  r  r=  rA  r4   r  rc  rm  rx  r  r  r  r  r  r  r{  r  r  r  r  r   r  r  r   r  r  r  r  r2  r   r   r4  r   r    r7  r?  rD  rO  rU  rY  rd  ri  rn  rv  ry  r|  r\  r]  rr  r  r  r  r  r  r  r  r  r  r  r  r  rW  r  r  r"  r(  r  rZ  rH  rh  rl  rk  rz  r_  r  r  r  r  r  r  r  r_  r  r  r  r  r-  r  r  r  r  r  classmethodr  r  r  r  r   r  r"  r'  r  r*  r<  rA  rF  rJ  rN  rR  rV  r  re  rh  r  ro  ru  rx  r{  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r6   rb   SignalResumer  r  r  r  r  r  r  r3   DeliveryCompleter  DeliveryFailedr  r5   InBandWindowResizer  r  rM  r   __classcell__)r  s   @r   r  r  '  s   2CI 6Kp >@E:?8 #-L-,#>@G;@F'*J$* $(L.'
 "J
!-1H*1&E: !Iz  .2N1f,-/-O 	%NHJ 
 .6]5 L4818`-5]5o255. 	D	
 	+E$?
-H) 
 $"%M<%JM5C&**/)--
 %&NM%4,.M.LEGBG< DF@E */. D04~4f./m/V04o4B +-27+1+HOD  $B6E=68'E:I}:\u-I $I$;$;<E=<1wU3Od	6e(0J%6" -1'+"&@2)@2 %@2 	@2
  @2 @2D
F H H  : :$	0# U U   " " ! !   *  ,!*  > >& . .0 "!%"'5+/ &&
&
 "&

 &
 &
 &
 &
 %&
 )&
 &
 
&
P
G 
G     ; ; K K I I F F > > 	7 	7 " " 
 
$ , %))-	3!3 3 '	3
 
3(   + +<
|%&"( 44 + +  A($-- 
 
  #J	8   D D  " " # #   U  5*5*  5* !2	5*
 5* 
5*n
"9$2W2 2 	2
 
2h
 ?C	0"	01;	0		0 !	 =  = 	 =
 
 =H  $"&	   	
 
>  $"&	"
"
 "
  	"

 
"
N 4
+
 
 
	
*

" "&

 

 
 
  
 

4$<'8. .G G6 JN;#;-1;BF;	;"(  '/#9=U* U* %	U*
 U* U* 7U* 
1U* U*t  %'+37V  V  	V 
 V  V  %V  1V  
V v  %'+37)-62 62 	62
 62 62 %62 162 '62 
62p,3\- V4J	9 
9			(8		 
	
 ?C

$;
	
. 	: 
:			(8		 
	
 ?C

$;
	
6:G G0 -1+/	GG *G )	G
 
GB -1+/@!@ *	@
 )@ 
@<,\-^(,?@> ? ?4 4CG)@	  JN 0G	 
 IM"""2E"	"H*2)<* 	 KO/4		  $	2	 H	 -		 	 	 
	 
 KO.2		3  $	32	3 H	3 ,		3 	3 .	3 
	3 GK!&	H  H.H DH 	H H 
7HT 	JN	#2	#=G	#	# 
	# 
59		(2		 
	
 MQ
4
?I
	
(!:F=4 D76)66 6"'#"'3@"'	"'H-6+$'. ,''(!!&*!37!?U!	!F	Y /3 %049=X.+X. X. 	X.
 X. X. .X. 7X. 
X.t,
&#+'+'&,+'6@+'IS+'	+'b " .299 9 	9
 9 ,9 
9v
'-
'	(*$6:-   	
  
6B B0E%NI
/&/$ " "*1 0 
 
    ,4;	(X* X*t 
 
( 48	%
'%
 #%
 1	%

 
1%
NCC.5C	C( -137	' * 1	
 
6' '/2'<?'	'R**&2*GN*	*X,M'' ?C . .`(@%#!:==
!%0+ >K==#&=7:=	=(B(	(+)B$ "/ $;0;0 	;0
  ;0 ;0 ;0 
;0z&
	* 	*&
E
. - - 2 2h1( 59 0 0 -1$(6@# $H
)H
 *	H

 "H
 4H
 H
 H
 H
 
H
 H
\ -1$(6@ $N
+N
 *	N

 "N
 4N
 N
 N
 
N
 N
n  $ $(!( *	(
 "( 4( ( ( ( 
( (T  	 !	   ##$  % 
!+ + +r   r  )r   ztype[SystemCommandsProvider](  r   
__future__r   r   r  r  r  r  r  r  r  r  r  warningsr   r   r   concurrent.futuresr   
contextlibr   r	   r
   r   	functoolsr   pathlibr   r.  r   typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    weakrefr!   r"   r  	rich.reprplatformdirsr#   r  r$   r%   r&   r'   rich.controlr(   rich.protocolr*   rich.segmentr+   r,   rich.terminal_themer-   textualr.   r/   r0   r1   r2   r3   r4   r5   r6   textual._animatorr7   r8   r9   r:   textual._ansi_sequencesr;   r<   textual._ansi_themer=   r>   textual._callbackr?   textual._compatr@   textual._compositorrA   textual._contextrB   rC   rD   r  textual._dispatch_keyrE   textual._event_brokerrF   rG   textual._filesrH   textual._pathrI   rJ   rK   textual._typesrL   textual._waitrM   textual.actionsrN   rO   textual.await_completerP   textual.await_removerQ   textual.bindingrR   rS   rT   rU   textual.commandrV   rW   rX   rY   textual.composerZ   textual.contentr[   textual.css.errorsr\   textual.css.queryr]   textual.css.stylesheetr^   r_   textual.domr`   ra   textual.driverrb   textual.errorsrc   textual.featuresrd   re   textual.file_monitorrf   textual.filterrg   rh   ri   rj   textual.geometryrk   rl   rm   textual.keysrn   ro   rp   rq   rr   textual.messagesrs   rt   textual.notificationsru   rv   rw   rx   textual.reactivery   textual.renderables.blankrz   textual.screenr{   r|   r}   r~   r   textual.signalr   textual.themer   r   r   textual.timerr   textual.visualr   r   textual.widgetr   r   textual.widgets._toastr   textual.workerr   r   textual.worker_managerr   r  r   typing_extensionsr   r   r   r   r   r   r   textual.messager   r  r   r   r   r   platformr  r  simplefilterResourceWarningversion_infor  r  r   r   r   r   r   r   r   rV  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r
  autor  r   r   r   <module>ri     s   #    	  	  
    8 8 %        ( /   , S S   ' * -
 
 
 S R 8 2 $ + 0 < E . D 5 
 * ' 9 0 , E E U U # # . ' 7 ) ! # 8 , J J 1 1  1 T T % +  " > >  1 - , = 01EE, ,)'#>)
,,'
! ???(O4 ),(8(8J(F % Di D  ; y  FO O b\0
 P
<J 
<"9y 99) 9<) <I{ I6	 68y 8By BFi F) /	 / \"
56 
 
   F HJ+'*
w HJ+ HJ+r   