~aleteoryx/ntalk

e8d9ffff99726eaf356dd58aead4930c856c25f8 — Aleteoryx 2 months ago 07ec576
sixel menu improvements, MOTD
1 files changed, 33 insertions(+), 11 deletions(-)

M ntalk.tcl
M ntalk.tcl => ntalk.tcl +33 -11
@@ 173,6 173,9 @@ make16

### UI SETUP ###

set motd "no MOTD yet! maybe you should send one..."
label .head -textvariable motd

frame .foot
entry .foot.input
label .foot.msgs -textvariable lastmsg


@@ 187,6 190,7 @@ pack .foot.ppl .foot.sep .foot.msgs -side right
pack .foot.name -side left
pack .foot.input -side bottom -fill x

pack .head -side top
pack .foot -side bottom -fill x
pack .scroll -side right -fill y
pack .buffer -fill both


@@ 205,6 209,7 @@ bind . <Control-R> restart
bind . <Control-s> {.menu.opt invoke "show raw sixel codes"}

.buffer tag configure rawsixel -elide true -foreground DarkSlateGrey
.buffer tag configure motd -foreground DarkGreen -justify center -spacing1 5 -spacing3 5 -underline 1


### MENU ###


@@ 289,13 294,15 @@ proc regensixelmenu {} {
	for {set i 0} {$i < [llength $sixellib]} {incr i} {
		if {[lindex $sixellib $i] == {}} continue
		lassign [lindex $sixellib $i] name data
		set data [list "\\($data)"]
		set name [string trim $name]
		set data [string trim $data]
		set escdata [list "\\($data)"]
		lassign [getsubmenu .menu.sixels $name] menu label
		$menu insert 0 command -label $label -command [subst {
			.foot.input insert insert $data
		$menu insert 0 command -image [sixels2image $data] -hidemargin 1 -command [subst {
			.foot.input insert insert $escdata
		}]
		lassign [getsubmenu .menu.sixels.rm $name] menu label
		$menu insert 0 command -label $label -command [subst {
		$menu insert 0 command -image [sixels2image $data] -hidemargin 1 -command [subst {
			rmsixel $i
		}]
	}


@@ 442,7 449,18 @@ proc recvlines {{bd 0}} {
}

proc bufpush {line} {
	global images
	global images motd

	set tag {}
	if {[string first "MOTD:" $line] == 0} {
		set motd [string trim [string range $line 5 end]]
		set line "<<< $motd >>>"
		set tag motd
	} elseif {[string first "MOTD" $line] == 0} {
		set motd [string trim [string range $line 4 end]]
		set line "<<< $motd >>>"
		set tag motd
	}

	.buffer configure -state normal
	


@@ 450,7 468,7 @@ proc bufpush {line} {
	set idx2 -1
	while {[set idx2 [string first "\\(" $line $idx1]] != -1} {
		# insert the prefix text
		.buffer insert end [string range $line $idx1 $idx2-1]
		.buffer insert end [string range $line $idx1 $idx2-1] $tag

		# get the sixels
		set idx1 $idx2


@@ 464,8 482,8 @@ proc bufpush {line} {
		
		set idx1 [expr {$idx2 + 1}]
	}
	.buffer insert end [string range $line $idx1 end]
	.buffer insert end "\n"
	.buffer insert end [string range $line $idx1 end] $tag
	.buffer insert end "\n" $tag
	
	.buffer configure -state disabled
}


@@ 529,8 547,9 @@ proc stat {} {
proc sendmsg {msg} {
	global lastmsg
	set msgid [send $msg]
	if {$msgid == $lastmsg} {
		bufpush "$msg\n"
	if {$msgid == $lastmsg+1} {
		set lastmsg $msgid
		bufpush "$msg"
		bufdown
	} else { skip }
}


@@ 559,7 578,7 @@ proc n64k_date {} {
### BOOT ###

set lastmsg 0
last [.buffer cget -height]
last 64
stat
after 10000 pollmsgs



@@ 582,6 601,9 @@ bind .foot.input <Return> [concat [bind .foot.input <Return>] ";" {
		{/send *} {
			sendmsg [string range $line 6 end]
		}
		{/motd *} {
			sendmsg "MOTD [string range $line 6 end]"
		}
		/me* {
			sendmsg "${user}[string range $line 3 end]"
		}