Browse Source

punk::console enableAnsi for older windows terminals

master
Julian Noble 1 year ago
parent
commit
0efddf4023
  1. 13
      src/modules/punk/console-999999.0a1.0.tm

13
src/modules/punk/console-999999.0a1.0.tm

@ -30,6 +30,10 @@ namespace eval punk::console {
if {"windows" eq $::tcl_platform(platform)} { if {"windows" eq $::tcl_platform(platform)} {
proc enableAnsi {} {
define_windows_procs
tailcall enableAnsi
}
proc enableRaw {{channel stdin}} { proc enableRaw {{channel stdin}} {
define_windows_procs define_windows_procs
tailcall enableRaw $channel tailcall enableRaw $channel
@ -39,6 +43,9 @@ namespace eval punk::console {
tailcall disableRaw $channel tailcall disableRaw $channel
} }
} else { } else {
proc enableAnsi {} {
#todo?
}
proc enableRaw {{channel stdin}} { proc enableRaw {{channel stdin}} {
set sttycmd [auto_execok stty] set sttycmd [auto_execok stty]
exec {*}$sttycmd raw -echo <@$channel exec {*}$sttycmd raw -echo <@$channel
@ -54,6 +61,9 @@ namespace eval punk::console {
if {$loadstate ni [list loading failed]} { if {$loadstate ni [list loading failed]} {
package require twapi ;#should be fast once twapi dll loaded in zzzload thread package require twapi ;#should be fast once twapi dll loaded in zzzload thread
set ::punk::console::has_twapi 1 set ::punk::console::has_twapi 1
proc enableAnsi {} {
twapi::SetConsoleMode [twapi::get_console_handle stdout] 5
}
proc enableRaw {{channel stdin}} { proc enableRaw {{channel stdin}} {
#review - change to modify_console_input_mode #review - change to modify_console_input_mode
set console_handle [twapi::GetStdHandle -10] set console_handle [twapi::GetStdHandle -10]
@ -71,6 +81,9 @@ namespace eval punk::console {
} else { } else {
if {$loadstate eq "failed"} { if {$loadstate eq "failed"} {
puts stderr "punk::console falling back to stty because twapi load 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}} { proc enableRaw {{channel stdin}} {
set sttycmd [auto_execok stty] set sttycmd [auto_execok stty]
exec {*}$sttycmd raw -echo <@$channel exec {*}$sttycmd raw -echo <@$channel

Loading…
Cancel
Save