#todo - determine cursor on/off state before the call to restore properly. May only be possible
proc get_size {{inoutchannels {stdin stdout}}} {
lassign $inoutchannels in out
if {[catch {
#some terminals (conemu on windows) scroll the viewport when we make a big move down like this - a move to 1 1 immediately after cursor_save doesn't seem to fix that.
#This issue also occurs when switching back from the alternate screen buffer - so perhaps that needs to be addressed elsewhere.
#faster - but uses cursor_save - which we may want to avoid if calling during another operation which uses cursor save/restore
proc get_size_cursorrestore {} {
if {[catch {
#some terminals (conemu on windows) scroll the viewport when we make a big move down like this - a move to 1 1 immediately after cursor_save doesn't seem to fix that.
#This issue also occurs when switching back from the alternate screen buffer - so perhaps that needs to be addressed elsewhere.
#todo - use these as defaults - provide a way to configure/listen to local events and notify server
variable consolewidth ;#entire console width - checked only at each telnet start for performance reasons (as we don't yet have sigwinch for unix, and on windows we don't yet have an equivalent)
#consolewidth should be about 80 cols wider than the window_cols setting if debug on same screen is to be used. (debug pane on RHS of screen)
#todo - launch a separate telnet server (or something) and allow debugging to a totally separate window that can be monitored with another telnet client - review
#todo - use these as defaults - provide a way to configure/listen to local events and notify server (sigwinch unix, unknown windows)
#puts -nonewline stdout [punk::ansi::cursor_on] ;#Enabling cursor should take account of whether it was enabled before - we don't have that info currently! review
#90
set debug_offset [expr {$consolewidth - $debug_width}]
#puts -nonewline stdout [punk::ansi::cursor_on] ;#Enabling cursor should take account of whether it was enabled before - we don't have that info currently! review
variable consolewidth ;#note - this is not terminal width for the telnet output - which needs to be about 80cols narrower if debug is to be displayed on same screen
set consolewidth [dict get [punk::console::get_size] columns]
if {$debug && $consolewidth-$::punk::basictelnet::window_cols < 80} {
puts stderr "Terminal width not wide enough for debug_window width: 80 + telnet window_cols:$::punk::basictelnet::window_cols"
puts stderr "Turn off debug, or make terminal window wider"
#todo - determine cursor on/off state before the call to restore properly. May only be possible
proc get_size {{inoutchannels {stdin stdout}}} {
lassign $inoutchannels in out
if {[catch {
#some terminals (conemu on windows) scroll the viewport when we make a big move down like this - a move to 1 1 immediately after cursor_save doesn't seem to fix that.
#This issue also occurs when switching back from the alternate screen buffer - so perhaps that needs to be addressed elsewhere.
#faster - but uses cursor_save - which we may want to avoid if calling during another operation which uses cursor save/restore
proc get_size_cursorrestore {} {
if {[catch {
#some terminals (conemu on windows) scroll the viewport when we make a big move down like this - a move to 1 1 immediately after cursor_save doesn't seem to fix that.
#This issue also occurs when switching back from the alternate screen buffer - so perhaps that needs to be addressed elsewhere.
#use non cursorsave versions - cursor save/restore will interfere with any concurrent ansi rendering that uses save/restore - because save/restore is a single item, not a stack.
set debug_offset [[expr {$consolewidth - $debug_width - 2}]]