Skip to content

Color REPL under -Dscala.color #3993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 9, 2014

Conversation

puffnfresh
Copy link
Contributor

We already use -Dscala.color when using -Ytyper-debug

This tries to reuse the colors chosen from the debug flag:

  • Bold blue for vals (e.g. "res0")
  • Bold green for types (e.g. "Int")
  • Magenta for the shell prompt (e.g. "scala>")

We already use -Dscala.color when using -Ytyper-debug

This tries to reuse the colors chosen from the debug flag:

* Bold blue for vals (e.g. "res0")
* Bold green for types (e.g. "Int")
* Magenta for the shell prompt (e.g. "scala>")
@scala-jenkins scala-jenkins added this to the 2.11.3 milestone Sep 22, 2014
@retronym
Copy link
Member

Looks like a flakey test in the scala-refactoring suite.

Results :

Failed tests: 
  ReusingPrinterTest.add_override_final_flags_to_lazy_val:138 expected:<...T extends T {
      [override final ]lazy val meth = 0
  ...> but was:<...T extends T {
      []lazy val meth = 0
  ...>

PLS REBUILD ALL

@retronym
Copy link
Member

This change fulfils part I of https://issues.scala-lang.org/browse/SI-4223.

@scala-jenkins
Copy link

(kitty-note-to-self: ignore 56330649)
🐱 Roger! Rebuilding pr-scala for 9902ae5. 🚨

@retronym
Copy link
Member

It is probably worthwhile to discuss what we would need to do to turn this on by default in the REPL.

To avoid the effecting tools that programatically drive the REPL, we could predicate it based on a suitable terminal environment:

scala> new jline.console.ConsoleReader().getTerminal.isAnsiSupported
res3: Boolean = true

We could also have a system property to turn it off explicitly.

Maybe we'd target this change at 2.12 both to be conservative and to give the feature (and the colour pallette) some time to mature.

* Errors are red
* Warnings are yellow
@retronym
Copy link
Member

retronym commented Oct 2, 2014

I think you might have missed a spot.

image

@puffnfresh
Copy link
Contributor Author

@retronym I did, thank you.

@adriaanm
Copy link
Contributor

adriaanm commented Oct 7, 2014

Cool, more flair for the REPL! What's the status of the missed spot?

@gkossakowski
Copy link
Contributor

Given missing activity, rescheduling for 2.11.4 (to happen at the end of November).

@gkossakowski gkossakowski modified the milestones: 2.11.4, 2.11.3 Oct 7, 2014
@puffnfresh
Copy link
Contributor Author

I'm happy to work on this tonight, if that's not too late to get into this release.

@gkossakowski
Copy link
Contributor

Hi @puffnfresh!
We are blocked by https://issues.scala-lang.org/browse/SI-8890 for which fix should arrive tomorrow. Let's give this PR another try, then. However, if you or us will feel tomorrow that this didn't have enough of time to fully bake, we'll reschedule it for 2.11.4, ok?

@gkossakowski gkossakowski modified the milestones: 2.11.3, 2.11.4 Oct 7, 2014
@puffnfresh
Copy link
Contributor Author

@gkossakowski sounds great 👍

@puffnfresh
Copy link
Contributor Author

@gkossakowski good to go:

screen shot 2014-10-07 at 9 16 23 pm

@retronym
Copy link
Member

retronym commented Oct 8, 2014

How does it look on a light black-on-white themed terminal?

@puffnfresh
Copy link
Contributor Author

@retronym as far as I know, most terminals choose colours which work on black or white. You be the judge, though:

screen shot 2014-10-07 at 9 21 16 pm

@retronym
Copy link
Member

retronym commented Oct 8, 2014

That looks good enough for now. If we turn it on by default in 2.12, we can polish that a little further. Thanks!

@puffnfresh
Copy link
Contributor Author

Yeah, I'm hoping for a tiny amount of data before the bike shedding starts.

gkossakowski added a commit that referenced this pull request Oct 9, 2014
@gkossakowski gkossakowski merged commit 19d1c81 into scala:2.11.x Oct 9, 2014
@jrudolph
Copy link
Contributor

Yay, nice idea. 👍

@jrudolph
Copy link
Contributor

FTR: here's how to enable it automatically in sbt:

Put this into your ~/.sbt/0.13/user.sbt:

initialize ~= { _ =>
  val ansi = System.getProperty("sbt.log.noformat", "false") != "true"
  if (ansi) System.setProperty("scala.color", "true")
}

@jozic
Copy link
Contributor

jozic commented Oct 31, 2014

@jrudolph 👍

@retronym
Copy link
Member

retronym commented Nov 3, 2014

I would suggest to predicate this on sbt.ConsoleLogger.formatEnabled, which incorporates the checks for the system property sbt.nologformat and the capabilities of the terminal.

% sbt "eval sbt.ConsoleLogger.formatEnabled"
[info] Loading global plugins from /Users/jason/.sbt/0.13/plugins
[info] Set current project to scala (in build file:/Users/jason/code/scala/)
[info] ans: Boolean = true

% sbt -Dsbt.log.noformat=true "eval sbt.ConsoleLogger.formatEnabled"
[info] Loading global plugins from /Users/jason/.sbt/0.13/plugins
[info] Set current project to scala (in build file:/Users/jason/code/scala/)
[info] ans: Boolean = false

@lihaoyi
Copy link
Contributor

lihaoyi commented Feb 3, 2015

Was this announced anywhere? This is probably the biggest improvement to the Scala REPL since the great war of 1939

@adriaanm
Copy link
Contributor

adriaanm commented Feb 3, 2015

;-) i believe it was included in forSome release notes, but happy to tout it again (handwritten.md over at scala/make-release-notes)

@lihaoyi
Copy link
Contributor

lihaoyi commented Feb 3, 2015

Wherever you put it, Google can't find it, because I've googled this and clicked-through the JIRA ticket at least 5 times by this point =P

screenshot 2015-02-02 17 46 39

@xring
Copy link

xring commented Jun 16, 2015

thank u~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants