File: demo_input_paste.py

package info (click to toggle)
python-curtsies 0.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 420 kB
  • sloc: python: 4,021; sh: 6; makefile: 5
file content (20 lines) | stat: -rw-r--r-- 602 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from curtsies.input import *

def paste():
    """
    Returns user input, delayed by one second, as a string; creates a paste event for 
    strings longer than the paste threshold and returns a list of the characters in 
    the string separated by commas.
    """
    with Input() as input_generator:
        print("If more than %d chars read in same read a paste event is generated" % input_generator.paste_threshold)
        for e in input_generator:
            print(repr(e))

            if e == '<ESC>':
                break

            time.sleep(1)

if __name__ == '__main__':
    paste()