Browse Source

interim hack for help to use ascii frametype on narrow terminals

master
Julian Noble 3 months ago
parent
commit
a4c97611fd
  1. 26
      src/bootsupport/modules/punk-0.1.tm
  2. 2
      src/bootsupport/modules/punk/ansi-0.1.1.tm
  3. 6
      src/bootsupport/modules/punk/console-0.1.1.tm
  4. 2
      src/bootsupport/modules/punk/du-0.1.0.tm
  5. 2
      src/bootsupport/modules/punk/lib-0.1.6.tm
  6. 29
      src/modules/punk-0.1.tm
  7. 2
      src/modules/punk/ansi-999999.0a1.0.tm
  8. 6
      src/modules/punk/console-999999.0a1.0.tm
  9. 2
      src/modules/punk/du-999999.0a1.0.tm
  10. 2
      src/modules/punk/lib-999999.0a1.0.tm
  11. 2
      src/modules/punk/netbox-999999.0a1.0.tm

26
src/bootsupport/modules/punk-0.1.tm

@ -8428,19 +8428,34 @@ namespace eval punk {
set I [punk::ansi::a+ italic]
set NI [punk::ansi::a+ noitalic]
set sizedict [punk::console::get_size]
set cols [dict get $sizedict columns]
set rows [dict get $sizedict rows]
if {$cols <= 80} {
# Be conservative with frame types on narrow terminals for help.
# an 80x30 terminal is more likely to be an older style terminal and may not have unicode support.
# unicode on a non-unicode terminal is a bad experience - with the frame chars showing as garbage (e.g 3 chars per grapheme).
set frametype ascii
} else {
#unicode
set frametype light
}
# -------------------------------------------------------
set logoblock ""
if {[catch {
package require patternpunk
#lappend chunks [list stderr [>punk . rhs]]
append logoblock [textblock::frame -title "Punk Shell [package provide punk]" -width 29 -checkargs 0 [>punk . banner -title "" -left Tcl -right [package provide Tcl]]]
append logoblock [textblock::frame -type $frametype -title "Punk Shell [package provide punk]" -width 29 -checkargs 0 [>punk . banner -title "" -left Tcl -right [package provide Tcl]]]
}]} {
append logoblock [textblock::frame -title "Punk Shell [package provide punk]" -subtitle "TCL [package provide Tcl]" -width 29 -height 10 -checkargs 0 ""]
append logoblock [textblock::frame -type $frametype -title "Punk Shell [package provide punk]" -subtitle "TCL [package provide Tcl]" -width 29 -height 10 -checkargs 0 ""]
}
set title "[a+ brightgreen] Help System: "
set cmdinfo [list]
lappend cmdinfo [list help "?${I}topic${NI}?" "This help.\nTo see available subitems type:\nhelp topics\n\nFor an unrecognised ${I}topic${NI}\nhelp will look for basic\ninfo for it as a command.\n"]
set t [textblock::class::table new -minwidth 51 -show_seps 0]
$t configure -frametype $frametype
foreach row $cmdinfo {
$t add_row $row
}
@ -8468,6 +8483,7 @@ namespace eval punk {
lappend cmdinfo [list newdir "${I}subdir${NI}..." "make new dir or dirs and show status"]
lappend cmdinfo [list fcat "${I}file ?file?...${NI}" "cat file(s)"]
set t [textblock::class::table new -minwidth 80 -show_seps 0]
$t configure -frametype $frametype
foreach row $cmdinfo {
$t add_row $row
}
@ -8491,6 +8507,7 @@ namespace eval punk {
lappend cmdinfo [list "nn/" "" "go up one namespace"]
lappend cmdinfo [list "newns" "${I}ns${NI}" "make child namespace and switch to it"]
set t [textblock::class::table new -minwidth 80 -show_seps 0]
$t configure -frametype $frametype
foreach row $cmdinfo {
$t add_row $row
}
@ -8513,6 +8530,7 @@ namespace eval punk {
lappend cmdinfo [list eg "${I}cmd${NI} ?${I}subcommand${NI}...?" "Show example from manpage"]
lappend cmdinfo [list corp "${I}proc${NI}" "View proc body and arguments with basic highlighting"]
set t [textblock::class::table new -minwidth 80 -show_seps 0]
$t configure -frametype $frametype
foreach row $cmdinfo {
$t add_row $row
}
@ -8537,6 +8555,7 @@ namespace eval punk {
lappend cmdinfo [list a "?${I}colourcode${NI}...?" "Return ANSI codes (with leading reset)\n e.g puts \"\[a+ purple\]purple\[a Green\]normal on green\[a\]\"\n [a+ purple]purple[a Green]normal on green[a] "]
set t [textblock::class::table new -minwidth 80 -show_seps 0]
$t configure -frametype $frametype
foreach row $cmdinfo {
$t add_row $row
}
@ -8606,6 +8625,7 @@ namespace eval punk {
set usetable 1
if {$usetable} {
set t [textblock::class::table new -show_hseps 0 -show_header 1 -ansiborder_header [a+ web-green]]
$t configure -frametype $frametype
if {"windows" eq $::tcl_platform(platform)} {
#If any env vars have been set to empty string - this is considered a deletion of the variable on windows.
#The Tcl ::env array is linked to the underlying process view of the environment
@ -8634,6 +8654,7 @@ namespace eval punk {
$t destroy
set t [textblock::class::table new -show_hseps 0 -show_header 1 -ansiborder_header [a+ web-green]]
$t configure -frametype $frametype
foreach {v vinfo} $otherenv_config {
if {[info exists ::env($v)]} {
set env_val [set ::env($v)]
@ -8851,6 +8872,7 @@ namespace eval punk {
}]
set t [textblock::class::table new -show_seps 0]
$t configure -frametype $frametype
$t add_column -headers [list "Topic"]
$t add_column
foreach {k v} $topics {

2
src/bootsupport/modules/punk/ansi-0.1.1.tm

@ -6044,6 +6044,7 @@ be as if this was off - ie lone CR.
#[para]These functions will emit the code - but read it in from stdin so that it doesn't display, and then return the row and column as a colon-delimited string or list respectively.
#[para]The punk::ansi::cursor_pos function is used by punk::console::get_cursor_pos and punk::console::get_cursor_pos_list
return \033\[6n
#same as 'tput u7' which just emits CSI 6n to stdout
}
proc cursor_pos_extended {} {
@ -6053,6 +6054,7 @@ be as if this was off - ie lone CR.
}
#DECFRA - Fill rectangular area
#REVIEW - vt100 accepts decimal values 132-126 and 160-255 ("in the current GL or GR in-use table")
#some modern terminals accept and display characters outside this range - but this needs investigation.

6
src/bootsupport/modules/punk/console-0.1.1.tm

@ -1012,6 +1012,7 @@ namespace eval punk::console {
#e.g \033\[46;1R
set capturingregex {(.*)(\x1b\[([0-9]+;[0-9]+)R)$} ;#must capture prefix,entire-response,response-payload
#This is all 'tput u7' does (emits CSI 6n on stdout)
set request "\033\[6n"
set payload [punk::console::internal::get_ansi_response_payload -console $inoutchannels $request $capturingregex]
#some terminals fail to respond properly to \x1b\[6n but do respond to \x1b\[?6n and vice-versa :/
@ -1021,6 +1022,9 @@ namespace eval punk::console {
return $payload
}
proc get_checksum_rect {id page t l b r {inoutchannels {stdin stdout}}} {
#e.g \x1b\[P44!~E797\x1b\\
#re e.g {(.*)(\x1b\[P44!~([[:alnum:]])\x1b\[\\)$}
@ -1295,7 +1299,7 @@ namespace eval punk::console {
default {set keyboard_name "unknown"}
}
return [dict create {*} {
return [dict create {*}{
} class $class_name {*}{
} version $version {*}{
} keyboard $keyboard_name {*}{

2
src/bootsupport/modules/punk/du-0.1.0.tm

@ -1641,7 +1641,7 @@ namespace eval punk::du {
#convert time from windows (100ns units since jan 1, 1601) to Tcl time (seconds since Jan 1, 1970)
#We lose some precision by not passing the boolean to the large_system_time_to_secs_since_1970 function which returns fractional seconds
#but we need to maintain compatibility with other platforms and other tcl functions so if we want to return more precise times we will need another flag and/or result dict
dict set alltimes $fullname [dict create {*} {
dict set alltimes $fullname [dict create {*}{
} c [twapi::large_system_time_to_secs_since_1970 [dict get $iteminfo ctime]] {*}{
} a [twapi::large_system_time_to_secs_since_1970 [dict get $iteminfo atime]] {*}{
} m [twapi::large_system_time_to_secs_since_1970 [dict get $iteminfo mtime]] {*}{

2
src/bootsupport/modules/punk/lib-0.1.6.tm

@ -2501,7 +2501,7 @@ namespace eval punk::lib {
#no parse tree - This is likely for an empty argument with expansion e.g {*}{ }
#This construct occurs when using {*} in place of line continuation for long lists or dicts, e.g
#dict create {*}{
# } key1 $dynamic {*} {
# } key1 $dynamic {*}{
# key2 value2
#}
#review - the 'empty' argument will still have an entry in cmdlineranges - as although 'empty' in terms of how it expands it may be whitespace across multiple lines.

29
src/modules/punk-0.1.tm

@ -8428,19 +8428,37 @@ namespace eval punk {
set I [punk::ansi::a+ italic]
set NI [punk::ansi::a+ noitalic]
set sizedict [punk::console::get_size]
set cols [dict get $sizedict columns]
set rows [dict get $sizedict rows]
#todo - provide a mechanism to configure the default frametype everywhere and describe it in this help.
if {$cols <= 80} {
# Be conservative with frame types on narrow terminals for help.
# an 80x30 terminal is more likely to be an older style terminal and may not have unicode support.
# unicode on a non-unicode terminal is a bad experience - with the frame chars showing as garbage (e.g 3 chars per grapheme).
set frametype ascii
} else {
#unicode
set frametype light
}
# -------------------------------------------------------
set logoblock ""
if {[catch {
package require patternpunk
#lappend chunks [list stderr [>punk . rhs]]
append logoblock [textblock::frame -title "Punk Shell [package provide punk]" -width 29 -checkargs 0 [>punk . banner -title "" -left Tcl -right [package provide Tcl]]]
append logoblock [textblock::frame -type $frametype -title "Punk Shell [package provide punk]" -width 29 -checkargs 0 [>punk . banner -title "" -left Tcl -right [package provide Tcl]]]
}]} {
append logoblock [textblock::frame -title "Punk Shell [package provide punk]" -subtitle "TCL [package provide Tcl]" -width 29 -height 10 -checkargs 0 ""]
append logoblock [textblock::frame -type $frametype -title "Punk Shell [package provide punk]" -subtitle "TCL [package provide Tcl]" -width 29 -height 10 -checkargs 0 ""]
}
set title "[a+ brightgreen] Help System: "
set cmdinfo [list]
lappend cmdinfo [list help "?${I}topic${NI}?" "This help.\nTo see available subitems type:\nhelp topics\n\nFor an unrecognised ${I}topic${NI}\nhelp will look for basic\ninfo for it as a command.\n"]
set t [textblock::class::table new -minwidth 51 -show_seps 0]
$t configure -frametype $frametype
foreach row $cmdinfo {
$t add_row $row
}
@ -8468,6 +8486,7 @@ namespace eval punk {
lappend cmdinfo [list newdir "${I}subdir${NI}..." "make new dir or dirs and show status"]
lappend cmdinfo [list fcat "${I}file ?file?...${NI}" "cat file(s)"]
set t [textblock::class::table new -minwidth 80 -show_seps 0]
$t configure -frametype $frametype
foreach row $cmdinfo {
$t add_row $row
}
@ -8491,6 +8510,7 @@ namespace eval punk {
lappend cmdinfo [list "nn/" "" "go up one namespace"]
lappend cmdinfo [list "newns" "${I}ns${NI}" "make child namespace and switch to it"]
set t [textblock::class::table new -minwidth 80 -show_seps 0]
$t configure -frametype $frametype
foreach row $cmdinfo {
$t add_row $row
}
@ -8513,6 +8533,7 @@ namespace eval punk {
lappend cmdinfo [list eg "${I}cmd${NI} ?${I}subcommand${NI}...?" "Show example from manpage"]
lappend cmdinfo [list corp "${I}proc${NI}" "View proc body and arguments with basic highlighting"]
set t [textblock::class::table new -minwidth 80 -show_seps 0]
$t configure -frametype $frametype
foreach row $cmdinfo {
$t add_row $row
}
@ -8537,6 +8558,7 @@ namespace eval punk {
lappend cmdinfo [list a "?${I}colourcode${NI}...?" "Return ANSI codes (with leading reset)\n e.g puts \"\[a+ purple\]purple\[a Green\]normal on green\[a\]\"\n [a+ purple]purple[a Green]normal on green[a] "]
set t [textblock::class::table new -minwidth 80 -show_seps 0]
$t configure -frametype $frametype
foreach row $cmdinfo {
$t add_row $row
}
@ -8606,6 +8628,7 @@ namespace eval punk {
set usetable 1
if {$usetable} {
set t [textblock::class::table new -show_hseps 0 -show_header 1 -ansiborder_header [a+ web-green]]
$t configure -frametype $frametype
if {"windows" eq $::tcl_platform(platform)} {
#If any env vars have been set to empty string - this is considered a deletion of the variable on windows.
#The Tcl ::env array is linked to the underlying process view of the environment
@ -8634,6 +8657,7 @@ namespace eval punk {
$t destroy
set t [textblock::class::table new -show_hseps 0 -show_header 1 -ansiborder_header [a+ web-green]]
$t configure -frametype $frametype
foreach {v vinfo} $otherenv_config {
if {[info exists ::env($v)]} {
set env_val [set ::env($v)]
@ -8851,6 +8875,7 @@ namespace eval punk {
}]
set t [textblock::class::table new -show_seps 0]
$t configure -frametype $frametype
$t add_column -headers [list "Topic"]
$t add_column
foreach {k v} $topics {

2
src/modules/punk/ansi-999999.0a1.0.tm

@ -6044,6 +6044,7 @@ be as if this was off - ie lone CR.
#[para]These functions will emit the code - but read it in from stdin so that it doesn't display, and then return the row and column as a colon-delimited string or list respectively.
#[para]The punk::ansi::cursor_pos function is used by punk::console::get_cursor_pos and punk::console::get_cursor_pos_list
return \033\[6n
#same as 'tput u7' which just emits CSI 6n to stdout
}
proc cursor_pos_extended {} {
@ -6053,6 +6054,7 @@ be as if this was off - ie lone CR.
}
#DECFRA - Fill rectangular area
#REVIEW - vt100 accepts decimal values 132-126 and 160-255 ("in the current GL or GR in-use table")
#some modern terminals accept and display characters outside this range - but this needs investigation.

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

@ -1012,6 +1012,7 @@ namespace eval punk::console {
#e.g \033\[46;1R
set capturingregex {(.*)(\x1b\[([0-9]+;[0-9]+)R)$} ;#must capture prefix,entire-response,response-payload
#This is all 'tput u7' does (emits CSI 6n on stdout)
set request "\033\[6n"
set payload [punk::console::internal::get_ansi_response_payload -console $inoutchannels $request $capturingregex]
#some terminals fail to respond properly to \x1b\[6n but do respond to \x1b\[?6n and vice-versa :/
@ -1021,6 +1022,9 @@ namespace eval punk::console {
return $payload
}
proc get_checksum_rect {id page t l b r {inoutchannels {stdin stdout}}} {
#e.g \x1b\[P44!~E797\x1b\\
#re e.g {(.*)(\x1b\[P44!~([[:alnum:]])\x1b\[\\)$}
@ -1295,7 +1299,7 @@ namespace eval punk::console {
default {set keyboard_name "unknown"}
}
return [dict create {*} {
return [dict create {*}{
} class $class_name {*}{
} version $version {*}{
} keyboard $keyboard_name {*}{

2
src/modules/punk/du-999999.0a1.0.tm

@ -1641,7 +1641,7 @@ namespace eval punk::du {
#convert time from windows (100ns units since jan 1, 1601) to Tcl time (seconds since Jan 1, 1970)
#We lose some precision by not passing the boolean to the large_system_time_to_secs_since_1970 function which returns fractional seconds
#but we need to maintain compatibility with other platforms and other tcl functions so if we want to return more precise times we will need another flag and/or result dict
dict set alltimes $fullname [dict create {*} {
dict set alltimes $fullname [dict create {*}{
} c [twapi::large_system_time_to_secs_since_1970 [dict get $iteminfo ctime]] {*}{
} a [twapi::large_system_time_to_secs_since_1970 [dict get $iteminfo atime]] {*}{
} m [twapi::large_system_time_to_secs_since_1970 [dict get $iteminfo mtime]] {*}{

2
src/modules/punk/lib-999999.0a1.0.tm

@ -2501,7 +2501,7 @@ namespace eval punk::lib {
#no parse tree - This is likely for an empty argument with expansion e.g {*}{ }
#This construct occurs when using {*} in place of line continuation for long lists or dicts, e.g
#dict create {*}{
# } key1 $dynamic {*} {
# } key1 $dynamic {*}{
# key2 value2
#}
#review - the 'empty' argument will still have an entry in cmdlineranges - as although 'empty' in terms of how it expands it may be whitespace across multiple lines.

2
src/modules/punk/netbox-999999.0a1.0.tm

@ -2471,7 +2471,7 @@ tcl::namespace::eval punk::netbox::tenancy {
namespace eval argdoc {
variable PUNKARGS
set DYN_CONTEXTNAMES {${[punk::netbox::api_context_names]}}
lappend PUNKARGS [list {*} {
lappend PUNKARGS [list {*}{
} {
@dynamic
@id -id ::punk::netbox::tenancy::tenants_list

Loading…
Cancel
Save