From 7d142da06236017c26ea877427784e36d0363e7f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 2 Oct 2010 11:32:11 +0100 Subject: [PATCH] ypp-chatlog-alerter: wip --- ypp-chatlog-alerter | 69 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) 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 -- 2.30.2