1
1
package javarepl ;
2
2
3
+ import com .googlecode .totallylazy .Exceptions ;
3
4
import com .googlecode .totallylazy .Option ;
4
5
import com .googlecode .totallylazy .Sequence ;
5
6
import com .googlecode .totallylazy .Strings ;
8
9
import javarepl .client .JavaREPLClient ;
9
10
import javarepl .completion .CompletionCandidate ;
10
11
import javarepl .completion .CompletionResult ;
12
+ import jline .Terminal ;
13
+ import jline .TerminalFactory ;
11
14
import jline .console .ConsoleReader ;
12
15
import jline .console .CursorBuffer ;
13
16
import jline .console .completer .CandidateListCompletionHandler ;
21
24
import java .nio .file .Files ;
22
25
import java .util .*;
23
26
27
+ import static com .googlecode .totallylazy .Exceptions .captureException ;
24
28
import static com .googlecode .totallylazy .Files .fileOption ;
25
29
import static com .googlecode .totallylazy .Option .none ;
26
30
import static com .googlecode .totallylazy .Option .some ;
@@ -167,6 +171,8 @@ private static Boolean printColors(String[] args) {
167
171
168
172
private static ExpressionReader expressionReaderFor (final JavaREPLClient client , Sequence <String > initialExpressions ) throws IOException {
169
173
return new ExpressionReader (new Function1 <Sequence <String >, String >() {
174
+ private static final char CTRL_C = (char ) 3 ;
175
+ private static final char CTRL_D = (char ) 4 ;
170
176
private final ConsoleReader consoleReader ;
171
177
private Sequence <String > expressions = initialExpressions ;
172
178
@@ -176,6 +182,7 @@ private static ExpressionReader expressionReaderFor(final JavaREPLClient client,
176
182
consoleReader .setHistoryEnabled (true );
177
183
consoleReader .setExpandEvents (false );
178
184
consoleReader .addCompleter (clientCompleter ());
185
+ consoleReader .addTriggeredAction (CTRL_D , e -> System .exit (0 ));
179
186
}
180
187
181
188
public String call (Sequence <String > lines ) throws Exception {
0 commit comments