📄 targetmgr.tcl
字号:
} else { #do rename target. } #clear entry $itk_component(entry) delete 0 end if {${creating_new_target} == 1} { # enable the other controls $itk_component(dup) configure -state normal $itk_component(create) configure -state normal $itk_component(edit) configure -state normal $itk_component(del) configure -state normal $itk_component(done) configure -state normal #TODO: call target editor. set creating_new_target 0 } } common editingtarget 0 public method edit_target {} { if {$editingtarget == 1} { # Target editor in use. return } # Mark editing in use. set editingtarget 1 # Get the targets name set target_name [$itk_component(entry) get] if {${target_name}==""} { # No target selected. bell -displayof $itk_component(hull) # Mark editing not in use. set editingtarget 0 return } if {[itcl::find objects -class snEditTarget .snte] != ".snte"} { # Invoke target editor snEditTarget .snte ${target_name} .snte transient $itk_component(hull) .snte activate itcl::delete object .snte # Mark editing not in use. set editingtarget 0 UpdateBuildWindows } else { # We shouldn't end up here. # But just incase. return } } public method HandleState {{selected ""} {entered ""}} { # Get Listbox selection set selection [$itk_component(tmlist) curselect] if {${selected} == "" && ${selection} != ""} { set selected [$itk_component(tmlist) get ${selection}] } # Get Text Widget contents. if {${entered} == ""} { set entered [$itk_component(entry) get] } # Nothing entered, nothing selected. if {${selected} == "" && ${entered} == ""} { $itk_component(dup) configure -state disabled $itk_component(create) configure -state disabled $itk_component(edit) configure -state disabled $itk_component(del) configure -state disabled $itk_component(rename) configure -state disabled $itk_component(done) configure -state normal $itk_component(done) configure -default active bind $itk_component(hull) <Return> "$itk_component(done) invoke" $itk_component(edit) configure -default normal $itk_component(create) configure -default normal $itk_component(rename) configure -default normal return } # Something entered, nothing selected. if {${selected} == "" && ${entered} != ""} { # Only "Done" and "Create*" active $itk_component(dup) configure -state disabled $itk_component(create) configure -state normal $itk_component(edit) configure -state disabled $itk_component(del) configure -state disabled $itk_component(rename) configure -state disabled $itk_component(done) configure -state normal $itk_component(create) configure -default active bind $itk_component(hull) <Return> "$itk_component(create) invoke" $itk_component(edit) configure -default normal $itk_component(done) configure -default normal $itk_component(rename) configure -default normal return } # Something entered, something selected (matching) if {${entered} != "" && ${selected} != "" && ${selected} == ${entered}} { #"Done", "Edit*", "Duplicate", "Delete" and "Done" active $itk_component(dup) configure -state normal $itk_component(create) configure -state disabled $itk_component(rename) configure -state disabled $itk_component(edit) configure -state normal $itk_component(del) configure -state normal $itk_component(done) configure -state normal $itk_component(edit) configure -default active bind $itk_component(hull) <Return> "$itk_component(edit) invoke" $itk_component(done) configure -default normal $itk_component(create) configure -default normal $itk_component(rename) configure -default normal return } # Something entered, something seleted (not matching) if {${entered} != "" && ${selected} != "" && ${selected} != ${entered}} { #"Done", "Create*" and "Rename" active. $itk_component(dup) configure -state disabled $itk_component(create) configure -state normal $itk_component(rename) configure -state normal $itk_component(edit) configure -state disabled $itk_component(del) configure -state disabled $itk_component(done) configure -state normal $itk_component(create) configure -default active bind $itk_component(hull) <Return> "$itk_component(create) invoke" $itk_component(done) configure -default normal $itk_component(edit) configure -default normal $itk_component(rename) configure -default normal return } } public method create_cb {} { set new_name [$itk_component(entry) get] CreateTarget ${new_name} $itk_component(tmlist) insert end "${new_name}" $itk_component(tmlist) selection clear 0 end $itk_component(tmlist) selection set end target_selected [$itk_component(tmlist) curselection] snEditTarget .new_target ${new_name} .new_target activate itcl::delete object .new_target EntryBoxChanged UpdateBuildWindows } public method done_cb {} { itcl::delete object ${this} } public method copy_target_cb {} { set selected [$itk_component(tmlist) curselection] set target_name [$itk_component(tmlist) get ${selected}] set new_name [CopyTarget ${target_name}] UpdateTargetList $itk_component(entry) delete 0 end $itk_component(entry) insert end ${new_name} EntryBoxChanged } public method rename_target_cb {} { set selected [$itk_component(tmlist) curselection] set old_name [$itk_component(tmlist) get ${selected}] set new_name [$itk_component(entry) get] RenameTarget ${old_name} ${new_name} UpdateTargetList EntryBoxChanged } public method delete_target_cb {} { set dead_name [$itk_component(entry) get] DeleteTarget ${dead_name} UpdateTargetList $itk_component(entry) delete 0 end EntryBoxChanged } public method UpdateBuildWindows {} { # FIXME : This is a really nasty hack! foreach buildwindow [itcl::find objects -class Make] { ${buildwindow} RefreshTargetInfo } }}# Get list for targets from the db.proc GetTargetsList {} { set targets_list [paf_db_proj get -key snide_targets] return ${targets_list}}# Create a build targetproc CreateTarget {target_name} { set targets [GetTargetsList] sn_log "IDE_DEBUG(proc CreateTarget): targets = <${targets}>" lappend targets ${target_name} sn_log "IDE_DEBUG(proc CreateTarget): targets = <${targets}>" #TODO: check target_name is unique sn_log "IDE_DEBUG: Creating build <${target_name}>" paf_db_proj put snide_targets ${targets} paf_db_proj sync}proc RenameTarget {old_target_name target_name} { set t_obj [snBuildTarget .oldone] ${t_obj} LoadData ${old_target_name} CreateTarget ${target_name} ${t_obj} SaveData ${target_name} itcl::delete object ${t_obj} DeleteTarget ${old_target_name}}proc DeleteTarget {target_name} { set del_target [snBuildTarget .targ_obj] ${del_target} DeleteData ${target_name} itcl::delete object ${del_target} DeleteTargetName ${target_name}}proc DeleteTargetName {target_name} { set targets [GetTargetsList] # Find it. set kill [lsearch ${targets} ${target_name}] # Remove it. set targets [lreplace ${targets} ${kill} ${kill}] # Save the rest. paf_db_proj put snide_targets ${targets} paf_db_proj sync}proc CopyTarget {target_name} { set targets [GetTargetsList] # Get a unquie name set copy "Copy" set num "" while {[lsearch ${targets} "${target_name} ${copy}${num}"] != -1} { if {${num} == ""} { set num 1 } else { incr num } } # Copy it. set t_obj [snBuildTarget .tcopy] ${t_obj} LoadData ${target_name} CreateTarget "${target_name} ${copy}${num}" ${t_obj} SaveData "${target_name} ${copy}${num}" itcl::delete object ${t_obj} return "${target_name} ${copy}${num}"}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -