Skip to content

Commit cc021a5

Browse files
committedMar 8, 2023
Fix signal processing on windows, fixes #822
1 parent 6fa8b78 commit cc021a5

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2023, the original author or authors.
3+
*
4+
* This software is distributable under the BSD license. See the terms of the
5+
* BSD license in the documentation provided with this software.
6+
*
7+
* https://opensource.org/licenses/BSD-3-Clause
8+
*/
9+
package org.jline.demo;
10+
11+
import org.jline.terminal.Terminal;
12+
import org.jline.terminal.TerminalBuilder;
13+
14+
public class TerminalDemo {
15+
16+
public static void main(String[] args) throws Exception {
17+
try (Terminal terminal = TerminalBuilder.terminal() )
18+
{
19+
terminal.enterRawMode();
20+
21+
terminal.writer().println("Terminal: " + terminal);
22+
terminal.writer().println("Type characters, which will be echoed to the terminal. Q will also exit this example.");
23+
terminal.writer().println();
24+
terminal.writer().flush();
25+
26+
while (true) {
27+
int c = terminal.reader().read(16);
28+
if (c >= 0) {
29+
terminal.writer().write(c);
30+
terminal.writer().flush();
31+
32+
// Use "q" to quit early
33+
if (c == 81 || c == 113) break;
34+
} else {
35+
if (c == -1) break; // Got EOF
36+
}
37+
}
38+
}
39+
}
40+
}

‎terminal/src/main/java/org/jline/terminal/impl/AbstractWindowsTerminal.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002-2019, the original author or authors.
2+
* Copyright (c) 2002-2023, the original author or authors.
33
*
44
* This software is distributable under the BSD license. See the terms of the
55
* BSD license in the documentation provided with this software.
@@ -170,6 +170,9 @@ public void setAttributes(Attributes attr) {
170170

171171
protected void updateConsoleMode() {
172172
int mode = ENABLE_WINDOW_INPUT;
173+
if (attributes.getLocalFlag(Attributes.LocalFlag.ISIG)) {
174+
mode |= ENABLE_PROCESSED_INPUT;
175+
}
173176
if (attributes.getLocalFlag(Attributes.LocalFlag.ECHO)) {
174177
mode |= ENABLE_ECHO_INPUT;
175178
}

0 commit comments

Comments
 (0)
Please sign in to comment.