Nicer case statement
This commit is contained in:
parent
847cd55617
commit
d0dae5e839
1 changed files with 21 additions and 19 deletions
18
more.nim
18
more.nim
|
|
@ -29,24 +29,26 @@ proc main(files:seq[string]) =
|
|||
topLine = minTopLine
|
||||
while true:
|
||||
redraw(lineBuffer, topLine)
|
||||
command = getch()
|
||||
if command == 'q':
|
||||
case getch():
|
||||
of 'q':
|
||||
break
|
||||
if command == 'j':
|
||||
of 'j':
|
||||
inc topLine
|
||||
if topLine > maxTopLine: topLine = maxTopLine
|
||||
if command == 'k':
|
||||
of 'k':
|
||||
dec topLine
|
||||
if topLine < minTopLine: topLine = minTopLine
|
||||
if command == 'f':
|
||||
of 'f':
|
||||
topLine += terminalHeight()
|
||||
if topLine > maxTopLine: topLine = maxTopLine
|
||||
if command == 'b':
|
||||
of 'b':
|
||||
topLine -= terminalHeight()
|
||||
if topLine < minTopLine: topLine = minTopLine
|
||||
if command == 'g':
|
||||
of 'g':
|
||||
topLine = minTopLine
|
||||
if command == 'G':
|
||||
of 'G':
|
||||
topLine = maxTopLine
|
||||
else:
|
||||
discard
|
||||
|
||||
dispatch(main, version=("version", nimbaseVersion))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue