Parse send_text payload only once at startup

This commit is contained in:
Kovid Goyal 2018-04-27 18:13:37 +05:30
parent 78002cf3ba
commit 9ea0de868c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 9 additions and 4 deletions

View File

@ -111,6 +111,12 @@ def parse_key_action(action):
args = tuple(map(parse_key_action, filter(None, parts)))
elif func == 'send_text':
args = rest.split(' ', 1)
if len(args) > 0:
try:
args[1] = parse_send_text_bytes(args[1])
except Exception:
log_error('Ignoring invalid send_text string: ' + args[1])
args[1] = ''
elif func in ('run_kitten', 'run_simple_kitten'):
if func == 'run_simple_kitten':
func = 'run_kitten'

View File

@ -9,7 +9,7 @@ from collections import deque
from enum import Enum
from .child import cwd_of_process
from .config import build_ansi_color_table, parse_send_text_bytes
from .config import build_ansi_color_table
from .constants import (
ScreenGeometry, WindowGeometry, appname, get_boss, wakeup
)
@ -187,10 +187,9 @@ class Window:
required_mode = frozenset(required_mode.split(','))
if not required_mode & {mode, 'all'}:
return True
data = parse_send_text_bytes(text)
if not data:
if not text:
return True
self.write_to_child(data)
self.write_to_child(text)
def write_to_child(self, data):
if data: