@@ -33,8 +33,8 @@ public final class FfmWindowsTerminal implements Terminal {
3333 private final MemorySegment inputRecord ;
3434 private final MemorySegment intBuffer ;
3535
36- private final int savedInputMode ;
37- private final int savedOutputMode ;
36+ private int savedInputMode ;
37+ private int savedOutputMode ;
3838 private boolean rawModeEnabled ;
3939 private volatile Consumer <Size > resizeHandler ;
4040
@@ -59,28 +59,26 @@ public FfmWindowsTerminal() throws IOException {
5959 inputRecord = arena .allocate (Kernel32 .INPUT_RECORD_LAYOUT );
6060 intBuffer = arena .allocate (ValueLayout .JAVA_INT );
6161
62+ rawModeEnabled = false ;
63+ }
64+
65+ @ Override
66+ public void enableRawMode () throws IOException {
67+ if (rawModeEnabled ) {
68+ return ;
69+ }
70+
6271 // Save original console modes
6372 if (Kernel32 .getConsoleMode (inputHandle , intBuffer ) == 0 ) {
64- arena .close ();
6573 throw new RuntimeException ("Failed to get input console mode" );
6674 }
6775 savedInputMode = intBuffer .get (ValueLayout .JAVA_INT , 0 );
6876
6977 if (Kernel32 .getConsoleMode (outputHandle , intBuffer ) == 0 ) {
70- arena .close ();
7178 throw new RuntimeException ("Failed to get output console mode" );
7279 }
7380 savedOutputMode = intBuffer .get (ValueLayout .JAVA_INT , 0 );
7481
75- rawModeEnabled = false ;
76- }
77-
78- @ Override
79- public void enableRawMode () throws IOException {
80- if (rawModeEnabled ) {
81- return ;
82- }
83-
8482 // Set input mode: disable line input, echo, and processed input; enable VT input
8583 var newInputMode =
8684 savedInputMode
0 commit comments