Browse Source

Improved the regexp for the input filtering

pull/119/head
Eugenio Parodi 3 years ago
parent
commit
1595b621ea
  1. 3
      TermTk/TTkCore/TTkTerm/readinputlinux.py
  2. 2
      tests/timeit/12.split.vs.re.py

3
TermTk/TTkCore/TTkTerm/readinputlinux.py

@ -46,7 +46,7 @@ class ReadInput():
tty.setcbreak(sys.stdin)
def read(self):
rm = re.compile('(\033?[^\033]*)')
rm = re.compile('(\033?[^\033]+)')
while self._readPipe[0] not in (list := select.select( [sys.stdin, self._readPipe[0]], [], [] )[0]):
# Read all the full input
_fl = fcntl.fcntl(sys.stdin, fcntl.F_GETFL)
@ -57,7 +57,6 @@ class ReadInput():
# Split all the ansi sequences
# or yield any separate input char
for sr in rm.findall(stdinRead):
if not sr: continue
if '\033' == sr[0]:
yield sr
else:

2
tests/timeit/12.split.vs.re.py

@ -37,7 +37,7 @@ strb = 'print([m.start() for m in rm.finditer(stra)]),print([m.start() for m in
strc = 'Eugenio'
strd = '\033Eugenio'
rm = re.compile('(\033?[^\033]*)')
rm = re.compile('(\033?[^\033]+)')
print(stra.split('\033'))
print(strb.split('\033'))

Loading…
Cancel
Save