📄 targetmgr.tcl
字号:
# Copyright (c) 2000, Red Hat, Inc.# # This file is part of Source-Navigator.# # Source-Navigator is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License as published# by the Free Software Foundation; either version 2, or (at your option)# any later version.# # Source-Navigator is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU# General Public License for more details.# # You should have received a copy of the GNU General Public License along# with Source-Navigator; see the file COPYING. If not, write to# the Free Software Foundation, 59 Temple Place - Suite 330, Boston,# MA 02111-1307, USA.# #################################################### Target Manager (Build Manager) Dialog.## Copyright (c) 1999 Cygnus Solutions, Inc.## Written by Ian Roxborough <irox@cygnus.com>##################################################itcl::class snIdeTargetMgr { inherit sourcenav::Window protected variable creating_new_target 0 # new target flag. protected variable last_selected_item "" constructor {{args ""}} { CreateDialog $this title [get_indep String IDETargetMgrTitle] $this take_focus } public method CreateDialog {} { itk_component add btlabel { label $itk_component(hull).btlabel \ -text [get_indep String IDETMBuildTargets] \ -under [get_indep Pos IDETMBuildTargets] } itk_component add lbframe { label $itk_component(hull).lbframe \ -relief sunken -borderwidth 2 }# FIXME: I can select the empty line after the last build rule.# This needs to be fixed! itk_component add tmlist { listbox $itk_component(lbframe).listbox \ -width 40 \ -relief flat \ -yscrollcommand [list $itk_component(lbframe).scrolly set] } itk_component add scrolly { scrollbar $itk_component(lbframe).scrolly \ -orient vertical \ -command [list $itk_component(tmlist) yview] } itk_component add create { button $itk_component(hull).create \ -width 11 \ -command "${this} create_cb" \ -text [get_indep String IDETMCreateTarget] \ -under [get_indep Pos IDETMCreateTarget] } itk_component add rename { button $itk_component(hull).rename \ -width 11 \ -command "${this} rename_target_cb" \ -text [get_indep String IDETMRenameTarget] \ -under [get_indep Pos IDETMRenameTarget] } itk_component add edit { button $itk_component(hull).edit \ -width 11 \ -command "${this} edit_target" \ -text [get_indep String IDETMEditTarget] \ -under [get_indep Pos IDETMEditTarget] }# FIXME: If you select a rule and then press duplicate and# then triple click in the entry, you will still be able to# press the duplicate button (which will generate an error) itk_component add dup { button $itk_component(hull).dup \ -width 11 \ -command "${this} copy_target_cb" \ -text [get_indep String IDETMCopyTarget] \ -under [get_indep Pos IDETMCopyTarget] } itk_component add del { button $itk_component(hull).del \ -width 11 \ -command "${this} delete_target_cb" \ -text [get_indep String IDETMDeleteTarget] \ -under [get_indep Pos IDETMDeleteTarget] } itk_component add done { button $itk_component(hull).done \ -width 11 \ -command "${this} done_cb" \ -text [get_indep String IDETargetMgrDone] \ -under [get_indep Pos IDETargetMgrDone] } itk_component add entry { entry $itk_component(hull).entry \ } # Grid the frame that will contain the listbox and # the scrollbar grid $itk_component(tmlist) -row 0 -column 0 -sticky news grid $itk_component(scrolly) -row 0 -column 1 -sticky ns grid rowconfigure $itk_component(lbframe) 0 -weight 1 grid columnconfigure $itk_component(lbframe) 0 -weight 1 # Grid the rest of the widgets into the parent frame grid $itk_component(btlabel) -row 0 -column 0 -sticky w \ -padx 10 -pady 5 grid $itk_component(lbframe) -row 1 -column 0 -rowspan 6 \ -sticky news -padx 10 grid $itk_component(create) -row 1 -column 1 grid $itk_component(rename) -row 2 -column 1 grid $itk_component(edit) -row 3 -column 1 grid $itk_component(dup) -row 4 -column 1 grid $itk_component(del) -row 5 -column 1 grid $itk_component(entry) -row 7 -column 0 \ -sticky ew -padx 10 grid $itk_component(done) -row 7 -column 1 grid columnconfigure $itk_component(hull) 0 -weight 1 grid rowconfigure $itk_component(hull) 6 -weight 1 # Get a list of targets set targets [GetTargetsList] foreach target ${targets} { $itk_component(tmlist) insert end ${target} sn_log "IDE_DEBUG: target = <${target}>" } set listcmdsel "${this} target_selected \[$itk_component(tmlist) curselection\]" set listcmdaction "${this} edit_target" # This should bing to a listbox select not a button click! bind $itk_component(tmlist) <ButtonRelease-1> \ "${this} target_selected \[$itk_component(tmlist) curselection\]" bind $itk_component(tmlist) <Double-1> "${this} edit_target"# FIXME: Can we bind this to the class instead of the instance? bind $itk_component(hull) <Escape> "$itk_component(done) invoke" bind $itk_component(entry) <KeyRelease> "${this} EntryBoxChanged %K" $this protocol WM_DELETE_WINDOW "$itk_component(done) invoke" HandleState } public method UpdateTargetList {} { # Delete old targets $itk_component(tmlist) delete 0 end # Get a list of targets set targets [GetTargetsList] foreach target ${targets} { $itk_component(tmlist) insert end ${target} sn_log "IDE_DEBUG: target = <${target}>" } } #TODO: This method has been earmark to be removed. public method new_target {} { set creating_new_target 1 # Now the user can only: # press Delete to cancel creation # or press Set to create target. $itk_component(dup) configure -state disabled $itk_component(create) configure -state disabled $itk_component(edit) configure -state disabled $itk_component(del) configure -state normal $itk_component(done) configure -state disabled $itk_component(tmlist) insert end "new_target" $itk_component(tmlist) selection clear 0 end $itk_component(tmlist) selection set end target_selected [$itk_component(tmlist) curselection] } public method target_selected {{itemnum ""}} { if {${itemnum} != ""} { set last_selected_item ${itemnum} set item [$itk_component(tmlist) get ${itemnum}] $itk_component(entry) delete 0 end $itk_component(entry) insert end ${item} } HandleState } public method EntryBoxChanged {{keypress ""}} { # If the user is hitting backspace instead of # typing, they probably don't want us to start # selecting targets for them. Unless nothing is # selected then we should try to select something. set list_value [$itk_component(tmlist) curselection] if {${keypress}=="BackSpace" && ${list_value}!=""} { # Just update the button state HandleState return } set entry_value [$itk_component(entry) get] # Check to see if new Entry box value # matches any list box values. # Why? so it can be selected from the list set matched 0 set itemnum -1 foreach item [$itk_component(tmlist) get 0 end] { incr itemnum if {${item} == ${entry_value}} { set matched 1 break } } if {${matched}} { $itk_component(tmlist) selection clear 0 end $itk_component(tmlist) selection set ${itemnum} } HandleState } #TODO: This method has been earmarked to be removed. public method set_cb {} { #set stuff. #get new name set new_name [$itk_component(entry) get] #TODO: check that the new name has #not already be given to a target. #set new name set item ${last_selected_item} $itk_component(tmlist) delete ${item} $itk_component(tmlist) insert ${item} ${new_name} $itk_component(tmlist) selection set ${item} if {${creating_new_target} == 1} { #do create a target... set new_name [$itk_component(entry) get]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -