Skip to content

Commit

Permalink
make console banner configurable (and optional)
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@6414 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
MenTaLguY committed Apr 5, 2008
1 parent 6bf7e4c commit 8ccfaca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions samples/irb-applet.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
codebase="../lib/"
archive="jruby-complete.jar"
width="500" height="500">
<param name="jruby.banner" value="Welcome to JRuby on the Web!" />
<param name="jruby.console" value="true" />
<param name="jruby.objectspace" value="true" />
<param name="jruby.eval" value="ARGV[0..-1] = %w(-f) ; require 'irb' ; require 'irb/completion' ; Thread.new { IRB.start }" />
Expand Down
13 changes: 8 additions & 5 deletions src/org/jruby/JRubyApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ private static RubyProc blockToProc(Ruby runtime, Block block) {
}
}

private boolean getBooleanParameter(String name, boolean default_value) {
private boolean getBooleanParameter(String name, boolean defaultValue) {
String value = getParameter(name);
if ( value != null ) {
return value.equals("true");
} else {
return default_value;
return defaultValue;
}
}

Expand Down Expand Up @@ -206,7 +206,7 @@ public void init() {
super.init();

if (getBooleanParameter("jruby.console", false)) {
facade = new ConsoleFacade();
facade = new ConsoleFacade(getParameter("jruby.banner"));
} else {
facade = new TrivialFacade();
}
Expand Down Expand Up @@ -388,7 +388,7 @@ private static class ConsoleFacade implements Facade {
private PrintStream outputStream;
private PrintStream errorStream;

public ConsoleFacade() {
public ConsoleFacade(String bannerText) {
textPane = new JTextPane();
textPane.setMargin(new Insets(4, 4, 0, 4));
textPane.setCaretColor(new Color(0xa4, 0x00, 0x00));
Expand All @@ -402,7 +402,10 @@ public ConsoleFacade() {

scrollPane = new JScrollPane(textPane);
scrollPane.setDoubleBuffered(true);
adaptor = new TextAreaReadline(textPane, " JRuby applet console \n\n");
if ( bannerText != null ) {
bannerText = " " + bannerText + " \n\n";
}
adaptor = new TextAreaReadline(textPane, bannerText);
inputStream = adaptor.getInputStream();
outputStream = new PrintStream(adaptor.getOutputStream());
errorStream = new PrintStream(adaptor.getOutputStream());
Expand Down

0 comments on commit 8ccfaca

Please sign in to comment.