~aleteoryx/ntalk

54f5c578573ee15fa33c6726e9a3d1970d56d6fb — Aleteoryx 2 months ago 0218b24
fix a netcode deadlock, add a "copy sixel" menu
1 files changed, 23 insertions(+), 14 deletions(-)

M ntalk.tcl
M ntalk.tcl => ntalk.tcl +23 -14
@@ 397,6 397,11 @@ proc finishsixel {} {


menu .savesixel -tearoff 0
.savesixel add command -label "copy sixel" -command {
	clipboard clear
	clipboard append "\\([dict get $images "image:$clickedimage"])"
	set clickedsixel {}
}
.savesixel add command -label "save sixel..." -command {
	bind . <Button> {}



@@ 585,29 590,33 @@ proc doskip {delay} {

if {[catch {package require Thread}] == 0} { # threading supported!
	set threads 1

	set main [thread::id]

	set nett [thread::create]
	thread::transfer $nett $sok
	thread::send $nett [concat [subst -nocommands {
	set sok $sok
	interp alias {} restart {} thread::send $main restart
	interp alias {} bufdown {} thread::send -async $main bufdown
	interp alias {} bufclear {} thread::send -async $main bufclear
	proc bufpush {x} { thread::send -async $main [list bufpush [set x]] }
	proc setclients {x} { thread::send -async $main [list setclients [set x]] }
	proc setlastmsg {x} {
		global lastmsg
		set lastmsg [set x]
		thread::send -async $main [list setlastmsg [set x]]
	}
	
	thread::send $nett [concat [subst -nocommands {	
		proc restart {} {
			global argv0
			exec [info nameofexecutable] $argv0 &
			exit 0
		}
		set sok $sok
		interp alias {} bufdown {} thread::send -async $main bufdown
		interp alias {} bufclear {} thread::send -async $main bufclear
		proc bufpush {x} { thread::send -async $main [list bufpush [set x]] }
		proc setclients {x} { thread::send -async $main [list setclients [set x]] }
		proc setlastmsg {x} {
			global lastmsg
			set lastmsg [set x]
			thread::send -async $main [list setlastmsg [set x]]
		}
	}] ";" $netcode]


	interp alias {} hist {} thread::send -async $nett hist
	proc pollmsgs {n} [subst -nocommands { thread::send $nett [list pollmsgs [set n]] }]
	proc send {line} [subst -nocommands { thread::send $nett [list send [set line]] }]
	proc pollmsgs {n} [subst -nocommands { thread::send -async $nett [list pollmsgs [set n]] }]
	proc last {n} [subst -nocommands { thread::send -async $nett [list last [set n]] }]
} else {
	set threads 0