📄 includepane.tcl
字号:
# Set Level Counter up to one set level [expr {${level} + 1}] foreach entry [includes ${n}] { if {${entry} == ${n}} { continue } lappend arr(${entry}) ${n} lappend sons(${n}) ${entry} if {![info exists r(${entry})]} { set r(${entry}) 0 FillValuesRec ${entry} arr r ${level} ${max_levels} } } # By leaving the Program decriment Level Counter to # origin value as given set max_levels [expr {${level} - 1}] } } method ReadMaxLevels {} {# FIXME: remove this global variable upvar #0 ${this}.incMaxLevels incMaxLevels if {[catch {set incMaxLevels [expr {int(${incMaxLevels}) + 0}]}] ||\ ${incMaxLevels} < 0} { set incMaxLevels 2 } DispMaxLevels } method DispMaxLevels {} { if {$itk_option(-toolbar) != "" && [winfo exists $itk_option(-toolbar)]} { $itk_option(-toolbar).incbr.txt delete 0 end $itk_option(-toolbar).incbr.txt insert 0 ${incMaxLevels} } } method view_include {include {reset 0}} { #nothing selected if {${include} == ""} { return } #dump the current view into the history stack if {!${reset}} { ${topw} history_stack_add_point ${this} } #reset the variables reset set baseroot ${include} #set the new selected item set includes_to_view [list ${include}] set base_root ${includes_to_view} #calculate the coordinates FillValues #Redraw the Widget Redraw set tid [${can} find withtag ${include}] set level ${incMaxLevels} if {${incMaxLevels} > 1} { set level [expr ${incMaxLevels} - 1] } references by ${tid} ${level} if {$itk_option(-symbols) != ""} { $itk_option(-symbols) selecttext ${include} } set base_root "" mark_item ${include} } method values {} { return ${base_root} } # 0 <==> File includes # 2 <==> File included from #files that are included from this file proc includes {name} { if {! [info exists Includes(${name})]} { if {[::info commands paf_db_iu] != ""} { set Includes(${name}) [lunique [lsort\ -dictionary [paf_db_iu seq -col 0 -end ${name}]]] } else { set Includes(${name}) "" } } return $Includes(${name}) } # 0 <==> File includes # 2 <==> File included from #files that include this file proc included_from {name} { global sn_sep if {! [info exists Included_From(${name})]} { if {[::info commands paf_db_iu] != ""} { set Included_From(${name}) [lunique [lsort\ -dictionary [paf_db_iu seq -col 2 "${name}${sn_sep}"]]] } else { set Included_From(${name}) "" } } return $Included_From(${name}) } method control_buttons {{id ""}} { if {${id} == ""} { set id [${can} select item] } if {${id} == ""} { return } set includes_state disabled set included_from_state disabled set remove_state disabled set removeFrom_state disabled if {${id} != ""} { set name [${can} itemcget ${id} -text] #there are Items availiable, include this file #force the Includes list, to see if there are includes #availiable, that are not drawned on the screen foreach entry [includes ${name}] { if {[catch {set ret [lsearch -exact $sons(${name})\ ${entry}]}]} { return } if {${ret} == -1} { set includes_state normal break } } if {![info exists sons(${name})]} { set sons(${name}) "" } if {$sons(${name}) != ""} { set remove_state normal } if {![info exists parents(${name})]} { set parents(${name}) "" } #force the Included_From list, to see if there are includes #availiable, that are not drawned on the screen foreach entry [included_from ${name}] { if {[lsearch -exact $parents(${name}) ${entry}] == -1} { set included_from_state normal break } } # Parents availiable. if {$parents(${name}) != ""} { set removeFrom_state normal } } if {$itk_option(-menu) != "" && [winfo exists $itk_option(-menu)]} { $itk_option(-menu) entryconfig [get_indep String Includes]\ -state ${includes_state} $itk_option(-menu) entryconfig [get_indep String IncludedFrom]\ -state ${included_from_state} $itk_option(-menu) entryconfig [get_indep String RemIncludes]\ -state ${remove_state} $itk_option(-menu) entryconfig [get_indep String RemIncludedFrom]\ -state ${removeFrom_state} } if {$itk_option(-toolbar) != "" && [winfo exists $itk_option(-toolbar)]} { $itk_option(-toolbar).incbr.ref_to configure -state ${includes_state} $itk_option(-toolbar).incbr.ref_by configure -state ${included_from_state} $itk_option(-toolbar).incbr.remove configure -state ${remove_state} } #option menu ${can}.menu entryconfig [get_indep String Includes]\ -state ${includes_state} ${can}.menu entryconfig [get_indep String IncludedFrom]\ -state ${included_from_state} ${can}.menu entryconfig [get_indep String RemIncludes]\ -state ${remove_state} ${can}.menu entryconfig [get_indep String RemIncludedFrom]\ -state ${removeFrom_state} return [list ${includes_state} ${included_from_state}] } method set_sorted_order {} { if {${tids} != ""} { eval graph ${can} add ${tids} } } method graph_new_layout {{redraw 1}} { global sn_options if {${tids} == ""} { return } if {${redraw}} { graph ${can} clear set_sorted_order } if {${order} == ""} { set order 0 } if {${order} == 0} { set cmd "-nodespacev $sn_options(def,include-horizspace)\ -nodespaceh $sn_options(def,include-vertspace)" } else { set cmd "-nodespacev $sn_options(def,include-vertspace) \ -nodespaceh $sn_options(def,include-horizspace)" } eval graph ${can} configure -gridlock 1 -order ${order} ${cmd} if {[info exists tids] && [string trim ${tids}] != ""} { graph ${can} layout ${layoutstyle} set reg [${can} bbox all] set wd [lindex ${reg} 2] set he [lindex ${reg} 3] ${can} configure -scrollregion [list 0 0 ${wd} ${he}] set lst [list ${wd} ${he}] } else { set lst [list 10 10] } return ${lst} } method update_post_menu {} { set m ${can}.menu set view ${this}.menu.view set id [${can} select item] if {${id} == ""} { return } set sym [string trim [${can} itemcget ${id} -text]] } method references {type {sym_id ""} {level -1}} { if {${level} == -1} { ReadMaxLevels set maxlevels ${incMaxLevels} } else { set maxlevels ${level} } if {${type} == "both"} { set type [list to by] } set scroll_to_top 0 switch -glob ${sym_id} { {[0-9]*} { set sym [${can} itemcget ${sym_id} -text] set sym_tp [lindex ${sym} 0] set sym [lindex ${sym} end] } {} { set sym_id [${can} select item] if {${sym_id} == ""} { return } set sym [${can} itemcget ${sym_id} -text] set sym_tp [lindex ${sym} 0] set sym [lindex ${sym} end] } default { return } } if {[lsearch ${type} "by"] != -1} { show_included_from ${sym_id} 0 ${maxlevels} if {$itk_option(-menu) != "" && [winfo exists $itk_option(-menu)]} { $itk_option(-menu) entryconfig [get_indep String IncludedFrom]\ -state disabled } if {$itk_option(-toolbar) != "" && [winfo exists $itk_option(-toolbar)]} { $itk_option(-toolbar).incbr.ref_by configure -state disabled } } if {[lsearch ${type} "to"] != -1} { show_includes ${sym_id} 0 ${maxlevels} if {$itk_option(-menu) != "" && [winfo exists $itk_option(-menu)]} { $itk_option(-menu) entryconfig [get_indep String Includes] -state disabled } if {$itk_option(-toolbar) != "" && [winfo exists $itk_option(-toolbar)]} { $itk_option(-toolbar).incbr.ref_to configure -state disabled } } # This is a workaround for 'tree'. if {${layoutstyle} == "tree"} { graph_new_layout 1 } else { graph ${can} layout ${layoutstyle} set reg [${can} bbox all] set wd [lindex ${reg} 2] set he [lindex ${reg} 3] ${can} configure -scrollregion [list 0 0 ${wd} ${he}] } if {${scroll_to_top}} { ${can} xview moveto 0.0 ${can} yview moveto 0.0 } control_buttons see_item ${sym_id} } method show_included_from {sym_id level maxlevels} { global sn_options set sym [${can} itemcget ${sym_id} -text] if {${maxlevels} > 0 && ${level} >= ${maxlevels}} { return } #no Included Files available if {[included_from ${sym}] == ""} { return } if {! [info exists sons(${sym})]} { set sons(${sym}) "" } if {! [info exists parents(${sym})]} { set parents(${sym}) "" } # Add the included files from this file foreach s [included_from ${sym}] { lappend sons(${s}) ${sym} lappend parents(${sym}) ${s} #text not drawned if {! [info exists inc_drawn(${s})] || $inc_drawn(${s}) != 1} { set tid [${can} create text 0 0 -text ${s} -tags [list ${s}\ incT inc] -anchor nw -font $sn_options(def,include_font)] set inc_drawn(${s}) 1 set tids [linsert ${tids} 0 ${tid}] } else { set eid [${can} find withtag "b:${s}:${sym}"] if {${eid} != ""} { continue } set tid "" } if {${s} == ${sym}} { continue } else { set eid [${can} create edge -1m -1m -1m -1m -tag\ [list child:${s} e:${s} e:${sym} b:${s}:${sym} edge]\ -to [${can} find withtag ${sym}] -from [${can} find withtag\ ${s}] -arrow last -fill $sn_options(def,canv-line-fg)] lappend tids ${eid} } if {${tid} != "" && ${eid} != ""} { eval graph ${can} add ${tid} ${eid} show_included_from ${tid} [expr ${level} + 1] ${maxlevels} }\ elseif {${eid} != ""} { eval graph ${can} add ${eid} } } #mark_item $sym } method show_includes {sym_id level maxlevels} { global sn_options set sym [${can} itemcget ${sym_id} -text] if {${maxlevels} > 0 && ${level} >= ${maxlevels}} { return } #no Included Files available if {[includes ${sym}] == ""} { return } if {! [info exists sons(${sym})]} { set sons(${sym}) "" } if {! [info exists parents(${sym})]} { set parents(${sym}) "" } # Add the Includes that include this file foreach s [includes ${sym}] { lappend sons(${sym}) ${s} lappend parents(${s}) ${sym} #text not created, create now if {! [info exists inc_drawn(${s})] || $inc_drawn(${s}) != 1} { set tid [${can} create text 0 0 -text ${s} -tags [list ${s}\ incT inc] -anchor nw -font $sn_options(def,include_font)] set inc_drawn(${s}) 1 lappend tids ${tid} #text already created } else { set eid [${can} find withtag "b:${sym}:${s}"] #edge already exists if {${eid} != ""} { continue } set tid "" } if {${s} == ${sym}} { continue } else { set eid [${can} create edge -1m -1m -1m -1m -tag\ [list child:${sym} e:${s} e:${sym} b:${sym}:${s} edge]\ -from [${can} find withtag ${sym}] -to [${can} find withtag\ ${s}] -arrow last -fill $sn_options(def,canv-line-fg)] lappend tids ${eid} } if {${tid} != "" && ${eid} != ""} { graph ${can} add ${tid} ${eid}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -