Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Want to extend Console.

 
Nachiket Patel
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I want to extend functionality of Java Console.
Say want to highlight(color) some words etc.

Is it possible???

As per my knowledge, it is not, because it is suppose to be platform independent. And not all platform provides this functionality (or something like that), but say i want to extend only console in windows (as of now)

How to do??

Any ideas???

Regards,
Nachiket
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would that be the public final class Console?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a completely platform independent way? No. But you can print ANSI escape codes to print colored text and do some cursor movement on Windows, Linux, and Mac OS X, so for all practical purposes yes, you can.

See here for a table of the escape codes you need. For a Java example: this prints "Hello, World" in red:

System.out.println("\u001b[01;31mHello, World\u001b[00m");
 
Nachiket Patel
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Thank you for your replies.


Would that be the public final class Console?


I said i want to extend functionality not Console class.


Thanks, Ernest, that's what i am looking for. I want to show colored text, as well as folder navigation using <tab> feature.

I tried, but i don't know,
it prints like this..
←[01;31mHello, World←[00m

I'll try, but if you know, why it is not showing, then let me know.

Thanks
Nachiket
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There was some discussion on this recently: http://www.coderanch.com/t/416938/java/java/Different-colored-text
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic