📄 projedit.tcl
字号:
} #Only view names set Views "" foreach view ${ProjectViews} { lappend Views [lindex ${view} 0] } set can_apply 0 control_buttons } method Refresh {} { #refresh views if {[winfo exists ${Views_Combo}]} { ${Views_Combo} configure -contents ${Views} ${Views_Combo} selecttext ${CurrentView} #$Views_Combo see 0 } #Add project files into tree Display_ProjectFiles } method Display_ProjectFiles {{cls ""} {dummy ""}} { global sn_options global sn_path global Avail_Parsers Parser_Info set filter [${tree} getfilter] if {${filter} == "*"} { set pfiles [lsort ${ProjectFiles}] set hfiles [lsort ${HiddenFiles}] set ufiles [lsort ${files_to_unload}] } else { set pfiles [lsort [lmatch -glob 0 ${ProjectFiles} *${filter}]] set hfiles [lsort [lmatch -glob 0 ${HiddenFiles} *${filter}]] set ufiles [lsort [lmatch -glob 0 ${files_to_unload} *${filter}]] } switch -- ${Tree_Mode} { "tree" { set dir_bitmap dir_image set file_bitmap file_image #delete old entries ${treew} delete 0 end #add project name as first icon ${treew} insert 0 -text [get_indep String ProjectFiles]\ -image dir_image fill_file_tree -widget ${treew} -fileimage file_s_image\ -dirimage dir_image -contents ${pfiles} -parent 0\ -basedir ${disp_Directories} #Hidden files, if availiable if {${HiddenFiles} != ""} { set img dir_image set hi [${treew} insert end -text [get_indep String\ HiddenFiles] -image ${img}] fill_file_tree -widget ${treew}\ -fileimage file_h_image -dirimage dir_image\ -contents ${hfiles} -parent ${hi}\ -basedir ${disp_Directories} } if {${files_to_unload} != ""} { set img dir_image set ui [${treew} insert end -text [get_indep String\ UnloadedFiles] -image ${img}] fill_file_tree -widget ${treew}\ -fileimage file_d_image -dirimage dir_image\ -contents ${ufiles} -parent ${ui}\ -basedir ${disp_Directories} } } "list" { #display an easy file list #delete old entries ${treew} delete 0 end #add project name as first icon ${treew} insert end -text [get_indep String ProjectFiles]\ -image dir_image #$treew insert end list $pfiles -parent 0\ -image file_s_image add_list_to_project ${treew} 0 file_s_image\ ${disp_Directories} ${pfiles} #Hidden files, if availiable if {${HiddenFiles} != ""} { set hi [${treew} insert end -text [get_indep String\ HiddenFiles] -image dir_image] #$treew insert end list $hfiles -parent $hi\ -image file_h_image add_list_to_project ${treew} ${hi} file_h_image\ ${disp_Directories} ${hfiles} } #unloaded files, if availiable if {${files_to_unload} != ""} { set hi [${treew} insert end -text [get_indep String\ UnloadedFiles] -image dir_image] #$treew insert end list $ufiles -parent $hi\ -image file_d_image add_list_to_project ${treew} ${hi} file_h_image\ ${disp_Directories} ${ufiles} } } "cat" { #display files in groups #get known types and extensions to sort set types "" foreach type ${Avail_Parsers} { lappend types [list $Parser_Info(${type},TYPE)\ $Parser_Info(${type},SUF)] } set types [::lsort -dictionary ${types}] #delete old entries ${treew} delete 0 end #add project name as first icon ${treew} insert end -text [get_indep String ProjectFiles]\ -image dir_image AddFilesAsCategorie ${treew} ${types} 0 ${pfiles}\ file_s_image ${disp_Directories} #Hidden files, if availiable if {${HiddenFiles} != ""} { set hi [${treew} insert end -text [get_indep String\ HiddenFiles] -image dir_image] AddFilesAsCategorie ${treew} ${types} ${hi} ${hfiles}\ file_h_image ${disp_Directories} } #unloaded files, if availiable if {${files_to_unload} != ""} { set hi [${treew} insert end -text [get_indep String\ UnloadedFiles] -image dir_image] AddFilesAsCategorie ${treew} ${types} ${hi} ${ufiles}\ file_d_image ${disp_Directories} } } } project_CloseAlreayClosed ${treew} ${Tree_Mode} } method toggle_disp_mode {} { upvar #0 ${this}-Tree_Mode tm if {${tm} == "tree"} { ${Toolbar}.dirs config -state disabled } else { ${Toolbar}.dirs config -state normal } #change tabs to delete unneeded tabs if {${tm} == "tree" || ${disp_Directories} == 0} { ${tree} change_tabs 0 250 Name } else { ${tree} change_tabs 1 {250 250} {Name Directory} } if {${Tree_Mode} != ${tm}} { set Tree_Mode ${tm} Display_ProjectFiles } } method undo {} { #ReadProjectFiles set x_Undo_HiddenFiles ${HiddenFiles} set x_Undo_files_to_unload ${files_to_unload} set x_Undo_ProjectFiles ${ProjectFiles} set ProjectFiles ${Undo_ProjectFiles} set HiddenFiles ${Undo_HiddenFiles} set files_to_unload ${Undo_files_to_unload} set Undo_HiddenFiles ${x_Undo_HiddenFiles} set Undo_files_to_unload ${x_Undo_files_to_unload} set Undo_ProjectFiles ${x_Undo_ProjectFiles} Display_ProjectFiles } proc can_create_project {prjdir prjname} { set name [sn_build_project_filename ${prjdir} ${prjname}] set ret [sn_is_project_busy ${name} in remuser remhost port pid] switch -- ${ret} { "othersystem" { sn_error_dialog [format \ [get_indep String ProjAlreadyOpenedOtherSystem] \ ${remuser} ${name} ${remhost}] return 0 } "thisprocess" { sn_error_dialog [format \ [get_indep String ProjAlreadyOpenedThisProcess] \ ${name}] return 0 } "thisuser" { sn_error_dialog [format \ [get_indep String ProjAlreadyOpenedThisUser] \ ${name} ${pid}] return 0 } "thissystem" { sn_error_dialog [format \ [get_indep String ProjAlreadyOpenedThisSystem] \ ${remuser} ${name} ${pid}] return 0 } "error" { return 0 } } if {[file exists ${name}]} { set answer [tk_dialog auto [get_indep String FileExists] ${name}\ question_image 0 [get_indep String Overwrite] [get_indep String\ cancel]] if {${answer} == 1} { return 0 } else { #delete existing project set ret [sn_delete_project ${name}] #unable to delete the project if {${ret} == 0} { sn_error_dialog [get_indep String CannotDeleteProject] return 0 } } } return 1 } method apply {{exit ""}} { global sn_options global sn_newargs upvar #0 ${this}-view view if {${view} == ""} { set view "default" } set CurrentView ${view} if {$itk_option(-new_project)} { set prjdir [file dirname [sn_filecmd format -sn $sn_newargs(path)]] set prjname [file tail [sn_filecmd format -sn $sn_newargs(path)]] #valid project name ?? if {${prjname} == ""} { sn_error_dialog [get_indep String InvalidProjectName] focus [${prjname_Entry} entry] return } #valid project name ?? if {[catch {set realprjdir [realpath -pwd [pwd] ${prjdir}]} err]} { sn_error_dialog "${prjdir}: ${err}" focus [${prjname_Entry} entry] return } #Does the directory exist? if {![file isdirectory ${prjdir}]} { sn_error_dialog [get_indep String InvalidProjectDir] focus [${prjdir_Entry} entry] return } #verify if the file exists or is being used if {! [can_create_project ${realprjdir} ${prjname}]} { return } #now we can set project file set sn_options(sys,project-file) [sn_filecmd format\ -sn $sn_newargs(path)] #project directory can be only changed by new projects #accept only full pathes set sn_options(sys,project-dir) ${realprjdir} set itk_option(-new_ProjectFiles) ${ProjectFiles} set new_HiddenFiles ${HiddenFiles} } else { #add all directory prefixes to the path list set dirs [generate_pathes ${ProjectFiles}] foreach dir ${dirs} { if {[lsearch -exact $sn_options(include-source-directories)\ ${dir}] == -1} { lappend sn_options(include-source-directories) ${dir} } } #we should here only pass the new files that have been added #to the project, not all the files that are alreay in the #project to reduce the loading time (over SAMBA it reduces #some minutes for hug projects) if {${orig_ProjectFiles} != ""} { set new_files "" foreach f ${ProjectFiles} { if {[lsearch -exact ${orig_ProjectFiles} ${f}] == -1} { lappend new_files ${f} } } } else { set new_files ${ProjectFiles} } set ret [sn_load_hide_unload_files $sn_options(sys,project-dir)\ ${new_files} ${HiddenFiles} ${files_to_unload} ${CurrentView}] if {!${ret}} { #operation not applied return } } set can_apply 0 control_buttons if {$itk_option(-variable) != ""} { global $itk_option(-variable) set $itk_option(-variable) "ok" } elseif {${exit} == "exit"} { itcl::delete object $this } hide_loading_message } protected variable last_dir [pwd] method add_files_cb {files} { global sn_options tcl_platform #undo history if {[llength $files] > 0} { set Undo_ProjectFiles ${ProjectFiles} set Undo_HiddenFiles ${HiddenFiles} set Undo_files_to_unload ${files_to_unload} } #don't differ between upper/lower case on windows if {$tcl_platform(platform) == "windows"} { set nocase 1 } else { set nocase 0 } # Create map for ProjectFiles, HiddenFiles, and files_to_unload foreach lname {ProjectFiles HiddenFiles files_to_unload} { if {$nocase} { foreach file [set $lname] { set ${lname}_MAP([string tolower $file]) {} } } else { foreach file [set $lname] { set ${lname}_MAP($file) {} } } } foreach f ${files} { if {! $itk_option(-new_project)} { set f [sn_truncate_path $sn_options(sys,project-dir) ${f}] } if {$nocase} { set nc [string tolower $f] } else { set nc $f } if {[info exists ProjectFiles_MAP($nc)] || [info exists HiddenFiles_MAP($nc)] || [info exists files_to_unload_MAP($nc)]} { continue } lappend ProjectFiles ${f} set ProjectFiles_MAP($nc) {} set can_apply 1 } #store last directory set last_dir [file dirname [lindex ${files} 0]] control_buttons Display_ProjectFiles } method add_files {} { Editor&::FileDialog $itk_component(hull) -title [get_indep String Open]\ -script "${this} add_files_cb" -prefix add_files\ -save_open open -initialdir ${last_dir} } method add_dir_cb {dir} { global sn_options global Avail_Parsers Parser_Info
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -