terminfo 参数化字符串中的延迟
Delay in terminfo parameterized strings
在 terminfo 的联机帮助页中,提到 $<>
在 ms
中指定延迟的编码中,其中 angular 括号内是最多为 1 的数字小数点精度。
并且通过以下 python 脚本,我确认 $<
仅用于指定延迟,即没有参数化字符串,其中 $<
用于不指定延迟.
#!/usr/bin/env python3
# './test/data/stressTestTerms.txt' contains contains terminal names
# and directory './test/data/mirror' contains terminal databases of 2718 terminals
import subprocess
import re
def check_dollar_angular(caps):
string_caps = [cap for cap in caps.split(',') if '=' in cap]
# search for $<..> type delays in string caps
delay = r"$<(\d+(\.(\d)+)?\*?/?|(\.(\d)+)?\*?/?)>"
caps_with_dollar = 0
delay_matches = 0
for cap in string_caps:
matches = list(re.finditer(delay, cap))
dollar_idx = cap.find('$<')
if dollar_idx != -1:
caps_with_dollar += 1
if any([True if match.start() == dollar_idx else False for match in matches]):
delay_matches += 1
if caps_with_dollar == delay_matches:
return True
else:
return False
if __name__ == "__main__":
with open('./test/data/stressTestTerms.txt') as terminal_names:
res = []
for each_terminal in terminal_names:
output = subprocess.run(
['infocmp', '-0', '-A', './test/data/mirror', each_terminal.strip()], stdout=subprocess.PIPE)
try:
output.check_returncode()
caps = output.stdout.decode('utf-8')
res.append(check_dollar_angular(caps))
except subprocess.CalledProcessError as e:
print(e)
if (not all(res)):
print(
"We have a terminal where in one of it's caps there is a dollar-angular but it doesn't signify delay")
else:
print(
"Success! no terminal found where '$<' is used for anything else other than specifying delay")
所以我的问题是,是否 $<
是 text/sequence 的一部分而不代表延迟?例如。是否存在这样的情况(现在或将来的终端):$<%p1%d
或 $<A
,其中没有结尾的 angular 括号并且延迟并不意味着使用 $<
并且仍然是有效的 terminfo 序列?
manual page 的语法非常明确:
A delay in milliseconds may appear anywhere in a string capability,
enclosed in $<..> brackets, as in el=\EK$<5>, and padding characters
are supplied by tputs(3x) to provide this delay.
o The delay must be a number with at most one decimal place of preci-
sion; it may be followed by suffixes "*" or "/" or both.
o A "*" indicates that the padding required is proportional to the
number of lines affected by the operation, and the amount given is
the per-affected-unit padding required. (In the case of insert
character, the factor is still the number of lines affected.)
Normally, padding is advisory if the device has the xon capability;
it is used for cost computation but does not trigger delays.
o A "/" suffix indicates that the padding is mandatory and forces a
delay of the given number of milliseconds even on devices for which
xon is present to indicate flow control.
如果没有结尾 <
,并且包含的文本不是有效数字(可能 *
and/or /
), 那么tputs
不应将其视为延迟。
没有 $<
后跟数字或“.”的例子。在 ncurses 的终端数据库中,但这并不意味着它将 无效 ,因为终端数据库应该能够描述大多数字符串(除了 [= 的特殊情况16=](八进制)被视为与 [=17=]
相同,以适应 C 语言的 NUL 终止字符串。
在 terminfo 的联机帮助页中,提到 $<>
在 ms
中指定延迟的编码中,其中 angular 括号内是最多为 1 的数字小数点精度。
并且通过以下 python 脚本,我确认 $<
仅用于指定延迟,即没有参数化字符串,其中 $<
用于不指定延迟.
#!/usr/bin/env python3
# './test/data/stressTestTerms.txt' contains contains terminal names
# and directory './test/data/mirror' contains terminal databases of 2718 terminals
import subprocess
import re
def check_dollar_angular(caps):
string_caps = [cap for cap in caps.split(',') if '=' in cap]
# search for $<..> type delays in string caps
delay = r"$<(\d+(\.(\d)+)?\*?/?|(\.(\d)+)?\*?/?)>"
caps_with_dollar = 0
delay_matches = 0
for cap in string_caps:
matches = list(re.finditer(delay, cap))
dollar_idx = cap.find('$<')
if dollar_idx != -1:
caps_with_dollar += 1
if any([True if match.start() == dollar_idx else False for match in matches]):
delay_matches += 1
if caps_with_dollar == delay_matches:
return True
else:
return False
if __name__ == "__main__":
with open('./test/data/stressTestTerms.txt') as terminal_names:
res = []
for each_terminal in terminal_names:
output = subprocess.run(
['infocmp', '-0', '-A', './test/data/mirror', each_terminal.strip()], stdout=subprocess.PIPE)
try:
output.check_returncode()
caps = output.stdout.decode('utf-8')
res.append(check_dollar_angular(caps))
except subprocess.CalledProcessError as e:
print(e)
if (not all(res)):
print(
"We have a terminal where in one of it's caps there is a dollar-angular but it doesn't signify delay")
else:
print(
"Success! no terminal found where '$<' is used for anything else other than specifying delay")
所以我的问题是,是否 $<
是 text/sequence 的一部分而不代表延迟?例如。是否存在这样的情况(现在或将来的终端):$<%p1%d
或 $<A
,其中没有结尾的 angular 括号并且延迟并不意味着使用 $<
并且仍然是有效的 terminfo 序列?
manual page 的语法非常明确:
A delay in milliseconds may appear anywhere in a string capability,
enclosed in $<..> brackets, as in el=\EK$<5>, and padding characters
are supplied by tputs(3x) to provide this delay.
o The delay must be a number with at most one decimal place of preci-
sion; it may be followed by suffixes "*" or "/" or both.
o A "*" indicates that the padding required is proportional to the
number of lines affected by the operation, and the amount given is
the per-affected-unit padding required. (In the case of insert
character, the factor is still the number of lines affected.)
Normally, padding is advisory if the device has the xon capability;
it is used for cost computation but does not trigger delays.
o A "/" suffix indicates that the padding is mandatory and forces a
delay of the given number of milliseconds even on devices for which
xon is present to indicate flow control.
如果没有结尾 <
,并且包含的文本不是有效数字(可能 *
and/or /
), 那么tputs
不应将其视为延迟。
没有 $<
后跟数字或“.”的例子。在 ncurses 的终端数据库中,但这并不意味着它将 无效 ,因为终端数据库应该能够描述大多数字符串(除了 [= 的特殊情况16=](八进制)被视为与 [=17=]
相同,以适应 C 语言的 NUL 终止字符串。