-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix signal processing on windows, fixes #822
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2023, the original author or authors. | ||
* | ||
* This software is distributable under the BSD license. See the terms of the | ||
* BSD license in the documentation provided with this software. | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
package org.jline.demo; | ||
|
||
import org.jline.terminal.Terminal; | ||
import org.jline.terminal.TerminalBuilder; | ||
|
||
public class TerminalDemo { | ||
|
||
public static void main(String[] args) throws Exception { | ||
try (Terminal terminal = TerminalBuilder.terminal() ) | ||
{ | ||
terminal.enterRawMode(); | ||
|
||
terminal.writer().println("Terminal: " + terminal); | ||
terminal.writer().println("Type characters, which will be echoed to the terminal. Q will also exit this example."); | ||
terminal.writer().println(); | ||
terminal.writer().flush(); | ||
|
||
while (true) { | ||
int c = terminal.reader().read(16); | ||
if (c >= 0) { | ||
terminal.writer().write(c); | ||
terminal.writer().flush(); | ||
|
||
// Use "q" to quit early | ||
if (c == 81 || c == 113) break; | ||
} else { | ||
if (c == -1) break; // Got EOF | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters