From 456f9b17edd7104ebd6d938aa565b59023be7f2d Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Tue, 28 Oct 2025 14:20:28 +0100 Subject: `core:os` -> `core:os/os2` in `core:terminal` --- core/terminal/terminal.odin | 8 ++++---- core/terminal/terminal_js.odin | 4 +--- core/terminal/terminal_posix.odin | 13 ++++++++----- core/terminal/terminal_windows.odin | 12 +++++++----- 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 } -- cgit v1.2.3