📄 automsg.tcl
字号:
::plugins::PostEvent ChangeMyState evPar } else { status_log "ChCustomState where state didnt exist !!!" red } CreateStatesMenu .my_menu if { [info exists automsgsent] } { unset automsgsent } if { $redraw == 1 } { cmsn_draw_online 0 1 }}#///////////////////////////////////////////////////////////////////////////////# EditNewState ( mode {idx} )# GUI frontend for adding new states or editing old states# mode is 0 for adding new one, no need for idx in this case# mode is 1 for adding a temporary state# mode is 2 for editing an old state, need to give idx of state to editproc EditNewState { mode { idx "" } } { global chstate variable stemp if { $mode == 2 } { if { $idx != "" } { if { [StateList get $idx] == 0 } { status_log "Opened EditNewState with invalid idx : $idx\n" return 0 } } else { status_log "Called EditNewState mode 2 no idx\n" return 0 } } if {[winfo exists .editstate]} { raise .editstate return 0 } ::skin::setPixmap prefaway [file join [::skin::GetSkinFile pixmaps prefaway.gif]] toplevel .editstate #wm group .editstate . #wm geometry .editstate if { $mode == 0 || $mode == 1 } { wm title .editstate "[trans editnewstate]" } else { wm title .editstate "[trans editstate]" } #ShowTransient .editstate set lfname [labelframe .editstate.lfname -text [trans stateinfo] -font splainf] #pack $lfname -anchor n -side top -expand 1 -fill x frame .editstate.1 -class Degt label .editstate.1.away -image [::skin::loadPixmap prefaway] pack .editstate.1.away -side left -anchor nw if { $mode == 0 || $mode == 1 } { label .editstate.1.laway -text [trans statenewtext] -padx 10 -justify left -font splainf } else { label .editstate.1.laway -text [trans stateedittext] -padx 10 -justify left -font splainf } pack .editstate.1.laway -fill both -side left label $lfname.ldesc -text "[trans statename] :" -font splainf entry $lfname.edesc -bg #FFFFFF -font splainf -width 40 label $lfname.lnick -text "[trans statenick] :" -font splainf entry $lfname.enick -bg #FFFFFF -font splainf -width 40 menubutton $lfname.nickhelp -font sboldf -text "<-" -menu $lfname.nickhelp.menu menu $lfname.nickhelp.menu -tearoff 0 $lfname.nickhelp.menu add command -label [trans nick] -command "$lfname.enick insert insert \\\$nick" $lfname.nickhelp.menu add separator $lfname.nickhelp.menu add command -label [trans delete] -command "$lfname.enick delete 0 end" label $lfname.lpsm -text "[trans statepsm] :" -font splainf entry $lfname.epsm -bg #FFFFFF -font splainf -width 40 menubutton $lfname.psmhelp -font sboldf -text "<-" -menu $lfname.psmhelp.menu menu $lfname.psmhelp.menu -tearoff 0 $lfname.psmhelp.menu add command -label [trans psm] -command "$lfname.epsm insert insert \\\$psm" $lfname.psmhelp.menu add separator $lfname.psmhelp.menu add command -label [trans delete] -command "$lfname.epsm delete 0 end" label $lfname.lstate -text "[trans state] :" -font splainf combobox::combobox $lfname.statebox -editable false -highlightthickness 0 -width 37 -bg #FFFFFF -font splainf -command "" label $lfname.lmsg -text "[trans stateautomsg] :" -font splainf text $lfname.emsg -background white -borderwidth 2 -relief ridge -width 40 -height 5 -font splainf set msgcopypastemenu [CreateCopyPasteMenu $lfname.emsg] bind $lfname.emsg <Button3-ButtonRelease> "tk_popup $msgcopypastemenu %X %Y" pack .editstate.1 -expand false -fill x -side top -pady 15 pack .editstate.lfname -expand 1 -fill both -side top grid $lfname.ldesc -row 1 -column 1 -sticky w -pady 5 -padx 5 grid $lfname.edesc -row 1 -column 2 -sticky w -pady 5 -padx 5 grid $lfname.lnick -row 2 -column 1 -sticky w -pady 5 -padx 5 grid $lfname.enick -row 2 -column 2 -sticky w -pady 5 -padx 5 grid $lfname.nickhelp -row 2 -column 3 -sticky w -pady 5 -padx 5 if { [::config::getKey protocol] == 11 } { grid $lfname.lpsm -row 3 -column 1 -sticky w -pady 5 -padx 5 grid $lfname.epsm -row 3 -column 2 -sticky w -pady 5 -padx 5 grid $lfname.psmhelp -row 3 -column 3 -sticky w -pady 5 -padx 5 grid $lfname.lstate -row 4 -column 1 -sticky w -pady 5 -padx 5 grid $lfname.statebox -row 4 -column 2 -sticky w -pady 5 -padx 5 grid $lfname.lmsg -row 5 -column 1 -sticky nw -pady 10 -padx 5 grid $lfname.emsg -row 5 -column 2 -sticky w -pady 10 -padx 5 } else { grid $lfname.lstate -row 3 -column 1 -sticky w -pady 5 -padx 5 grid $lfname.statebox -row 3 -column 2 -sticky w -pady 5 -padx 5 grid $lfname.lmsg -row 4 -column 1 -sticky nw -pady 10 -padx 5 grid $lfname.emsg -row 4 -column 2 -sticky w -pady 10 -padx 5 } #Frame for options frame .editstate.options -class Degt if { $mode != 2 } { set stemp 0 checkbutton .editstate.options.stemp -text "[trans temp_state]" -onvalue 1 -offvalue 0 -font sboldf -variable stemp pack .editstate.options.stemp -anchor w -side top -padx 10 -pady 0 } elseif { $mode == 2 } { set stemp 2 } if { [info exists chstate] } { unset chstate } checkbutton .editstate.options.chstate -text "[trans ch_to_state]" -onvalue 1 -offvalue 0 -font sboldf pack .editstate.options.chstate -anchor w -side top -padx 10 -pady 0 pack .editstate.options -fill both -side top # Frame for buttons frame .editstate.buttons -class Degt button .editstate.buttons.cancel -text [trans cancel] -command "destroy .editstate" # Insert states in the combobox eval $lfname.statebox list insert end [list [trans online] \ [trans noactivity] \ [trans rightback] \ [trans onphone] \ [trans busy] \ [trans away] \ [trans gonelunch]] # select online in combobox by default $lfname.statebox select 0 # Fill all entries if editing an existing state if { $mode == 2 } { $lfname.edesc insert end [lindex [StateList get $idx] 0] $lfname.enick insert end [lindex [StateList get $idx] 1] $lfname.statebox select [lindex [StateList get $idx] 2] $lfname.emsg insert end [lindex [StateList get $idx] 4] $lfname.epsm insert end [lindex [StateList get $idx] 5] } #else { # $lfname.enick insert end [::abook::getPersonal MFN] #} button .editstate.buttons.save -text [trans ok] -command "ButtonSaveState $lfname $idx; destroy .editstate" -default active pack .editstate.buttons.save .editstate.buttons.cancel -side right -padx 10 -pady 5 pack .editstate.buttons -side top -fill x -pady 10 moveinscreen .editstate catch {focus .editstate}}#///////////////////////////////////////////////////////////////////////////////# CreateCopyPasteMenu ( w )# Returns a menu with Cut - Copy - Paste commandsproc CreateCopyPasteMenu { w } { set menu $w.copypaste menu $menu -tearoff 0 -type normal $menu add command -label [trans cut] \ -command "status_log cut\n;tk_textCut $w" $menu add command -label [trans copy] \ -command "status_log copy\n;tk_textCopy $w" $menu add command -label [trans paste] \ -command "status_log pasteHere\n;pasteHere $w" return $menu}#///////////////////////////////////////////////////////////////////////proc pasteHere { w } { set contents [ selection get -selection CLIPBOARD ] $w insert insert $contents}#///////////////////////////////////////////////////////////////////////////////# ButtonSaveState ( lfname idx )# GUI frontend for adding new states or editing old states# this procedure is called when save is pressed, so it does what it needs# mode is 0 for adding new one, no need for idx in this case# mode is 1 for adding a temporary state# mode is 2 for editing an old state, need to give idx of state to editproc ButtonSaveState { lfname { idx "" } } { variable stemp set mode $stemp # Global variables for temp status and changin the new state, from checkbutton on EditNewState global chstate lappend gui_info [$lfname.edesc get] lappend gui_info [$lfname.enick get] lappend gui_info [$lfname.statebox curselection] set message [$lfname.emsg get 0.0 end] set message [string range $message 0 end-1] set numlines [llength [split $message "\n"]] lappend gui_info $numlines lappend gui_info $message lappend gui_info [$lfname.epsm get] switch $mode { 0 { StateList add $gui_info if { $chstate == 1 } { ChCustomState [expr {[StateList size] - 1}] } } 1 { StateList add $gui_info ChCustomState [expr {[StateList size] - 1}] StateList unset [expr {[StateList size] - 1}] } 2 { StateList edit $gui_info $idx if { $chstate == 1 } { ChCustomState $idx } } } # reset menus and listbox CreateStatesMenu .my_menu if { ($mode == 0 || $mode == 2) && [winfo exists .cfg] } { set cfgname [[.cfg.notebook.nn getframe session].sw.sf getframe] $cfgname.lfname2.statelist.box delete 0 end for { set idx 0 } { $idx < [StateList size] } {incr idx } { $cfgname.lfname2.statelist.box insert end [lindex [StateList get $idx] 0] } } SaveStateList}#///////////////////////////////////////////////////////////////////////////////# DeleteState ( idx path )# Deletes a state from the listbox in preferences# idx is index of state to deleteproc DeleteState { { idx "" } path} { if { $idx == "" } { return 0 } elseif { $idx >= 2 } { StateList unset $idx if { [winfo exists $path.otherstates.$idx] } { destroy $path.otherstates.$idx } } else { StateList unset $idx if { [winfo exists $path.$idx] } { destroy $path.$idx } } # reset menus and listbox CreateStatesMenu .my_menu}proc DeleteStateListBox { { idx "" } path} { if { $idx == "" } { return 0 } else { StateList unset $idx if { [winfo exists $path] } { $path delete $idx } } # reset menus and listbox CreateStatesMenu .my_menu}#///////////////////////////////////////////////////////////////////////////////# new_state {cstack cdata saved_data cattr saved_attr args}## Adds a new state to the states listproc new_state {cstack cdata saved_data cattr saved_attr args} { upvar $saved_data sdata if { ! [info exists sdata(${cstack}:name)] } { return 0 } if { ! [info exists sdata(${cstack}:state)] } { return 0 } if { ! [info exists sdata(${cstack}:message)] } { return 0 } lappend newstate "$sdata(${cstack}:name)" # This if, for compatibility with previous versions of amsn # that doesn't support custom nicknames per custom status: # If the states:newstate contains :nick, append it to the # matrix, else append "", as a non-change nick if { [info exists sdata(${cstack}:nick)] } { lappend newstate "$sdata(${cstack}:nick)" } else { lappend newstate "" } lappend newstate "$sdata(${cstack}:state)" set message "$sdata(${cstack}:message)" set numlines [llength [split $message "\n"]] lappend newstate $numlines lappend newstate $message if { [info exists sdata(${cstack}:psm)] } { lappend newstate "$sdata(${cstack}:psm)" } StateList add $newstate return 0}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -