From d0dae5e8396bd3f9ff3b131ac0927d1f366023ea Mon Sep 17 00:00:00 2001 From: joachimschmidt557 Date: Sat, 6 Apr 2019 20:45:58 +0200 Subject: [PATCH] Nicer case statement --- more.nim | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/more.nim b/more.nim index dd8530c..b67cd68 100644 --- a/more.nim +++ b/more.nim @@ -29,24 +29,26 @@ proc main(files:seq[string]) = topLine = minTopLine while true: redraw(lineBuffer, topLine) - command = getch() - if command == 'q': - break - if command == 'j': - inc topLine - if topLine > maxTopLine: topLine = maxTopLine - if command == 'k': - dec topLine - if topLine < minTopLine: topLine = minTopLine - if command == 'f': - topLine += terminalHeight() - if topLine > maxTopLine: topLine = maxTopLine - if command == 'b': - topLine -= terminalHeight() - if topLine < minTopLine: topLine = minTopLine - if command == 'g': - topLine = minTopLine - if command == 'G': - topLine = maxTopLine + case getch(): + of 'q': + break + of 'j': + inc topLine + if topLine > maxTopLine: topLine = maxTopLine + of 'k': + dec topLine + if topLine < minTopLine: topLine = minTopLine + of 'f': + topLine += terminalHeight() + if topLine > maxTopLine: topLine = maxTopLine + of 'b': + topLine -= terminalHeight() + if topLine < minTopLine: topLine = minTopLine + of 'g': + topLine = minTopLine + of 'G': + topLine = maxTopLine + else: + discard dispatch(main, version=("version", nimbaseVersion))