📄 retrieverpane.tcl
字号:
} set pat ${ptrn} ${this} SetTitle set scopes [retriever_what_to_qry [namespace tail ${this}]] if {${scopes} == ""} { #nothing is selected bell return } #display dialog box set Cancel_Dialog_Id [after 500 "${this} Display_Cancel_Dialog"] incr SearchActive # Block the UI while we search. tixBusy $itk_component(hull) on set oldcmd [${searchbtn} cget -command] set oldstate [${searchbtn} cget -state] set oldtext [${searchbtn} cget -text] set oldund [${searchbtn} cget -underline] ${searchbtn} config -text [get_indep String Cancel]\ -underline [get_indep Pos Cancel] -command " ${this} cancel_fetching " if {[winfo exists ${this}-mixer.button_0]} { ${this}-mixer.button_0 config -text [get_indep String Cancel]\ -command " ${this} cancel_fetching " } update update idletasks #display correct column labels if {${scopes} == "files"} { ${this}.list change_label 0 [get_indep String File] ${this}.list change_label 1 [get_indep String Directory] ${this}.list change_label 2 [get_indep String Type] ${this}.list change_label 3 "" ${this}.list change_label 4 "" ${this}.list toggle_column 0 "" 1 ${this}.list toggle_column 1 "" 1 ${this}.list toggle_column 2 "" 1 ${this}.list toggle_column 3 "" 0 ${this}.list toggle_column 4 "" 0 } else { set type "" set prm "" set class "" foreach s ${scopes} { if {[lsearch -exact ${with_type} ${s}] != -1} { set type [get_indep String Type] } if {[lsearch -exact ${with_param} ${s}] != -1} { set prm [get_indep String Parameters] } if {[lsearch -exact ${with_class} ${s}] != -1} { set class [get_indep String Class] } } if {[string first "files" ${scopes}] != -1} { set dir Directory } else { set dir "" } if {${dir} != "" && ${class} != ""} { set txt [file join ${class} ${dir}] } else { set txt "${class}${dir}" } ${this}.list change_label 0 [get_indep String Name] ${this}.list change_label 1 ${txt} ${this}.list change_label 2 ${type} ${this}.list change_label 3 ${prm} ${this}.list change_label 4 [get_indep String File] if {${txt} == ""} { ${this}.list toggle_column 1 "" 0 } else { ${this}.list toggle_column 1 "" 1 } if {${type} == ""} { ${this}.list toggle_column 2 "" 0 } else { ${this}.list toggle_column 2 "" 1 } if {${prm} == ""} { ${this}.list toggle_column 3 "" 0 } else { ${this}.list toggle_column 3 "" 1 } ${this}.list toggle_column 4 "" 1 } display_contents ${this}.list [read_matched_from_db ${this}.list\ ${scopes} -glob ${pat}] ${this}.list sort_refresh #delete cancel button, if availiable Delete_Cancel_Dialog #to discard the events bound on the buttons update #$searchbtn config -state $oldstate ${searchbtn} config -text ${oldtext} -underline ${oldund}\ -command ${oldcmd} -state normal if {[winfo exists ${this}-mixer.button_0]} { ${this}-mixer.button_0 config -text ${oldtext} -command ${oldcmd}\ -state normal } incr SearchActive -1 # Release the UI back to the user. tixBusy $itk_component(hull) off } method next_entry {amount} { if {[${tree} size] <= 0} { bell return } ${tree} activate [expr [${tree} index active] + ${amount}] ${tree} selection clear 0 end ${tree} see active ${tree} selection set active if {$itk_option(-selectcommand) != ""} { ::eval $itk_option(-selectcommand) [Selection] } else { #emulate double click edit_symbol ${tree} } } method handle_all_none {prefix all} { global sn_scopes upvar #0 ${this}-exclusive excl set excl 0 ${this}-mixer.button_0 config -state normal foreach sc ${sn_scopes} { if {${all}} { if {[info commands paf_db_${sc}] == ""} { set val "" } else { set val ${sc} } } else { set val "" } set ::${prefix}-${sc} ${val} } # Note: The "files" option is not selected by all but # it is deselected by none. if {!$all} { set ::${prefix}-files "" } } method handle_space {} { ${tree} selection clear 0 end ${tree} selection set active if {$itk_option(-selectcommand) != ""} { ::eval $itk_option(-selectcommand) [Selection] } } #Click can toggle a subtree or goto a symbol method handle_click {x y} { set res [Retriever&::expand_classes ${this} ${x} ${y}\ display_contents] if {${res} != "" && $itk_option(-selectcommand) != ""} { ::eval $itk_option(-selectcommand) [Selection] } } method Title {{full 1}} { global sn_options upvar #0 ${this}-pattern ptrn if {${ptrn} == ""} { set ptrn "*" } set t [string trimright ${Retr_Title} "."] if {${mode} != "symbr" && ${ptrn} != ""} { set t "${t}: ${ptrn}" } if {${full}} { return [sn_title ${t}] } else { return ${t} } } method Icon {} { return [sn_view_icon ${Retr_Title}] } method SetTitle {} { ${topw} configure -title [Title] -iconname [Icon] } method print {} { if {$itk_option(-next) != ""} { $itk_option(-next) print } else { ${this}.list print_dialog_box } } method filter {{all 0}} { } #this function is called, when the symbols combobox #is called method postcommand {m} { set ed [MultiWindow&::list_find $itk_option(-next) edit] if {$itk_option(-symbols) == "" || ${ed} == ""} { return } ${ed} postcommand ${m} } method activate {} { if {$itk_option(-symbols) != ""} { set ed [MultiWindow&::list_find $itk_option(-next) edit] if {${ed} == ""} { $itk_option(-symbols) configure -state disabled } } if {$itk_option(-menu) != ""} { #set mn [string range $menu 0 [expr [string last "." $menu] - 1]] #$mn entryconfig [get_indep String MultiRetriever] -state normal } if {$itk_option(-toolbar) != ""} { pack $itk_option(-toolbar).retrfr -side left } } method deactivate {} { if {$itk_option(-symbols) != ""} { $itk_option(-symbols) configure -state normal } if {$itk_option(-menu) != ""} { #set mn [string range $menu 0 [expr [string last "." $menu] - 1]] #$mn entryconfig [get_indep String MultiRetriever] -state disabled } if {$itk_option(-toolbar) != ""} { pack forget $itk_option(-toolbar).retrfr } #hide filter window, if availiable if {[winfo exists ${this}-mixer]} { itcl::delete object ${this}-mixer } } method Selection {} { global sn_sep set sel [lindex [${tree} curselection] 0] if {${sel} == ""} { return "" } set txt [split [${tree} get ${sel}] \t] set data [split [${tree} itemcget ${sel} -data] \t] set file [lindex ${data} 0] set from [lindex ${data} 1] set to [lindex ${data} 2] if {${data} != "1"} { get_key_and_scope [lindex ${txt} 0] sym scope return [list ${scope} ${sym} [lindex ${txt} 1] ${file} ${from}\ [lindex ${txt} 2] [lindex ${txt} 3] ${to}] } else { set file [lindex ${txt} 0] set dir [lindex ${txt} 1] if {${dir} != ""} { set file [file join ${dir} ${file}] } #it's a file entry, return only file name return [list "" "" "" ${file} "" "" "" ""] } } method gotosymbol {{scope ""} {sym ""} {cls ""} {file ""} {from ""} {type\ ""} {prm ""} {to ""} {always 1}} { return 1 } method clearselection {} { ${tree} selection clear 0 end } method control_buttons {} { foreach sc [list cl md fu f] { if {[::info commands paf_db_${sc}] != ""} { set ${sc}_state normal } else { set ${sc}_state disabled } } if {$itk_option(-toolbar) != "" && [winfo exists $itk_option(-toolbar).retrfr.class]} { $itk_option(-toolbar).retrfr.class config -state ${cl_state} $itk_option(-toolbar).retrfr.meth config -state ${md_state} $itk_option(-toolbar).retrfr.func config -state ${fu_state} $itk_option(-toolbar).retrfr.file config -state ${f_state} } } method Update_Layout {} { global sn_options ${tree} config -font $sn_options(def,default-font)\ -selectforeground $sn_options(def,select-fg)\ -selectbackground $sn_options(def,select-bg) } method Focus {} { focus ${tree} } #refresh retriever, only by exclusive mode method Refresh_Display {} { upvar #0 ${this}-exclusive excl if {[info exists excl] && ${excl}} { #mark position set sel [${tree} curselection] #first viewed item in the tree set seen [${tree} index @0,0] set active [${tree} index active] start_search #restore older position if {${sel} != ""} { ${tree} selection clear 0 end ${tree} selection set ${sel} } if {${active} != ""} { ${tree} activate ${active} } if {${seen} != ""} { #restore back the older display ${tree} see -top ${seen} } } control_buttons } #make a title for the Dump position, this is usefull #for the views stack (prev/next) method DumpTitle {{dump ""}} { if {${dump} == ""} { set dump [Dump] } set pattern [lindex ${dump} 0] set scopes [lindex ${dump} 1] if {${pattern} == ""} { set pattern "*" } if {${scopes} == ""} { set scopes "files" } return "Retrieve [string trim "${scopes}(${pattern})"]" } method AddHistoryFromDump {dump title} { } #return the important data to restore this widget #in later time again (used by saving the project) method Dump {} { upvar #0 ${this}-pattern pattern upvar #0 ${this}-exclusive excl if {![info exists excl]} { set excl 0 } set scopes [retriever_what_to_qry ${this}] return [list ${pattern} ${scopes} ${excl}] } #gets the result from the function "Dump" to #restore the older state (used by restoring the project) method Restore {str} { upvar #0 ${this}-pattern pattern upvar #0 ${this}-exclusive excl set pattern [lindex ${str} 0] set excl [lindex ${str} 2] set scopes [lindex ${str} 1] RestoreScopes ${scopes} start_search } #window can't be closed when a fetch is active. method Close {{mode 0}} { if {${SearchActive}} { bell sn_error_dialog [get_indep String CannotCloseWindow] ${Retr_Title} return 0 } return 1 } method whoami {} { return retr } #if an editor is added to the retriever, call the #goto function of the editor method goto {combo txt} { set ed [MultiWindow&::list_find $itk_option(-next) edit] if {$itk_option(-symbols) != "" && ${ed} != ""} { #dump the current view into the history stack ${topw} history_stack_add_point ${ed} ${ed} goto ${combo} ${txt} } } protected variable searchbtn "" protected variable topw protected variable tree "" protected variable treew "" protected variable ScopesFilter protected variable cl_state disabled protected variable md_state disabled protected variable fu_state disabled protected variable f_state disabled public variable Retr_Title [get_indep String Retriever] itk_option define -selectcommand selectcommand Selectcommand "" { if {[winfo exists ${this}.list]} { ${this}.list treebind <space> "${this} handle_space" } } public variable pattern "" { if {[winfo exists ${this}.pattern.e]} { global ${this}-pattern set ${this}-pattern ${pattern} } } public variable width 60 public variable height 30 #can be #"retr " to interact as a retriever #"symbr" to interact as symbol browser public variable mode "retr" #true, when a symbol browser is created during a restore session public variable restore 0}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -