File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,5 +11,7 @@ A minimal terminal library.
1111## Running examples
1212
1313``` bash
14- ./jbang --java 22+ -R--enable-native-access=ALL-UNNAMED --cp target/miniterm-* .jar src/test/java/examples/TerminalSize.java
14+ ./jbang --java 22+ -R--enable-native-access=ALL-UNNAMED --cp target/miniterm-* .jar src/test/java/examples/PrintKeys.java
15+ ./jbang --java 22+ -R--enable-native-access=ALL-UNNAMED --cp target/miniterm-* .jar src/test/java/examples/PrintSize.java
16+ ./jbang --java 22+ -R--enable-native-access=ALL-UNNAMED --cp target/miniterm-* .jar src/test/java/examples/WatchSize.java
1517```
Original file line number Diff line number Diff line change 33import java .io .IOException ;
44import org .codejive .miniterm .Terminal ;
55
6- public class TerminalSize {
6+ public class PrintSize {
77 public static void main (String [] args ) {
88 try (Terminal terminal = Terminal .create ()) {
99 System .out .println ("Terminal size: " + terminal .getSize ());
Original file line number Diff line number Diff line change 1+ package examples ;
2+
3+ import java .io .IOException ;
4+ import org .codejive .miniterm .Terminal ;
5+
6+ public class WatchSize {
7+ public static void main (String [] args ) {
8+ try (Terminal terminal = Terminal .create ()) {
9+ System .out .println ("Terminal size: " + terminal .getSize ());
10+ terminal .enableRawMode ();
11+ terminal .onResize (size -> System .out .println ("New terminal size: " + size ));
12+ System .out .println ("Try resizing your terminal... (press Ctrl+C to exit)" );
13+ while (true ) {
14+ int key = terminal .read (1000 );
15+ if (key == -1 || key == 3 ) { // Ctrl+C
16+ break ; // End of stream
17+ }
18+ }
19+ } catch (IOException e ) {
20+ e .printStackTrace ();
21+ }
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments