aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2025-10-28 14:20:28 +0100
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2026-02-08 12:44:07 +0100
commit456f9b17edd7104ebd6d938aa565b59023be7f2d (patch)
tree74ec71322d10e38f831ef454c83adda0e52d26dc
parent02477b25264659f10889ce84e57a6603d9d613a2 (diff)
`core:os` -> `core:os/os2` in `core:terminal`
-rw-r--r--core/terminal/terminal.odin8
-rw-r--r--core/terminal/terminal_js.odin4
-rw-r--r--core/terminal/terminal_posix.odin13
-rw-r--r--core/terminal/terminal_windows.odin12
4 files changed, 20 insertions, 17 deletions
diff --git a/core/terminal/terminal.odin b/core/terminal/terminal.odin
index 37fdaff36..d24b963d3 100644
--- a/core/terminal/terminal.odin
+++ b/core/terminal/terminal.odin
@@ -1,7 +1,7 @@
// Interaction with the command line interface (`CLI`) of the system.
package terminal
-import "core:os"
+import os "core:os/os2"
/*
This describes the range of colors that a terminal is capable of supporting.
@@ -15,14 +15,14 @@ Color_Depth :: enum {
}
/*
-Returns true if the file `handle` is attached to a terminal.
+Returns true if the `File` is attached to a terminal.
This is normally true for `os.stdout` and `os.stderr` unless they are
redirected to a file.
*/
@(require_results)
-is_terminal :: proc(handle: os.Handle) -> bool {
- return _is_terminal(handle)
+is_terminal :: proc(f: ^os.File) -> bool {
+ return _is_terminal(f)
}
/*
diff --git a/core/terminal/terminal_js.odin b/core/terminal/terminal_js.odin
index 4dcd4465e..78c6c240f 100644
--- a/core/terminal/terminal_js.odin
+++ b/core/terminal/terminal_js.odin
@@ -2,9 +2,7 @@
#+build js
package terminal
-import "core:os"
-
-_is_terminal :: proc "contextless" (handle: os.Handle) -> bool {
+_is_terminal :: proc "contextless" (handle: any) -> bool {
return true
}
diff --git a/core/terminal/terminal_posix.odin b/core/terminal/terminal_posix.odin
index 8d96dd256..341b9084b 100644
--- a/core/terminal/terminal_posix.odin
+++ b/core/terminal/terminal_posix.odin
@@ -2,12 +2,15 @@
#+build linux, darwin, netbsd, openbsd, freebsd, haiku
package terminal
-import "base:runtime"
-import "core:os"
-import "core:sys/posix"
+import "base:runtime"
+import os "core:os/os2"
+import "core:sys/posix"
-_is_terminal :: proc "contextless" (handle: os.Handle) -> bool {
- return bool(posix.isatty(posix.FD(handle)))
+_is_terminal :: proc "contextless" (f: ^os.File) -> bool {
+ context = runtime.default_context()
+ fd := os.fd(f)
+ is_tty := posix.isatty(posix.FD(fd))
+ return bool(is_tty)
}
_init_terminal :: proc "contextless" () {
diff --git a/core/terminal/terminal_windows.odin b/core/terminal/terminal_windows.odin
index 6d5f98a1f..d1ade13f3 100644
--- a/core/terminal/terminal_windows.odin
+++ b/core/terminal/terminal_windows.odin
@@ -1,12 +1,14 @@
#+private
package terminal
-import "base:runtime"
-import "core:os"
-import "core:sys/windows"
+import "base:runtime"
+import os "core:os/os2"
+import "core:sys/windows"
-_is_terminal :: proc "contextless" (handle: os.Handle) -> bool {
- is_tty := windows.GetFileType(windows.HANDLE(handle)) == windows.FILE_TYPE_CHAR
+_is_terminal :: proc "contextless" (f: ^os.File) -> bool {
+ context = runtime.default_context()
+ fd := os.fd(f)
+ is_tty := windows.GetFileType(windows.HANDLE(fd)) == windows.FILE_TYPE_CHAR
return is_tty
}