See Also edit
- A Message User Agent
- PYK 2014-05-01: initally based on the code below.
Code edit
package require Tk
package require nntp
proc main argv {
global n
set host aioe.cjb.net
pack [panedwindow .p -ori vert] -fill both -expand 1
.p add [frame .x]
pack [scrollbar .x.y -command ".x.l yview"] -fill y -side right
pack [listbox .x.l -yscrollc ".x.y set"] -fill both -expand 1 -side right
set n [nntp::nntp $host]
#$n authinfo $user $password ;#-- not needed for aioe.cjb.net
foreach {num from to group} [$n group comp.lang.tcl] break
for {set i $to} {$i>$to-64} {incr i -1} {
set head [$n head $i]
.x.l insert end [list $i [get Subject: $head] [get From: $head]]
}
bind .x.l <ButtonRelease-1> {fetch .f.t [selection get]}
.p add [frame .f]
pack [scrollbar .f.y -command ".f.t yview"] -fill y -side right
pack [text .f.t -wrap word -yscrollc ".f.y set"\
-padx 5 -pady 3 -height 12 -font {Helvetica 9}] \
-fill both -expand 1 -side right
foreach color {red blue} {.f.t tag configure $color -foreground $color}
display .f.t [$n article $to]
}
proc fetch {w what} {
display $w [$::n article [lindex $what 0]]
}
#-- Extract a field from an article
proc get {what where} {
foreach line $where {
if [string match $what* $line] {
return [string map [list $what ""] $line]
}
}
}
proc display {w article} {
$w delete 1.0 end
$w insert end [get Subject: $article]\n red
$w insert end [get From: $article]\n blue
set inbody 0
foreach line $article {
if $inbody {$w insert end $line\n}
if {$line eq ""} {set inbody 1}
}
}
main $argv
bind . <Escape> {exec wish $argv0 &; exit}
bind . <F1> {console show}
RS 2005-04-01: updated to use a free server that provides comp.lang.tcl - thanks miguel for the hint!rdt I like this little thing. I made a couple of minor changes in two lines (in my copy):
# in main:
# foreach color {red blue} {.f.t tag configure $color -foreground $color ;# becomes:
foreach color {red blue brown4} {.f.t tag configure $color -foreground $color# in display:
# if $inbody {$w insert end $line\n} ;# becomes:
if $inbody {$w insert end $line\n [expr {([regexp {^>+} $line]) ? "brown4" : ""}]}
}escargo: I like this too. One of my modifications is small, but useful. I added a line to the fetch proc to mark the articles that I've read (red implies read).proc fetch {w what} {
.x.l itemconfigure [.x.l curselection] -foreground red
display $w [$::n article [lindex $what 0]]
}RLH: Well why not a very simple way to post as well? : )rdt: Well if you wish to add functionality, how about a popup listbox / entry for the "news group" ?
