X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=blobdiff_plain;f=ypp-chatlog-alerter;h=7dea3ac36cc8de35fc0202b819dff6ff50d98794;hp=71a05bb9f209321e998d9258fedd81c4c2ed5a26;hb=7d142da06236017c26ea877427784e36d0363e7f;hpb=fc0aa4015af9e5d1e7f83ac7764841f3c9af4e43 diff --git a/ypp-chatlog-alerter b/ypp-chatlog-alerter index 71a05bb..7dea3ac 100755 --- a/ypp-chatlog-alerter +++ b/ypp-chatlog-alerter @@ -1,5 +1,12 @@ #!/usr/bin/wish +proc manyset {list args} { + foreach val $list var $args { + upvar 1 $var my + set my $val + } +} + set progname ypp-chatlog-alerter menu .mbar -tearoff 0 @@ -32,10 +39,18 @@ switch -exact [tk windowingsystem] { } } +set height 5 + +listbox .t -width 5 -height $height -borderwidth 0 +listbox .p -width 14 -height $height -borderwidth 0 +listbox .m -width 80 -height $height -borderwidth 0 +pack .t .p .m -side left + proc newfile {} { global currentfile defaultfile - set newfile [tk_getOpenFile -multiple 0 -title "Select YPP log to track"] + set newfile [tk_getOpenFile -multiple 0 -initialfile $currentfile \ + -title "Select YPP log to track"] if {![string length $newfile]} return set currentfile $newfile @@ -46,13 +61,61 @@ proc newfile {} { refresh } -set currentfile {} +proc for_ll {varname body} { + upvar 1 $varname l + foreach l {times pirates messages} { + set rc [catch { uplevel 1 $body } emsg] + switch -exact $rc { + 0 { + # ok + } + 4 { + # continue + } + 3 { + # break + return + } + default { + # error, return, etc. + return -code $rc -errorinfo $errorInfo \ + -errorcode $errorCode $emsg + } + } + } +} + +proc retint {} { + global messages + set i 0 + set now [clock seconds] + foreach minfo $messages { + manyset $minfo then pirate msg + set ! +} + +proc init {} { + global currentfile height + global times pirates messages + set currentfile {} + + foreach w {t p m} { .$w delete 0 end } + foreach l {times pirates messages} + for {set i 0} {$i<$height} {incr i} { + lappend times 0 + lappend pirates {} + lappend messages {} + foreach w {t p m} { .$w insert end {} } + } +} proc refresh {} { } +init + if {[file exists $defaultfile]} { source $defaultfile } -listbox .l +refresh