From 0218b244007031f85a4059d26f28fd72350fdc15 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Sun, 21 Sep 2025 19:34:16 -0400 Subject: [PATCH] readme update, steal olive's polling logic --- README.md | 15 ++++++++++++--- ntalk.tcl | 30 ++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8c7d7ab6b8f2347eca1af4d617732a03174cc8b2..e43fa0a695a2856a8bdad71c69909a4afc9c65f9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [nanochat][src] utils -see also [neauoire's client][100r] and probably other things +see also [neauoire's client][100r], [olive's client][olive], and probably other things ## `ntalk.sh`: simple nanotalk server @@ -18,11 +18,18 @@ implemented with tail and head and wc. :P requires you have wish(1) installed. -boots to a config file, in which you can set fonts and stuff +the config is just a tcl script. +ntalk boots to a config file editor, in which you can set fonts and stuff the connection is done entirely over $sok, so set that to whatever. -if you want to include e.g. ssl, go ahead. the config file is saved +if you want to include e.g. tcltls, go ahead. the config file is saved to/read from ~/.config/ntalk/cscript.tcl. +right click on any sixel in the chatlog, and you can save it under a custom name. +saved sixels can be accessed through the "sixels" option in the top menu. +slashes are interpreted, so naming one e.g. "faces / :D" will create a submenu called "faces". +sixels are saved to/read from ~/.config/ntalk/cscript.tcl. +each non-empty line stores one sixel, with the first '=' separating the name and the data. + if $cmds is set, it will be used for command parsing. it is inserted into the body of a switch statement, with globbing enabled. you do not need to start your commands with /. if $server is set, it'll be @@ -32,6 +39,7 @@ to see the builtin commands, read the source code. they're torwards the bottom. if tklib is installed, history will be setup on the main input box. +if Thread is installed, netcode will run on a second thread (recommended!!!). Ctrl-Shift-R will restart the client, allowing you to test config changes rapidly. Ctrl-Q exits. @@ -45,3 +53,4 @@ when it was generated and from what server [src]: https://git.phial.org/d6/nanochat [100r]: https://git.sr.ht/~rabbits/nanotalk +[olive]: https://git.sr.ht/~olive/moonchat diff --git a/ntalk.tcl b/ntalk.tcl index 7a65c3cadb103414b4e2378e23f7b53b1fc1cf5f..9ed4473fe22c059b339758d1efe00ac07cf5b9ef 100755 --- a/ntalk.tcl +++ b/ntalk.tcl @@ -14,7 +14,10 @@ proc restart {} { exit 0 } -wm title . ". o ( ntalk ) o ." +proc settitle {title} { + wm title . ". o ( $title ) o ." +} +settitle ntalk tk appname ntalk @@ -467,7 +470,7 @@ fconfigure $sok -translation lf; # dammit set user [string trim $user] .foot.name configure -text "${user}:" -wm title . ". o ( nanochatting on $server ) o ." +settitle "nanochatting on $server" ### NETCODE ### @@ -564,13 +567,19 @@ proc stat {} { setclients $clients } -proc pollmsgs {} { +set pmid {} +proc pollmsgs {delay} { + global inrecv pmid + after cancel $pmid + set pmid [after $delay doskip $delay] +} +proc doskip {delay} { global inrecv if !$inrecv { stat skip } - after 10000 pollmsgs + set pmid [after $delay doskip $delay] } } @@ -596,8 +605,8 @@ if {[catch {package require Thread}] == 0} { # threading supported! }] ";" $netcode] - interp alias {} pollmsgs {} thread::send -async $nett pollmsgs 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 last {n} [subst -nocommands { thread::send -async $nett [list last [set n]] }] } else { @@ -677,7 +686,15 @@ proc n64k_date {} { ### BOOT ### last 64 -pollmsgs +pollmsgs 15000 + +set typingid {} +bind .foot.input { + after cancel $typingid + pollmsgs 3000 + set typingid [after 15000 pollmsgs 15000] +} + bind .foot.input [concat [bind .foot.input ] ";" { set line [.foot.input get] @@ -731,3 +748,4 @@ bind .foot.input [concat [bind .foot.input ] ";" { focus .foot.input +