13
13
14
14
from __future__ import annotations
15
15
16
- from typing import TYPE_CHECKING
17
-
18
16
from .command import DiscoveryHit , Hit , Hits , Provider
19
17
20
- if TYPE_CHECKING :
21
- from .app import SystemCommandsResult
22
-
23
18
24
19
class SystemCommandsProvider (Provider ):
25
20
"""A [source][textual.command.Provider] of command palette commands that run app-wide tasks.
26
21
27
22
Used by default in [`App.COMMANDS`][textual.app.App.COMMANDS].
28
23
"""
29
24
30
- @property
31
- def _system_commands (self ) -> SystemCommandsResult :
32
- """The system commands to reveal to the command palette."""
33
- yield from self .app .get_system_commands (self .screen )
34
-
35
25
async def discover (self ) -> Hits :
36
26
"""Handle a request for the discovery commands for this provider.
37
27
38
28
Yields:
39
29
Commands that can be discovered.
40
30
"""
41
- commands = sorted (self ._system_commands , key = lambda command : command [0 ])
31
+ commands = sorted (
32
+ self .app .get_system_commands (self .screen ), key = lambda command : command [0 ]
33
+ )
42
34
for name , help_text , callback , discover in commands :
43
35
if discover :
44
36
yield DiscoveryHit (
@@ -62,7 +54,7 @@ async def search(self, query: str) -> Hits:
62
54
63
55
# Loop over all applicable commands, find those that match and offer
64
56
# them up to the command palette.
65
- for name , help_text , callback , * _ in self ._system_commands :
57
+ for name , help_text , callback , * _ in self .app . get_system_commands ( self . screen ) :
66
58
if (match := matcher .match (name )) > 0 :
67
59
yield Hit (
68
60
match ,
0 commit comments