Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryLawyer committed Jun 4, 2019
0 parents commit b9a5d0b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
11 changes: 11 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ThisBuild / scalaVersion := "2.12.7"
ThisBuild / organization := "com.angrylawyer"

resolvers ++= Seq("snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
"releases" at "http://oss.sonatype.org/content/repositories/releases")

lazy val timetracker = (project in file("."))
.settings(
name := "TimeTracker",
libraryDependencies += "com.googlecode.lanterna" % "lanterna" % "3.0.1"
)
38 changes: 38 additions & 0 deletions src/main/scala/timetracker/Timetracker.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package timetracker
import scala.util.control.Breaks._
import com.googlecode.lanterna.terminal.DefaultTerminalFactory
import com.googlecode.lanterna.screen.TerminalScreen
import com.googlecode.lanterna.input.{KeyStroke, KeyType}


object Timetracker extends App {
val terminal = new DefaultTerminalFactory().createTerminal()
val screen = new TerminalScreen(terminal)
screen.startScreen()

var terminalSize = screen.getTerminalSize
screen.setCursorPosition(null)
screen.refresh()

breakable {
while (true) {
val keyStroke = screen.pollInput
if(keyStroke != null && (keyStroke.getKeyType() == KeyType.Escape || keyStroke.getKeyType() == KeyType.EOF)) {
break
}

val newSize = screen.doResizeIfNecessary()
terminalSize = if (newSize != null) {
newSize
} else {
terminalSize
}
screen.refresh()
Thread.`yield`()
}
}

if (screen != null) {
screen.close()
}
}

0 comments on commit b9a5d0b

Please sign in to comment.