Browse Source

another attempt at fixing enableRaw/disableRaw on unix

master
Julian Noble 10 months ago
parent
commit
e26f84228b
  1. 11
      src/modules/punk/console-999999.0a1.0.tm

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

@ -59,6 +59,7 @@ namespace eval punk::console {
internal::abort_if_loop internal::abort_if_loop
tailcall enableAnsi tailcall enableAnsi
} }
#review what raw mode means with regard to a specific channel vs terminal as a whole
proc enableRaw {{channel stdin}} { proc enableRaw {{channel stdin}} {
#loopavoidancetoken (don't remove) #loopavoidancetoken (don't remove)
internal::define_windows_procs internal::define_windows_procs
@ -76,14 +77,16 @@ namespace eval punk::console {
#todo? #todo?
} }
#todo - something better #todo - something better - the 'channel' concept may not really apply on unix, as raw mode is for input and output modes
proc enableRaw {{channel stdin}} { proc enableRaw {{channel stdin}} {
variable previous_stty_state_$channel variable previous_stty_state_$channel
set sttycmd [auto_execok stty] set sttycmd [auto_execok stty]
set previous_stty_state_$channel [exec {*}$sttycmd -g <@$channel] if {[set previous_stty_state_$channel] eq ""} {
set previous_stty_state_$channel [exec {*}$sttycmd -g <@$channel]
}
exec {*}$sttycmd raw -echo <@$channel exec {*}$sttycmd raw -echo <@$channel
return [dict create previous $previous_stty_state_$channel] return [dict create previous [set previous_stty_state_$channel]]
} }
proc disableRaw {{channel stdin}} { proc disableRaw {{channel stdin}} {
variable previous_stty_state_$channel variable previous_stty_state_$channel
@ -93,7 +96,7 @@ namespace eval punk::console {
set previous_stty_state_$channel "" set previous_stty_state_$channel ""
return restored return restored
} }
exec {*}$sttycmd raw echo <@$channel exec {*}$sttycmd -raw echo <@$channel
return done return done
} }
} }

Loading…
Cancel
Save