Skip to content

Commit

Permalink
#3 fixed
Browse files Browse the repository at this point in the history
now Ctrl+C will quickly close Diary
other escaped characters wouldn't affect diary entry record.
  • Loading branch information
madhaven committed Sep 8, 2022
1 parent f83da57 commit a0b302c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions diary.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ def record(self):
print()
return self

#Ctrl+C
elif char == '\\x03':
if len(entry) != 0:
entry.append(['\n', t2])
self.text = ''.join(list(zip(*entry))[0])
self.intervals = list(list(zip(*entry))[1])
raise EmergencyStop

#Escape char
elif char == '\\\\':
print('\\', end='', flush=True)
Expand All @@ -106,6 +114,11 @@ def record(self):
elif char == '\\x08':
print('\b \b', end='', flush=True)
char = '\b'

#stray characters
elif len(char) > 1:
char = str(getch())[2:-1]
continue

#normal character?
else:
Expand Down

0 comments on commit a0b302c

Please sign in to comment.