forked from mabe02/lanterna
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue#305: Restore terminal on close()
Previously we had to wait for JVM to exit and the shutdown hook to trigger. This also removes the shutdown hook if the terminal is closed manually.
- Loading branch information
Showing
3 changed files
with
93 additions
and
25 deletions.
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
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
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,54 @@ | ||
package com.googlecode.lanterna.issue; | ||
|
||
import com.googlecode.lanterna.terminal.DefaultTerminalFactory; | ||
import com.googlecode.lanterna.terminal.Terminal; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
/** | ||
* Created by martin on 2017-04-15. | ||
*/ | ||
public class Issue305 { | ||
/** | ||
* @param args the command line arguments | ||
*/ | ||
public static void main(String[] args) throws IOException, InterruptedException{ | ||
Terminal terminal = new DefaultTerminalFactory().createTerminal(); | ||
System.out.println("Class: " + terminal.getClass()); | ||
|
||
terminal.close(); | ||
|
||
BufferedReader br = null; | ||
try { | ||
br = new BufferedReader(new InputStreamReader(System.in)); | ||
|
||
while (true) { | ||
|
||
System.out.print("Enter something: "); | ||
String input = br.readLine(); | ||
|
||
if ("q".equals(input)) { | ||
System.out.println("Exit!"); | ||
System.exit(0); | ||
} | ||
|
||
System.out.println("input : " + input); | ||
System.out.println("-----------\n"); | ||
} | ||
|
||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} finally { | ||
if (br != null) { | ||
try { | ||
br.close(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
} | ||
} |