From 133ef83a37963e0684f69e86ddae35da29ba573c Mon Sep 17 00:00:00 2001 From: aleteoryx Date: Wed, 6 Nov 2024 15:50:33 -0500 Subject: [PATCH] basic ui things --- main.tcl | 55 +++++++++++------------------------------------------- uiMain.tcl | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 44 deletions(-) create mode 100644 uiMain.tcl diff --git a/main.tcl b/main.tcl index 74f6ceb..7c3c86b 100755 --- a/main.tcl +++ b/main.tcl @@ -1,53 +1,20 @@ #!/bin/env tclsh -lappend auto_path /usr/lib/tcllib1.21 -package require logger -set log [logger::init tclircc] +set path [file dirname [dict get [info frame 0] file]] -source irc.tcl -source cap.tcl +package require Thread +package require logger +set log [logger::init tclircc::main] -puts "connecting to testnet.ergo.chat" -set chan [irc::connect testnet.ergo.chat 6697 1] -#set chan [irc::connect localhost 8000 0] +${log}::info {tclircc 0.0.1 } +${log}::info "running from $path" -irc::handler add $chan * { - ${log}::debug [dict get $dispatch rawmsg] +${log}::debug "starting ui thread" +set ui_thread [thread::create -preserved] +if {[thread::send $ui_thread [list source "$path[file separator]/uiMain.tcl"] result] == 1} { + ${log}::critical "couldn't start ui thread: $result" + exit -1 } -proc nocap {dispatch} { - if {[dict get $dispatch cmd] == "CAP"} { - uplevel #0 {${log}::info "GET TROLLED, CAP BLOCKED"} - return true - } -} - -irc::interceptor add $chan nocap - -#irc::handler add $chan CAP { -# ${log}::debug "parsing cap ls" -# set parsed [cap::parse_msg [dict get $dispatch params]] -# dict for {k v} $parsed { -# if {$k == "caps"} { -# ${log}::debug "$k:" -# dict for {k v} $v { -# ${log}::debug " $k: $v" -# } -# } else { -# ${log}::debug "$k: $v" -# } -# } -#} - -cap::negotiate $chan -cap::support $chan message-tags - -puts [irc::meta get $chan] - -irc::listen on $chan - -#${log}::info "requesting CAPs" -#irc::msg send $chan CAP LS 302 - ${log}::info "entering event loop" vwait nil diff --git a/uiMain.tcl b/uiMain.tcl new file mode 100644 index 0000000..fa2c4a4 --- /dev/null +++ b/uiMain.tcl @@ -0,0 +1,36 @@ +#!/bin/env tclsh + +set path [file dirname [dict get [info frame 0] file]] + +variable toplevel_count 0 + +package require logger +set log [logger::init tclircc::ui] + +${log}::debug "loading tk" +package require Tk +wm withdraw . +# TODO: tray handling + +proc mkToplevel {varname {takefocus 0}} { + variable toplevel_count + upvar $varname window + set window .win$toplevel_count + toplevel $window -takefocus $takefocus + incr toplevel_count + + wm title $window "tclircc - $window" + + menu $window.menu + menu $window.menu.me + $window configure -menu "$window.menu" + + $window.menu add cascade -label "tclircc" -menu $window.menu.me + $window.menu.me add command -label "About" -command { + tk_messageBox -title "About tclircc" \ + -message "tclircc v0.0.1" \ + -detail "by Aleteoryx\nhttps://amehut.dev/~aleteoryx/tclircc\n\nThis software is in the public domain." \ + -type ok } +} + +mkToplevel _ -- 2.45.2