0
0
Fork 0

Fixed print error and added ability to print guide

This commit is contained in:
sloumdrone 2018-12-21 21:52:34 -08:00
parent 7774a28df1
commit 1987f76fb7
1 changed files with 12 additions and 7 deletions

19
chalk
View File

@ -80,12 +80,14 @@ def chalk(path):
helptext = [ helptext = [
"", "",
"{}Commands are entered as the only entry for their row:{}".format(c.yellow, c.end), "{}Commands are entered as the only entry for their row:{}".format(c.yellow, c.end),
" . - Finish writing/exit, will prompt for save", " {}.{} - Finish writing/exit, will prompt for save".format(c.b_green, c.end),
" !? - Print this help message", " {}!?{} - Print this help message".format(c.b_green, c.end),
" !d - Display the contents of the file", " {}!d{} - Display the contents of the file".format(c.b_green, c.end),
" !# - Rewrite a line, # is replaced by line number e.g. !27", " {}!v{} - View lines, prompt will request a range of lines".format(c.b_green, c.end),
" !x - Delete line(s), prompt will request line or range", " {}!#{} - Rewrite a line, # is replaced by line number e.g. !27".format(c.b_green, c.end),
" !i - Insert line(s), prompt will request start point and optional quantity", " {}!x{} - Delete line(s), prompt will request line or range".format(c.b_green, c.end),
" {}!i{} - Insert line(s), prompt will request start point and optional quantity".format(c.b_green, c.end),
" {}!g{} - Print the ruler/guide".format(c.b_green, c.end),
"" ""
] ]
@ -109,6 +111,9 @@ def chalk(path):
print('{:8} {}'.format(' ',x)) print('{:8} {}'.format(' ',x))
print('') print('')
print(header) print(header)
elif ln == '!g':
print('')
print(header)
elif ln == '!d': elif ln == '!d':
print('') print('')
for i, x in enumerate(content): for i, x in enumerate(content):
@ -171,7 +176,7 @@ def chalk(path):
print(header) print(header)
except: except:
print('{}{:8} Invalid entry{}'.format(c.red, c.end)) print('{}{:8} Invalid entry{}'.format(c.red, ' ', c.end))
elif re.match(r'^\!\d+$',ln): elif re.match(r'^\!\d+$',ln):
try: try:
row = int(ln[1:]) row = int(ln[1:])