~aleteoryx/ntalk

69771445aa1e89955ec38e4cf3b6fb9a8da5538e — Aleteoryx 2 months ago b6945b0
see the sixels
1 files changed, 35 insertions(+), 2 deletions(-)

M ntalk.tcl
M ntalk.tcl => ntalk.tcl +35 -2
@@ 12,6 12,9 @@ proc restart {} {
	exit 0
}

wm title . ".  o  (  ntalk  )  o  ."
tk appname ntalk


### SIXEL LIB ###



@@ 151,6 154,35 @@ if {[catch {package require history}] == 0} {

bind . <Control-q> quit
bind . <Control-R> restart
bind . <Control-s> {.menu.opt invoke "show raw sixel codes"}

.buffer tag configure rawsixel -elide true -foreground DarkSlateGrey


### MENU ###

menu .menu
menu .menu.nt -tearoff 0
menu .menu.opt -tearoff 1

.menu add cascade -label "ntalk" -menu .menu.nt
.menu.nt add command -label "about..." -command {
	tk_dialog .about "about ntalk" \
		"ntalk\nby aleteoryx\nlast updated 2025-09-20" \
		"info" \
		0 okay
}
.menu.nt add separator
.menu.nt add command -label "restart" -command restart -accelerator "Ctrl-Shift-R"
.menu.nt add command -label "quit" -command quit -accelerator "Ctrl-Q"

.menu add cascade -label "options" -menu .menu.opt
.menu.opt add checkbutton -label "show raw sixel codes" \
	-accelerator "Ctrl-s" -variable showsixel -command {
	.buffer tag configure rawsixel -elide [expr {!$showsixel}]
}

. configure -menu .menu


### CONNECTING ###


@@ 179,7 211,7 @@ bind .buffer <Control-Return> {
.buffer mark set insert end
focus .buffer
vwait cscript
bind .buffer <Control-Return> {}
bind . <Control-Return> {}
.buffer configure -state disabled

set fp [open $scriptpath w]


@@ 190,7 222,7 @@ fconfigure $sok -translation lf; # dammit
set user [string trim $user]
.foot.name configure -text "${user}:"

wm title . "nanochatting on $server"
wm title . ".  o  (  nanochatting on $server  )  o  ."


### NETCODE ###


@@ 239,6 271,7 @@ proc bufpush {line} {
		if {$idx2 == -1} break

		# insert them
		.buffer insert end [string range $line $idx1 $idx2] rawsixel
		set image [sixels2image [string range $line $idx1+2 $idx2-1]]
		.buffer image create end -image $image