Skip to content

Commit e2cd09c

Browse files
committed
refactor: renamed getSize() to size()
1 parent b2df538 commit e2cd09c

10 files changed

Lines changed: 14 additions & 14 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class Example {
3131
### Get terminal size
3232

3333
```java
34-
var size = terminal.getSize();
34+
var size = terminal.size();
3535
System.out.println("The size of the terminal is " + size);
3636
```
3737

examples/PrintSize.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
public class PrintSize {
77
public static void main(String[] args) {
88
try (Terminal terminal = Terminal.create()) {
9-
System.out.println("Terminal size: " + terminal.getSize());
9+
System.out.println("Terminal size: " + terminal.size());
1010
} catch (IOException e) {
1111
e.printStackTrace();
1212
}

examples/WatchSize.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
public class WatchSize {
77
public static void main(String[] args) {
88
try (Terminal terminal = Terminal.create()) {
9-
System.out.println("Terminal size: " + terminal.getSize());
9+
System.out.println("Terminal size: " + terminal.size());
1010
terminal.enableRawMode();
1111
terminal.onResize(size -> System.out.println("New terminal size: " + size));
1212
System.out.println("Try resizing your terminal... (press Ctrl+C to exit)");

miniterm-ffm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class Example {
2121
### Get terminal size
2222

2323
```java
24-
var size = terminal.getSize();
24+
var size = terminal.size();
2525
System.out.println("The size of the terminal is " + size);
2626
```
2727

miniterm-ffm/src/main/java/org/codejive/miniterm/unix/FfmUnixTerminal.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public void disableRawMode() throws IOException {
260260
* @return the terminal size
261261
* @throws IOException if the size cannot be determined
262262
*/
263-
public Size getSize() throws IOException {
263+
public Size size() throws IOException {
264264
int ioctlResult = LibC.ioctl(ttyFd, LibC.TIOCGWINSZ, winsize);
265265
if (ioctlResult == 0) {
266266
var cols = Short.toUnsignedInt((short) WS_COL.get(winsize, 0L));
@@ -473,7 +473,7 @@ private void checkResizePending() throws IOException {
473473
}
474474
// Call handler outside of lock to avoid deadlock
475475
if (handler != null) {
476-
handler.accept(getSize());
476+
handler.accept(size());
477477
}
478478
}
479479

miniterm-ffm/src/main/java/org/codejive/miniterm/windows/FfmWindowsTerminal.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void disableRawMode() throws IOException {
128128
}
129129

130130
@Override
131-
public Size getSize() throws IOException {
131+
public Size size() throws IOException {
132132
if (Kernel32.getConsoleScreenBufferInfo(outputHandle, screenBufferInfo) == 0) {
133133
throw new RuntimeException(
134134
"Failed to get console screen buffer info (error="
@@ -192,7 +192,7 @@ public int read(int timeoutMs) throws IOException {
192192
} else if (eventType == Kernel32.WINDOW_BUFFER_SIZE_EVENT) {
193193
var handler = resizeHandler;
194194
if (handler != null) {
195-
handler.accept(getSize());
195+
handler.accept(size());
196196
}
197197
}
198198

miniterm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class Example {
1919
### Get terminal size
2020

2121
```java
22-
var size = terminal.getSize();
22+
var size = terminal.size();
2323
System.out.println("The size of the terminal is " + size);
2424
```
2525

miniterm/src/main/java/org/codejive/miniterm/unix/LegacyUnixTerminal.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public void disableRawMode() throws IOException {
142142
}
143143

144144
@Override
145-
public Size getSize() throws IOException {
145+
public Size size() throws IOException {
146146
String result = stty("size").trim();
147147
// Output is "rows cols"
148148
String[] parts = result.split("\\s+");
@@ -407,7 +407,7 @@ public Object invoke(
407407
Consumer<Size> h = self.resizeHandler;
408408
if (h != null) {
409409
try {
410-
h.accept(self.getSize());
410+
h.accept(self.size());
411411
} catch (IOException ignore) {
412412
}
413413
}

miniterm/src/main/java/org/codejive/miniterm/windows/LegacyWindowsTerminal.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void disableRawMode() throws IOException {
103103
}
104104

105105
@Override
106-
public Size getSize() throws IOException {
106+
public Size size() throws IOException {
107107
int[] size = WinConsoleNative.getConsoleSize(OUTPUT_HANDLE);
108108
if (size == null) return new Size(80, 24);
109109
return new Size(size[0], size[1]);
@@ -194,7 +194,7 @@ private void pump() {
194194
Consumer<Size> h = resizeHandler;
195195
if (h != null) {
196196
try {
197-
h.accept(getSize());
197+
h.accept(size());
198198
} catch (IOException ignore) {
199199
}
200200
}

src/main/java/org/codejive/miniterm/TerminalBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public interface TerminalBase extends Appendable, AutoCloseable {
3939
* @return the terminal size
4040
* @throws IOException if the size cannot be determined
4141
*/
42-
Size getSize() throws IOException;
42+
Size size() throws IOException;
4343

4444
/**
4545
* Reads a single character from the terminal with timeout.

0 commit comments

Comments
 (0)