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
|
topLine = minTopLine
|
||||||
while true:
|
while true:
|
||||||
redraw(lineBuffer, topLine)
|
redraw(lineBuffer, topLine)
|
||||||
command = getch()
|
case getch():
|
||||||
if command == 'q':
|
of 'q':
|
||||||
break
|
break
|
||||||
if command == 'j':
|
of 'j':
|
||||||
inc topLine
|
inc topLine
|
||||||
if topLine > maxTopLine: topLine = maxTopLine
|
if topLine > maxTopLine: topLine = maxTopLine
|
||||||
if command == 'k':
|
of 'k':
|
||||||
dec topLine
|
dec topLine
|
||||||
if topLine < minTopLine: topLine = minTopLine
|
if topLine < minTopLine: topLine = minTopLine
|
||||||
if command == 'f':
|
of 'f':
|
||||||
topLine += terminalHeight()
|
topLine += terminalHeight()
|
||||||
if topLine > maxTopLine: topLine = maxTopLine
|
if topLine > maxTopLine: topLine = maxTopLine
|
||||||
if command == 'b':
|
of 'b':
|
||||||
topLine -= terminalHeight()
|
topLine -= terminalHeight()
|
||||||
if topLine < minTopLine: topLine = minTopLine
|
if topLine < minTopLine: topLine = minTopLine
|
||||||
if command == 'g':
|
of 'g':
|
||||||
topLine = minTopLine
|
topLine = minTopLine
|
||||||
if command == 'G':
|
of 'G':
|
||||||
topLine = maxTopLine
|
topLine = maxTopLine
|
||||||
|
else:
|
||||||
|
discard
|
||||||
|
|
||||||
dispatch(main, version=("version", nimbaseVersion))
|
dispatch(main, version=("version", nimbaseVersion))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue