mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 11:11:47 +02:00
Raise an exception when not in broadcast and no match for send-text
send-text still won't return an error code when there is no match, since no_response is True by default.
This commit is contained in:
@@ -85,6 +85,11 @@ type=bool-set
|
|||||||
Match all windows.
|
Match all windows.
|
||||||
|
|
||||||
|
|
||||||
|
--exclude-active
|
||||||
|
type=bool-set
|
||||||
|
Do not send text to the active window, even if it is one of the matched windows.
|
||||||
|
|
||||||
|
|
||||||
--stdin
|
--stdin
|
||||||
type=bool-set
|
type=bool-set
|
||||||
Read the text to be sent from :italic:`stdin`. Note that in this case the text is sent as is,
|
Read the text to be sent from :italic:`stdin`. Note that in this case the text is sent as is,
|
||||||
@@ -94,11 +99,6 @@ not interpreted for escapes. If stdin is a terminal, you can press :kbd:`Ctrl-D`
|
|||||||
--from-file
|
--from-file
|
||||||
Path to a file whose contents you wish to send. Note that in this case the file contents
|
Path to a file whose contents you wish to send. Note that in this case the file contents
|
||||||
are sent as is, not interpreted for escapes.
|
are sent as is, not interpreted for escapes.
|
||||||
|
|
||||||
|
|
||||||
--exclude-active
|
|
||||||
type=bool-set
|
|
||||||
Do not send text to the active window, even if it is one of the matched windows.
|
|
||||||
'''
|
'''
|
||||||
no_response = True
|
no_response = True
|
||||||
argspec = '[TEXT TO SEND]'
|
argspec = '[TEXT TO SEND]'
|
||||||
@@ -165,6 +165,7 @@ Do not send text to the active window, even if it is one of the matched windows.
|
|||||||
return chain()
|
return chain()
|
||||||
|
|
||||||
def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
|
def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
|
||||||
|
sid = payload_get('session_id', '')
|
||||||
if payload_get('all'):
|
if payload_get('all'):
|
||||||
windows: List[Optional[Window]] = list(boss.all_windows)
|
windows: List[Optional[Window]] = list(boss.all_windows)
|
||||||
else:
|
else:
|
||||||
@@ -172,14 +173,17 @@ Do not send text to the active window, even if it is one of the matched windows.
|
|||||||
match = payload_get('match')
|
match = payload_get('match')
|
||||||
if match:
|
if match:
|
||||||
windows = list(boss.match_windows(match))
|
windows = list(boss.match_windows(match))
|
||||||
|
if not windows and not sid:
|
||||||
|
raise MatchError(payload_get('match'))
|
||||||
mt = payload_get('match_tab')
|
mt = payload_get('match_tab')
|
||||||
if mt:
|
if mt:
|
||||||
windows = []
|
windows = []
|
||||||
tabs = tuple(boss.match_tabs(mt))
|
tabs = tuple(boss.match_tabs(mt))
|
||||||
if not tabs:
|
if not tabs and not sid:
|
||||||
raise MatchError(payload_get('match_tab'), 'tabs')
|
raise MatchError(payload_get('match_tab'), 'tabs')
|
||||||
for tab in tabs:
|
for tab in tabs:
|
||||||
windows += tuple(tab)
|
if tab:
|
||||||
|
windows += tuple(tab)
|
||||||
pdata: str = payload_get('data')
|
pdata: str = payload_get('data')
|
||||||
encoding, _, q = pdata.partition(':')
|
encoding, _, q = pdata.partition(':')
|
||||||
session = ''
|
session = ''
|
||||||
@@ -199,7 +203,6 @@ Do not send text to the active window, even if it is one of the matched windows.
|
|||||||
raise TypeError(f'Invalid encoding for send-text data: {encoding}')
|
raise TypeError(f'Invalid encoding for send-text data: {encoding}')
|
||||||
exclude_active = payload_get('exclude_active')
|
exclude_active = payload_get('exclude_active')
|
||||||
actual_windows = (w for w in windows if w is not None and (not exclude_active or w is not boss.active_window))
|
actual_windows = (w for w in windows if w is not None and (not exclude_active or w is not boss.active_window))
|
||||||
sid = payload_get('session_id', '')
|
|
||||||
|
|
||||||
def create_or_update_session() -> Session:
|
def create_or_update_session() -> Session:
|
||||||
s = sessions_map.setdefault(sid, Session(sid))
|
s = sessions_map.setdefault(sid, Session(sid))
|
||||||
|
|||||||
Reference in New Issue
Block a user