Skip to content
This repository
Browse code

another fix related to #460

  • Loading branch information...
commit cf2402cea4bc013495fb79c1db303b4bd3c4f7ed 1 parent e34b8e4
Mark Harrah authored
2  main/SettingGraph.scala
@@ -57,7 +57,7 @@ object Graph
57 57 // [info] |
58 58 // [info] +-quux
59 59 def toAscii[A](top: A, children: A => Seq[A], display: A => String): String = {
60   - val maxColumn = jline.Terminal.getTerminal.getTerminalWidth - 8
  60 + val maxColumn = JLine.usingTerminal(_.getTerminalWidth) - 8
61 61 val twoSpaces = " " + " " // prevent accidentally being converted into a tab
62 62 def limitLine(s: String): String =
63 63 if (s.length > maxColumn) s.slice(0, maxColumn - 2) + ".."
10 util/complete/LineReader.scala
@@ -62,10 +62,16 @@ private object JLine
62 62 val t = terminal
63 63 t.synchronized { f(t) }
64 64 }
65   - def createReader() =
  65 + /** For accessing the JLine Terminal object.
  66 + * This ensures synchronized access as well as re-enabling echo after getting the Terminal. */
  67 + def usingTerminal[T](f: jline.Terminal => T): T =
66 68 withTerminal { t =>
67   - val cr = new ConsoleReader
68 69 t.enableEcho()
  70 + f(t)
  71 + }
  72 + def createReader() =
  73 + usingTerminal { t =>
  74 + val cr = new ConsoleReader
69 75 cr.setBellEnabled(false)
70 76 cr
71 77 }

0 comments on commit cf2402c

Please sign in to comment.
Something went wrong with that request. Please try again.