This repository was archived by the owner on Apr 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change 11module Fargo.Console
2+
23open System
4+ open System.Runtime .InteropServices
35
46module Native =
5- open System.Runtime .InteropServices
6-
77 let STD_OUTPUT_HANDLE = - 11
88 let ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4 u
99 let DISABLE_NEWLINE_AUTO_RETURN = 8 u
@@ -15,8 +15,8 @@ module Native =
1515 [<DllImport( " kernel32.dll" , SetLastError= true ) >]
1616 extern bool SetConsoleMode( IntPtr hConsoleHandle, uint32 dwMode )
1717
18-
19- let supportVT100 =
18+
19+ let checkWin32VT100 () =
2020 let h = Native.GetStdHandle( Native.STD_ OUTPUT_ HANDLE)
2121 let mutable x = 0 u
2222 let r = Native.GetConsoleMode( h, & x)
@@ -28,6 +28,11 @@ let supportVT100 =
2828 let r = Native.SetConsoleMode( h, x ||| Native.ENABLE_ VIRTUAL_ TERMINAL_ PROCESSING ||| Native.DISABLE_ NEWLINE_ AUTO_ RETURN)
2929 r
3030
31+ let supportVT100 =
32+ RuntimeInformation.IsOSPlatform OSPlatform.Linux ||
33+ RuntimeInformation.IsOSPlatform OSPlatform.OSX ||
34+ checkWin32VT100 ()
35+
3136module Colors =
3237 let esc = " \x1B "
3338 let color n = if supportVT100 then $" {esc}[%d {n}m" else " "
Original file line number Diff line number Diff line change @@ -227,6 +227,7 @@ let ``completion of command on a full token in the middle``() =
227227 complete2 12 " voice select --voice funny"
228228 =! " select"
229229
230-
231-
232-
230+ [<Fact>]
231+ let ``test cross platform support`` () =
232+ let ex = Record.Exception( Action( fun () -> ignore Console.supportVT100))
233+ Assert.Null( ex)
You can’t perform that action at this time.
0 commit comments