mirror of
https://github.com/erkin/ponysay.git
synced 2025-03-03 16:01:27 +01:00
m + stty settings
This commit is contained in:
parent
88ca31b0a6
commit
d5328a32f7
1 changed files with 13 additions and 7 deletions
|
@ -73,13 +73,21 @@ class PonysayTool():
|
||||||
print('%s %s' % ('ponysay', VERSION))
|
print('%s %s' % ('ponysay', VERSION))
|
||||||
|
|
||||||
elif (opts['--edit'] is not None) and (len(opts['--edit']) == 1):
|
elif (opts['--edit'] is not None) and (len(opts['--edit']) == 1):
|
||||||
print('\033[?1049h', end='') # initialise terminal
|
|
||||||
pony = opts['--edit'][0]
|
pony = opts['--edit'][0]
|
||||||
if not os.path.isfile(pony):
|
if not os.path.isfile(pony):
|
||||||
printerr('%s is not an existing regular file' % pony)
|
printerr('%s is not an existing regular file' % pony)
|
||||||
exit(252)
|
exit(252)
|
||||||
self.editmeta(pony)
|
try:
|
||||||
print('\033[?1049l', end='') # terminate terminal
|
print('\033[?1049h', end='') # initialise terminal
|
||||||
|
cmd = 'stty %s < %s > /dev/null 2> /dev/null'
|
||||||
|
cmd %= ('-echo -icanon -isig', os.path.realpath('/dev/stdout'))
|
||||||
|
Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE).wait()
|
||||||
|
self.editmeta(pony)
|
||||||
|
finally:
|
||||||
|
cmd = 'stty %s < %s > /dev/null 2> /dev/null'
|
||||||
|
cmd %= ('echo icanon isig', os.path.realpath('/dev/stdout'))
|
||||||
|
Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE).wait()
|
||||||
|
print('\033[?1049l', end='') # terminate terminal
|
||||||
|
|
||||||
else:
|
else:
|
||||||
exit(253)
|
exit(253)
|
||||||
|
@ -172,8 +180,6 @@ class PonysayTool():
|
||||||
termsize = termsize.decode('utf8', 'replace')[:-1].split(' ') # [:-1] removes a \n
|
termsize = termsize.decode('utf8', 'replace')[:-1].split(' ') # [:-1] removes a \n
|
||||||
termsize = [int(item) for item in termsize]
|
termsize = [int(item) for item in termsize]
|
||||||
break
|
break
|
||||||
if termsize is None:
|
|
||||||
print('\033[?1049l', end='')
|
|
||||||
|
|
||||||
AUTO_PUSH = '\033[01010~'
|
AUTO_PUSH = '\033[01010~'
|
||||||
AUTO_POP = '\033[10101~'
|
AUTO_POP = '\033[10101~'
|
||||||
|
@ -212,13 +218,13 @@ class PonysayTool():
|
||||||
|
|
||||||
|
|
||||||
for key in fields:
|
for key in fields:
|
||||||
print('\033[1m%s:\033[21m' % key)
|
print('\033[34m%s:\033[39m' % key)
|
||||||
|
|
||||||
input()
|
input()
|
||||||
|
|
||||||
comment = data['comment']
|
comment = data['comment']
|
||||||
del data['comment']
|
del data['comment']
|
||||||
comment = ('\n' + comment + '\n').replace('\n$$$\n', '\n$$$ ($$$)\n')[:-1]
|
comment = ('\n' + comment + '\n').replace('\n$$$\n', '\n\\$$$\n')[:-1]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue