You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/specs/stdlib_system.md
+22-7Lines changed: 22 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -533,17 +533,21 @@ The file is removed from the filesystem if the operation is successful. If the o
533
533
{!example/system/example_delete_file.f90!}
534
534
```
535
535
536
-
## `get_terminal_size` - Get the size of the terminal window
536
+
## `get_terminal_size` - Get terminal window size in characters
537
537
538
538
### Status
539
539
540
540
Experimental
541
541
542
542
### Description
543
543
544
-
This subroutine returns the size of the terminal window in characters.
544
+
Queries the terminal window size in characters (columns × lines).
545
545
546
-
Note: This routine performs a detailed runtime inspection, so it has non-negligible overhead.
546
+
This routine performs the following checks:
547
+
1. Verifies stdout is connected to a terminal (not redirected);
548
+
2. Queries terminal dimensions via platform-specific APIs.
549
+
550
+
Typical execution time: <100μs on modern systems.
547
551
548
552
### Syntax
549
553
@@ -555,13 +559,24 @@ Subroutine
555
559
556
560
### Arguments
557
561
558
-
`columns`: Shall be an `intent(out)` argument of type `integer` that will contain the number of columns in the terminal window.
562
+
`columns`: `integer, intent(out)`.
563
+
Number of columns in the terminal window. Set to `-1` on error.
564
+
565
+
`lines`: `integer, intent(out)`.
566
+
Number of lines in the terminal window. Set to `-1` on error.
559
567
560
-
`lines`: Shall be an `intent(out)` argument of type `integer` that will contain the number of lines in the terminal window.
568
+
`err`: `type(state_type), intent(out), optional`.
569
+
Error state object. If absent, errors terminate execution.
561
570
562
-
`err`: Shall be an `intent(out)` and `optional` argument of type `type(state_type)` that will contain the error state. If not provided, the program stops execution on error.
571
+
### Error Handling
563
572
564
-
Note: If the query fails, the values of `columns` and `lines` will be set to `-1`.
573
+
-**Success**: `columns` and `lines` contain valid dimensions.
574
+
-**Failure**:
575
+
- Both arguments set to `-1`.
576
+
- If `err` present, `stat` contains error code:
577
+
- Unix: Contains `errno` (typically `ENOTTY` when redirected);
578
+
- Windows: Contains `GetLastError()` code.
579
+
- If `err` absent: Program stops with error message.
0 commit comments