diff --git a/src/modules/punk/console-999999.0a1.0.tm b/src/modules/punk/console-999999.0a1.0.tm index 91da0e00..08b01437 100644 --- a/src/modules/punk/console-999999.0a1.0.tm +++ b/src/modules/punk/console-999999.0a1.0.tm @@ -31,6 +31,9 @@ if {"windows" eq $::tcl_platform(platform)} { # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ namespace eval punk::console { variable has_twapi 0 + variable previous_stty_state_stdin "" + variable previous_stty_state_stdout "" + variable previous_stty_state_stderr "" #punk::console namespace - contains *directly* acting functions - some based on ansi escapes from the 'ansi' sub namespace, some on local system calls or executable calls wrapped in the 'local' sub namespace #directly acting means they write to stdout to cause the console to peform the action, or they perform the action immediately via other means. @@ -72,13 +75,26 @@ namespace eval punk::console { proc enableAnsi {} { #todo? } + + #todo - something better proc enableRaw {{channel stdin}} { + variable previous_stty_state_$channel set sttycmd [auto_execok stty] + set previous_stty_state_$channel [exec {*}$sttycmd -g <@$channel] + exec {*}$sttycmd raw -echo <@$channel + return [dict create previous $previous_stty_state_$channel] } proc disableRaw {{channel stdin}} { + variable previous_stty_state_$channel set sttycmd [auto_execok stty] + if {[set previous_stty_state_$channel] ne ""} { + exec {*}$sttycmd [set previous_stty_state_$channel] + set previous_stty_state_$channel "" + return restored + } exec {*}$sttycmd raw echo <@$channel + return done } }