Skip to content

Commit

Permalink
Remove break-based shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryLawyer committed Jun 13, 2019
1 parent 1878dcd commit 5b68ab5
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/main/scala/timetracker/Timetracker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,31 @@ object Timetracker extends App {
// Can we write out to a file here?
}

breakable {
while (!shouldExit) {
val newSize = screen.doResizeIfNecessary()
terminalSize = if (newSize != null) {
screen.clear()
newSize
} else {
terminalSize
}
while (!shouldExit) {
val newSize = screen.doResizeIfNecessary()
terminalSize = if (newSize != null) {
screen.clear()
newSize
} else {
terminalSize
}

val keyStroke = screen.pollInput
if (keyStroke != null) {
if (keyStroke.getKeyType() == KeyType.EOF) {
break
}
val keyStroke = screen.pollInput
if (keyStroke != null) {
if (keyStroke.getKeyType() == KeyType.EOF) {
shouldExit = true
} else {
val (newScreen, newTimes, exit) = currentScreen.handleInput(screen, keyStroke, currentTimes)
currentScreen = newScreen
currentTimes = newTimes
shouldExit = exit
}
}

currentScreen.render(screen, terminalSize, currentTimes)
currentScreen.render(screen, terminalSize, currentTimes)

screen.refresh()
Thread.`yield`()
}
screen.refresh()
Thread.`yield`()
}

if (screen != null) {
Expand Down

0 comments on commit 5b68ab5

Please sign in to comment.