From b7dd0c2f400b9b738c8218b15c6980bfc659c957 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Mon, 22 Sep 2025 21:12:32 -0400 Subject: [PATCH] add servlist --- ntalk.tcl | 244 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 218 insertions(+), 26 deletions(-) diff --git a/ntalk.tcl b/ntalk.tcl index 3407114af617e1f4d848f9118ac7bf9483e0f87b..266e368dbbc94113e5a866e1c65a159492eddc98 100755 --- a/ntalk.tcl +++ b/ntalk.tcl @@ -1,16 +1,20 @@ #!/bin/env wish -set confdir ~/.config/ntalk -set scriptpath "${confdir}/cscript.tcl" +set confdir [file normalize ~/.config/ntalk] +set config "${confdir}/config.tcl" +set scriptdir "${confdir}/cscript" set sixelpath "${confdir}/sixels.txt" file mkdir $confdir proc quit {} {exit 0} -proc restart {} { +proc runself args { global argv0 - exec [info nameofexecutable] $argv0 & + exec [info nameofexecutable] $argv0 {*}$args & +} +proc restart args { + runself {*}$args exit 0 } @@ -202,7 +206,6 @@ proc make16 {} { font configure $font -size $fontsize } } -make16 ### UI SETUP ### @@ -237,8 +240,10 @@ if {[catch {package require history}] == 0} { } } +bind . {if {[list %W] == "."} quit} bind . quit bind . restart +bind . runself bind . {.menu.opt invoke "show raw sixel codes"} .buffer tag configure rawsixel -elide true -foreground DarkSlateGrey @@ -253,15 +258,18 @@ menu .menu.nt -tearoff 0 menu .menu.opt -tearoff 1 menu .menu.sixels -tearoff 1 -title "sixel picker" menu .menu.sixels.rm -tearoff 0 +menu .menu.server -tearoff 0 +menu .menu.server.rm -tearoff 0 .menu add cascade -label "ntalk" -menu .menu.nt .menu.nt add command -label "about ntalk" -command { tk_messageBox -title "about ntalk" \ -message "ntalk\nby aleteoryx" \ - -detail "last updated 2025-09-21" \ + -detail "last updated 2025-09-22" \ -icon "info" } .menu.nt add separator +.menu.nt add command -label "new window" -command runself -accelerator "Ctrl-Shift-N" .menu.nt add command -label "restart" -command restart -accelerator "Ctrl-Shift-R" .menu.nt add command -label "quit" -command quit -accelerator "Ctrl-Q" @@ -269,6 +277,11 @@ menu .menu.sixels.rm -tearoff 0 .menu.sixels add separator .menu.sixels add cascade -label "delete a sixel..." -menu .menu.sixels.rm +.menu add cascade -label "servers" -menu .menu.server +.menu.server add separator +.menu.server add command -label "add a server" -command addserver_open +.menu.server add cascade -label "delete a server..." -menu .menu.server.rm + .menu add cascade -label "options" -menu .menu.opt .menu.opt add checkbutton -label "show raw sixel codes" \ -accelerator "Ctrl-s" -variable showsixel -command { @@ -337,13 +350,15 @@ proc getsubmenu {menu name} { proc regensixelmenu {} { global sixellib - .menu.sixels delete 0 [expr {[.menu.sixels index end]-2}] - .menu.sixels.rm delete 0 end - foreach menu [winfo children .menu.sixels] { - if {$menu == ".menu.sixels.rm"} continue - destroy $menu + if {[.menu.sixels index end] > 2} { + .menu.sixels delete 0 [expr {[.menu.sixels index end]-2}] + .menu.sixels.rm delete 0 end + foreach menu [winfo children .menu.sixels] { + if {$menu == ".menu.sixels.rm"} continue + destroy $menu + } + destroy {*}[winfo children .menu.sixels.rm] } - destroy {*}[winfo children .menu.sixels.rm] for {set i 0} {$i < [llength $sixellib]} {incr i} { if {[lindex $sixellib $i] == {}} continue @@ -405,8 +420,9 @@ menu .savesixel -tearoff 0 .savesixel add command -label "save sixel..." -command { bind .