From edcde6bd8d022002e170d856b0541078516e3e30 Mon Sep 17 00:00:00 2001 From: Glavo Date: Fri, 29 Sep 2023 15:24:13 +0800 Subject: [PATCH] Add final modifier --- .../org/fusesource/jansi/ffm/Kernel32.java | 20 +++++++++---------- .../jansi/ffm/WindowsAnsiProcessor.java | 19 ++++-------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/fusesource/jansi/ffm/Kernel32.java b/src/main/java/org/fusesource/jansi/ffm/Kernel32.java index 0baffad0..0cc409ac 100644 --- a/src/main/java/org/fusesource/jansi/ffm/Kernel32.java +++ b/src/main/java/org/fusesource/jansi/ffm/Kernel32.java @@ -410,7 +410,7 @@ static MethodHandle downcallHandle(String name, FunctionDescriptor fdesc) { static final MethodHandle _get_osfhandle$MH = downcallHandle("_get_osfhandle", FunctionDescriptor.of(C_POINTER$LAYOUT, C_INT$LAYOUT)); - public static class INPUT_RECORD { + public static final class INPUT_RECORD { static final MemoryLayout LAYOUT = MemoryLayout.structLayout( ValueLayout.JAVA_SHORT.withName("EventType"), MemoryLayout.unionLayout( @@ -446,7 +446,7 @@ public FOCUS_EVENT_RECORD focusEvent() { } } - public static class MENU_EVENT_RECORD { + public static final class MENU_EVENT_RECORD { static final GroupLayout LAYOUT = MemoryLayout.structLayout(C_DWORD$LAYOUT.withName("dwCommandId")); static final VarHandle COMMAND_ID = varHandle(LAYOUT, "dwCommandId"); @@ -466,7 +466,7 @@ public void commandId(int commandId) { } } - public static class FOCUS_EVENT_RECORD { + public static final class FOCUS_EVENT_RECORD { static final GroupLayout LAYOUT = MemoryLayout.structLayout(C_BOOL$LAYOUT.withName("bSetFocus")); static final VarHandle SET_FOCUS = varHandle(LAYOUT, "bSetFocus"); @@ -490,7 +490,7 @@ public void setFocus(boolean setFocus) { } } - public static class WINDOW_BUFFER_SIZE_RECORD { + public static final class WINDOW_BUFFER_SIZE_RECORD { static final GroupLayout LAYOUT = MemoryLayout.structLayout(COORD.LAYOUT.withName("size")); static final long SIZE_OFFSET = byteOffset(LAYOUT, "size"); @@ -510,7 +510,7 @@ public String toString() { } } - public static class MOUSE_EVENT_RECORD { + public static final class MOUSE_EVENT_RECORD { private static final MemoryLayout LAYOUT = MemoryLayout.structLayout( COORD.LAYOUT.withName("dwMousePosition"), @@ -554,7 +554,7 @@ public String toString() { } } - public static class KEY_EVENT_RECORD { + public static final class KEY_EVENT_RECORD { static final MemoryLayout LAYOUT = MemoryLayout.structLayout( JAVA_INT.withName("bKeyDown"), @@ -616,7 +616,7 @@ public String toString() { } } - public static class CHAR_INFO { + public static final class CHAR_INFO { static final GroupLayout LAYOUT = MemoryLayout.structLayout( MemoryLayout.unionLayout(C_WCHAR$LAYOUT.withName("UnicodeChar"), C_CHAR$LAYOUT.withName("AsciiChar")) @@ -646,7 +646,7 @@ public char unicodeChar() { } } - public static class CONSOLE_SCREEN_BUFFER_INFO { + public static final class CONSOLE_SCREEN_BUFFER_INFO { static final GroupLayout LAYOUT = MemoryLayout.structLayout( COORD.LAYOUT.withName("dwSize"), COORD.LAYOUT.withName("dwCursorPosition"), @@ -697,7 +697,7 @@ public void attributes(short attr) { } } - public static class COORD { + public static final class COORD { static final GroupLayout LAYOUT = MemoryLayout.structLayout(C_SHORT$LAYOUT.withName("x"), C_SHORT$LAYOUT.withName("y")); @@ -745,7 +745,7 @@ public COORD copy(Arena arena) { } } - public static class SMALL_RECT { + public static final class SMALL_RECT { static final GroupLayout LAYOUT = MemoryLayout.structLayout( C_SHORT$LAYOUT.withName("Left"), diff --git a/src/main/java/org/fusesource/jansi/ffm/WindowsAnsiProcessor.java b/src/main/java/org/fusesource/jansi/ffm/WindowsAnsiProcessor.java index bd2b028e..e933ff0a 100644 --- a/src/main/java/org/fusesource/jansi/ffm/WindowsAnsiProcessor.java +++ b/src/main/java/org/fusesource/jansi/ffm/WindowsAnsiProcessor.java @@ -166,14 +166,8 @@ protected void processEraseScreen(int eraseOption) throws IOException { (info.window().bottom() - info.cursorPosition().y()) * info.size().x() + (info.size().x() - info.cursorPosition().x()); - FillConsoleOutputAttribute( - console, - info.attributes(), - lengthToEnd, - info.cursorPosition(), - written); - FillConsoleOutputCharacterW( - console, ' ', lengthToEnd, info.cursorPosition(), written); + FillConsoleOutputAttribute(console, info.attributes(), lengthToEnd, info.cursorPosition(), written); + FillConsoleOutputCharacterW(console, ' ', lengthToEnd, info.cursorPosition(), written); break; default: break; @@ -206,13 +200,8 @@ protected void processEraseLine(int eraseOption) throws IOException { int lengthToLastCol = info.size().x() - info.cursorPosition().x(); FillConsoleOutputAttribute( - console, - info.attributes(), - lengthToLastCol, - info.cursorPosition(), - written); - FillConsoleOutputCharacterW( - console, ' ', lengthToLastCol, info.cursorPosition(), written); + console, info.attributes(), lengthToLastCol, info.cursorPosition(), written); + FillConsoleOutputCharacterW(console, ' ', lengthToLastCol, info.cursorPosition(), written); break; default: break;