Skip to content

Commit

Permalink
Merge pull request #66 from FISCO-BCOS/dev
Browse files Browse the repository at this point in the history
 fix sol2java.sh and ctrl+c
  • Loading branch information
fqliao authored Apr 16, 2019
2 parents 88a475d + a02c9b2 commit d489f60
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/main/java/console/ConsoleClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
import org.fisco.bcos.web3j.protocol.exceptions.MessageDecodingException;
import org.jline.builtins.Completers.FilesCompleter;
import org.jline.reader.Completer;
import org.jline.reader.EndOfFileException;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
import org.jline.reader.UserInterruptException;
import org.jline.reader.impl.completer.AggregateCompleter;
import org.jline.reader.impl.completer.ArgumentCompleter;
import org.jline.reader.impl.completer.StringsCompleter;
import org.jline.terminal.Attributes;
import org.jline.terminal.Attributes.ControlChar;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;

Expand Down Expand Up @@ -102,8 +106,17 @@ public static void main(String[] args) {
completers.add(new ArgumentCompleter(new StringsCompleter("quit")));
completers.add(new ArgumentCompleter(new StringsCompleter("exit")));

Terminal terminal = TerminalBuilder.terminal();
lineReader =
Terminal terminal = TerminalBuilder.builder()
.nativeSignals(true)
.signalHandler(Terminal.SignalHandler.SIG_IGN)
.build();
Attributes termAttribs = terminal.getAttributes();
// enable CTRL+D shortcut
termAttribs.setControlChar(ControlChar.VEOF, 4);
// enable CTRL+C shortcut
termAttribs.setControlChar(ControlChar.VINTR, 4);
terminal.setAttributes(termAttribs);
lineReader =
LineReaderBuilder.builder()
.terminal(terminal)
.completer(new AggregateCompleter(completers))
Expand Down Expand Up @@ -329,6 +342,12 @@ public static void main(String[] args) {
System.out.println("Contract call failed.");
System.out.println();
}
catch (UserInterruptException e) {
console.close();
}
catch (EndOfFileException e) {
console.close();
}
catch (Exception e) {
if(e.getMessage().contains("MessageDecodingException"))
{
Expand Down
1 change: 1 addition & 0 deletions tools/sol2java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function check_java(){
version=${version:1:len}

IFS='.' arr=($version)
IFS=' '
if [ -z ${arr[0]} ];then
LOG_ERROR "At least Java8 is required."
exit 1
Expand Down

0 comments on commit d489f60

Please sign in to comment.