
    AHj                    B    d Z ddlmZ ddlmZmZmZmZ  G d de      Zy)aA  

This module contains `SystemCommands`, a command palette command provider for Textual system commands.

This is a simple command provider that makes the most obvious application
actions available via the [command palette][textual.command.CommandPalette].

!!! note

    The App base class installs this automatically.

    )annotations)DiscoveryHitHitHitsProviderc                       e Zd ZdZddZddZy)SystemCommandsProviderzA [source][textual.command.Provider] of command palette commands that run app-wide tasks.

    Used by default in [`App.COMMANDS`][textual.app.App.COMMANDS].
    c                  K   t        | j                  j                  | j                        d       }|D ]  \  }}}}|st	        |||        yw)zHandle a request for the discovery commands for this provider.

        Yields:
            Commands that can be discovered.
        c                    | d   S )Nr    )commands    O/root/tools/cai/cai_env/lib/python3.12/site-packages/textual/system_commands.py<lambda>z1SystemCommandsProvider.discover.<locals>.<lambda>    s    7ST:     )keyhelpN)sortedappget_system_commandsscreenr   )selfcommandsname	help_textcallbackdiscovers         r   r   zSystemCommandsProvider.discover   s^      HH((5;U
 4< 	/D)Xx"" 	s   >AAc                  K   | j                  |      }| j                  j                  | j                        D ]>  ^}}}}|j	                  |      x}dkD  st        ||j                  |      ||       @ yw)zHandle a request to search for system commands that match the query.

        Args:
            query: The user input to be matched.

        Yields:
            Command hits for use in the command palette.
        r   r   N)matcherr   r   r   matchr   	highlight)r   queryr   r   r   r   _r    s           r   searchzSystemCommandsProvider.search*   s}      ,,u% .2XX-I-I$++-V 	)D)X t,,1%%d+"	 	s   AA;$A;N)returnr   )r"   strr%   r   )__name__
__module____qualname____doc__r   r$   r   r   r   r	   r	      s    
"r   r	   N)	r*   
__future__r   textual.commandr   r   r   r   r	   r   r   r   <module>r-      s!    # = =-X -r   