From ea7ede93cc7d2e15da60a50428f7f77b53dcf409 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Sun, 21 Sep 2025 15:05:12 -0400 Subject: [PATCH] small fixes and reorg --- ntalk.tcl | 90 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/ntalk.tcl b/ntalk.tcl index 27b6bc54797aef2a2627208eb44b50b59ac2c9c5..ca1ebe73b1fb8d894ee962715f3c30abb359aaab 100755 --- a/ntalk.tcl +++ b/ntalk.tcl @@ -155,6 +155,8 @@ proc sixels2image {sixels} { dict set images "sixel:$sixels" $image dict set images "xbm:$xbm" $image dict set images "image:$image" $sixels + dict set images "image:motd$image" $sixels + dict set images "image:mention$image" $sixels return $image } @@ -201,7 +203,7 @@ make16 ### UI SETUP ### -label .motd +frame .motd frame .foot entry .foot.input @@ -290,7 +292,6 @@ proc setmotd {newmotd} { set motd $newmotd } -setmotd "no MOTD yet! maybe you should send one..." ### USER SIXEL LIBRARY ### @@ -497,48 +498,6 @@ proc recvlines {{bd 0}} { set inrecv 0 } -proc bufpush {line} { - global images motd user - - set tag {} - if {[string first "MOTD:" $line] == 0} { - setmotd [string trim [string range $line 5 end]] - set line "<<< $motd >>>" - set tag motd - } elseif {[string first "MOTD" $line] == 0} { - setmotd [string trim [string range $line 4 end]] - set line "<<< $motd >>>" - set tag motd - } elseif {[regexp "\[^\\w.\]${user}\[^\\w.\]" $line]} { - set tag mention - } - - .buffer configure -state normal - foreach {text image} [parseline $line] { - .buffer insert end $text $tag - - if {$image != {}} { - lassign $image raw image - set image $tag$image - .buffer insert end $raw [concat rawsixel $tag] - .buffer image create end -image $image - .buffer tag add $tag {end -1 chars} - } - } - .buffer insert end "\n" $tag - .buffer configure -state disabled -} -proc bufdown {} { - .buffer yview moveto 1 - update -} -proc bufclear {} { - .buffer configure -state normal - .buffer replace 1.0 end {} - .buffer configure -state disabled - update -} - proc send {line} { sendl "SEND $line" recvl @@ -585,6 +544,49 @@ proc stat {} { ### ACTUAL CLIENT CODE LMAO ### +proc bufpush {line} { + global images motd user + + set tag {} + if {[string first "MOTD:" $line] == 0} { + setmotd [string trim [string range $line 5 end]] + set line "<<< $motd >>>" + set tag motd + } elseif {[string first "MOTD" $line] == 0} { + setmotd [string trim [string range $line 4 end]] + set line "<<< $motd >>>" + set tag motd + } elseif {[regexp "\[^\\w.\]${user}\[^\\w.\]" $line]} { + set tag mention + } + + .buffer configure -state normal + foreach {text image} [parseline $line] { + .buffer insert end $text $tag + + if {$image != {}} { + lassign $image raw image + set image $tag$image + .buffer insert end $raw [concat rawsixel $tag] + .buffer image create end -image $image + .buffer tag add $tag {end -1 chars} + } + } + .buffer insert end "\n" $tag + .buffer configure -state disabled +} +proc bufdown {} { + .buffer yview moveto 1 + update +} +proc bufclear {} { + .buffer configure -state normal + .buffer replace 1.0 end {} + .buffer configure -state disabled + setmotd "no MOTD yet! maybe you should send one..." + update +} + proc sendmsg {msg} { global lastmsg set msgid [send $msg]