2017-12-15 14 views
0

terminfoのマンページでは、遅延を指定するエンコーディングの$<>msであり、その角括弧内に小数点以下1桁の精度があることが記述されています。terminfoパラメータ化された文字列の遅延

そして、次の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") 

だから私の質問は、かどうかは、テキスト/シーケンスの一部であると遅延を示すものではありませ$<ですか?例えば。 $<%p1%dまたは$<Aのようなケース(現在または将来の端末)がある可能性があります。遅延は、$<を使用して指定されることを意味するものではなく、有効なterminfoシーケンスです。 manual page

答えて

2

は、構文についてかなり明示的です:

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. 

がある場合何<、および囲まれたテキストは、(可能*および/または/付き)ない有効な数値ではありません終了、tputsはそれを遅延として扱うべきではありません。

例はありません。$<には、数字または "。" ncursesの端末データベースではなく、端末データベースはさておき\200特殊なケースから(ほとんどの文字列を記述することができるはずですので、それは(8進数)に\0と同じように扱われ、それが無効だろうという意味ではありませんC言語のNUL終端文字列に対応します。

関連する問題