Skip to content

Commit

Permalink
Set default Console constructor to use keyboard and terminal display as
Browse files Browse the repository at this point in the history
input/output stream.
  • Loading branch information
johardi committed Jul 29, 2014
1 parent 48485e5 commit 106e35b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/com/obidea/semantika/cli2/Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.obidea.semantika.cli2;

import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;

Expand Down Expand Up @@ -68,8 +67,7 @@ private Console createInteractiveConsole(IQueryEngine engine, IPrefixManager pm,
Terminal terminal) throws IOException
{
showBanner();
InputStream in = System.in; // listen the keyboard
return new Console(engine, pm, name, in, terminal);
return new Console(name, engine, pm, terminal);
}

private void showBanner()
Expand Down
25 changes: 15 additions & 10 deletions src/com/obidea/semantika/cli2/runtime/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class Console
private String mConsoleName;

private InputStream mInputStream;
private static PrintStream mOutputStream;
private static PrintStream mErrorStream;
private PrintStream mOutputStream;
private PrintStream mErrorStream;

private Thread mPipeThread;
private Thread mRunningThread;
Expand All @@ -36,13 +36,18 @@ public class Console
private ConsoleReader mConsoleReader;
private ConsoleSession mConsoleSession;

public Console(IQueryEngine engine, IPrefixManager pm, String name, InputStream inputSource,
Terminal terminal) throws IOException
public Console(String name, IQueryEngine engine, IPrefixManager pm, Terminal terminal) throws IOException
{
this(name, engine, pm, System.in, System.out, System.err, terminal);
}

public Console(String name, IQueryEngine engine, IPrefixManager pm, InputStream inputSource, PrintStream outputTarget,
PrintStream errorTarget, Terminal terminal) throws IOException
{
mConsoleName = name;
mInputStream = inputSource;
mOutputStream = System.out;
mErrorStream = System.err;
mOutputStream = outputTarget;
mErrorStream = errorTarget;
mConsoleReader = createConsoleReader(name, terminal);
mConsoleSession = new ConsoleSession(engine, pm);
mPipeThread = new Thread(new Pipe());
Expand Down Expand Up @@ -255,13 +260,13 @@ public int read() throws IOException
}
}

protected static void error(String message)
protected void info(String message)
{
mErrorStream.println(message); //$NON-NLS-1$
mOutputStream.println(message);
}

protected static void info(String message)
protected void error(String message)
{
mOutputStream.println(message);
mErrorStream.println(message);
}
}

0 comments on commit 106e35b

Please sign in to comment.