From 0efddf40234d1c07e08b06135fbdffdd1b6b418d Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Mon, 16 Oct 2023 07:00:33 +0000 Subject: [PATCH] punk::console enableAnsi for older windows terminals --- src/modules/punk/console-999999.0a1.0.tm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/modules/punk/console-999999.0a1.0.tm b/src/modules/punk/console-999999.0a1.0.tm index 1167e64a..f8eb6c5d 100644 --- a/src/modules/punk/console-999999.0a1.0.tm +++ b/src/modules/punk/console-999999.0a1.0.tm @@ -30,6 +30,10 @@ namespace eval punk::console { if {"windows" eq $::tcl_platform(platform)} { + proc enableAnsi {} { + define_windows_procs + tailcall enableAnsi + } proc enableRaw {{channel stdin}} { define_windows_procs tailcall enableRaw $channel @@ -39,6 +43,9 @@ namespace eval punk::console { tailcall disableRaw $channel } } else { + proc enableAnsi {} { + #todo? + } proc enableRaw {{channel stdin}} { set sttycmd [auto_execok stty] exec {*}$sttycmd raw -echo <@$channel @@ -54,6 +61,9 @@ namespace eval punk::console { if {$loadstate ni [list loading failed]} { package require twapi ;#should be fast once twapi dll loaded in zzzload thread set ::punk::console::has_twapi 1 + proc enableAnsi {} { + twapi::SetConsoleMode [twapi::get_console_handle stdout] 5 + } proc enableRaw {{channel stdin}} { #review - change to modify_console_input_mode set console_handle [twapi::GetStdHandle -10] @@ -71,6 +81,9 @@ namespace eval punk::console { } else { if {$loadstate eq "failed"} { puts stderr "punk::console falling back to stty because twapi load failed" + proc enableAnsi {} { + puts stderr "punk::console::enableAnsi todo" + } proc enableRaw {{channel stdin}} { set sttycmd [auto_execok stty] exec {*}$sttycmd raw -echo <@$channel