From: Ralph Ronnquist Date: Fri, 7 Jan 2022 10:14:24 +0000 (+1100) Subject: fixes; first version X-Git-Tag: 0.1~5 X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=HEAD;p=rrq%2Fhourglass.git fixes; first version --- diff --git a/sitetool/sitetool.lsp b/sitetool/sitetool.lsp index 19c3e80..22bccd9 100644 --- a/sitetool/sitetool.lsp +++ b/sitetool/sitetool.lsp @@ -24,7 +24,8 @@ (tk:load-tcl "sitetool.tcl") -(while true - (tk:read-loop) - (println (eval-string (or (read-line) (exit)))) - ) +(when nil + (while true + (tk:read-loop) + (println (eval-string (or (read-line) (exit)))) + )) diff --git a/sitetool/sitetool.tcl b/sitetool/sitetool.tcl index ca44957..ede8716 100644 --- a/sitetool/sitetool.tcl +++ b/sitetool/sitetool.tcl @@ -1,16 +1,36 @@ +#!/usr/bin/wish +# Tell newlisp embedding to exit on window close -# Report dimensions -#puts [winfo vrootwidth .] -#puts [winfo vrootheight .] +bind . {puts {newLISP: (exit)}} -wm title . {Hourglass sitetool} -#wm geometry . 600x400 +proc loadsite {} { + set f [open hourglass.conf] + set data [read $f] + close $f + global site + foreach line [split $data \n] { + if [regexp {(\S[^ =]*)\s*=\s*(.*)} $line all key value] { + set site($key) [string trim $value] + } + } +} -## Tell embedding newlisp to (exit) -bind . {puts {newLISP: (exit)}} +loadsite -set count 3 +proc savesite {} { + set f [open hourglass.conf w] + puts saving + global site + foreach key [lsort [array names site]] { + if {$key != ""} { + set v [string trimright $site($key)] + puts "$key = >>>$v<<<" + puts $f "$key = $v" + } + } + close $f +} proc tooltipOn {w name} { if {![winfo exist .balloon]} { @@ -41,9 +61,27 @@ proc tooltipOff {} { } } +proc leaving {w} { + set i [string first value $w] + set k [string replace $w $i [expr $i + 4] name] + set key [$k cget -text] + set value [$w get 1.0 end] + global site + set site($key) $value +} + +# +set count 0 + proc setting {name defval} { global count; + global site; incr count; + if {[array names site $name] != ""} { + set defval "$site($name)" + } else { + set site($name) $defval + } set wname .fr.settings.name$count ; set wvalue .fr.settings.value$count ; set weq .fr.settings.eq$count ; @@ -51,6 +89,7 @@ proc setting {name defval} { label $weq -text { }; text $wvalue -height 1 -wrap none -padx 4 -font sanserif -width 30; $wvalue insert end "$defval"; + bind $wvalue [list leaving $wvalue] grid $wname -row $count -column 0; grid $weq -row $count -column 1; grid $wvalue -row $count -column 2; @@ -59,6 +98,8 @@ proc setting {name defval} { bind $wname {tooltipOff} } +wm title . {Hourglass sitetool} + frame .fr frame .fr.settings grid columnconfigure .fr.settings 0 -weight 1 -uniform A; @@ -83,7 +124,15 @@ setting {ipset.table} {TIMO} setting {wui.port} {1070} setting {wui.passwd} {htpasswd} -button .fr.exit -text "exit" -command {exit} pack .fr.settings -pack .fr.exit -pady 4 + +frame .fr.buttons + +button .fr.buttons.save -text save -command {savesite} +button .fr.buttons.exit -text "done" -command {exit} + +grid .fr.buttons.save -column 0 -row 0 +grid .fr.buttons.exit -column 1 -row 0 +pack .fr.buttons + grid .fr -column 0 -row 0 -sticky w -padx {10 4} -pady {12 0}