Skip to content

Commit

Permalink
Adding a few stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
TonioGela committed Oct 23, 2023
1 parent c04b55c commit e220a40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
# This file was automatically generated by sbt-github-actions using the
# githubWorkflowGenerate task. You should add and commit this file to
# your git repository. It goes without saying that you shouldn't edit
# this file by hand! Instead, if you wish to make changes, you should
# change your sbt build configuration to revise the workflow description
# to meet your needs, then regenerate this file.

name: Clean

on: push

jobs:
delete-artifacts:
name: Delete Artifacts
Expand Down
8 changes: 7 additions & 1 deletion client/src/main/scala/dev/toniogela/chat/Printer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ object Printer:

def errorln(msg: String): IO[Unit] = println(s"$RED$msg$RESET")

private val ESC: String = "\u001B"

private val deleteLine: String = s"$ESC[2K"

private val upLine: String = s"$ESC[F"

def readLine: IO[Option[String]] =
stdinUtf8[IO](1024).take(1).compile.foldMonoid.map(_.trim.some.filterNot(_.isBlank))
.flatTap(_ => Console[IO].print("\u001B[F\u001B[2K"))
.flatTap(_ => Console[IO].print(s"$upLine$deleteLine"))
.handleErrorWith { case t => Console[IO].errorln(t) >> t.raiseError }
}
}
Expand Down

0 comments on commit e220a40

Please sign in to comment.