multiview.tcl
来自「This Source-Navigator, an IDE for C/C++/」· TCL 代码 · 共 2,115 行 · 第 1/5 页
TCL
2,115 行
method edit_delete {} { set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { bell return } ${ed} Delete } method do_compile_file {} { global sn_options set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { bell return } set file [${ed} cget -filename] if {${file} == $sn_options(noname_file)} { bell return } #get file name and convert it to an object file set tocmpfile [sn_object_file [file tail ${file}]] set tocmpdir [file dirname ${file}] #mask the file with "" if there are blanks in it. if {[string first " " ${tocmpfile}] > 1} { set tocmpfile "\"${tocmpfile}\"" } set make [sn_make] ${make}.make setmakecommand\ "$sn_options(both,make-command) ${tocmpfile}" ${make}.make ExecMake } proc edit_proj_preferences {m} { sn_project_preferences } method edit_preferences {m} { sn_project_preferences 0 [${ActiveWidget} whoami] ${ActiveWidget}\ ${this} } if {${sn_elix}} { proc edit_elix_preferences {} { sn_elix_preferences } } method edit_insert {} { set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { bell return } ${ed} insert_file } method edit_indent {mode} { set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { bell return } Editor&::Indent ${ed} ${mode} } method Handle_Rcs {cmd {prm ""}} { set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { bell return } eval ${cmd} ${prm} [${ed} cget -filename] ${ed} SetTitle } method edit_selectall {} { set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { bell return } [${ed} editor] tag add sel 0.0 end [${ed} editor] tag raise sel } method edit_clear {} { ${ActiveWidget} clearselection } method search_post {m} { #if we don't have an editor in the actual view, #disable string manipulation menu items set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { set state disabled } else { set state normal } ${m} entryconfig [get_indep String SearchFind] -state ${state} ${m} entryconfig [get_indep String SearchNext] -state ${state} ${m} entryconfig [get_indep String SearchPrev] -state ${state} ${m} entryconfig [get_indep String SearchReplace] -state ${state} # FIXME: using sub menu widgets directly is likely to break # Disable goto submenu too ${m}.goto entryconfig [get_indep String SearchGotoLine] -state ${state} ${m}.goto entryconfig [get_indep String SearchSetMark] -state ${state} ${m}.goto entryconfig [get_indep String SearchGotoMark] -state ${state} ${m}.goto entryconfig [get_indep String SearchGotoError] -state ${state} #verify if we can retrieve something if {${ed} != ""} { set string [Get_Selection ${ed} ${ActiveWidget}] } else { set string "" } if {${string} == ""} { set retrstate disabled } else { set retrstate normal } ${m} entryconfig [get_indep String SearchDefinition] -state ${retrstate} ${m} entryconfig [get_indep String SearchImplementation]\ -state ${retrstate} ${m} entryconfig [get_indep String SearchGrep] -state ${retrstate} } method search_findtext {} { set ed [list_find_editor ${ActiveWidget}] if {${ed} != ""} { ${ed} FindText } else { bell } } method search_next {} { set ed [list_find_editor ${ActiveWidget}] if {${ed} != ""} { ${ed} FindNext -forwards } else { bell } } method search_prev {} { set ed [list_find_editor ${ActiveWidget}] if {${ed} != ""} { ${ed} FindNext -backwards } else { bell } } method search_replace {} { set ed [list_find_editor ${ActiveWidget}] if {${ed} != ""} { ${ed} Replace } else { bell } } proc Get_Selection {ed active_wdg} { # Get selection from current editor. if {${ed} != ""} { set string [Editor&::Get_XSelection ${ed}] } else { set string "" } # Get selection from current view. if {${string} == "" && ${ed} != ${active_wdg}} { set sel [${active_wdg} Selection] if {${sel} != ""} { set string [lindex ${sel} 1] set cls [lindex ${sel} 2] if {${cls} != ""} { set string "${cls} ${string}" } } } return ${string} } method search_definition {} { # Look for an editor. set ed [list_find_editor ${ActiveWidget}] # We use only the same editor, if the keep flag # is not seted. if {${keep} && ${ed} != ""} { set cmd "${ed} gotofile_cb" } else { set cmd "" } if {${ed} != ""} { return [Editor&::search_definition ${ed}] } set string [Get_Selection ${ed} ${ActiveWidget}] if {${string} == ""} { bell return } # Try to find method or function definition (don't bell) set ret [sn_retrieve_symbol ${string} {md fd fr} "" -exact 1 0 ${cmd}] # Try to find any definition (not implementation or function body) # (bell if nothing found) if {${ret} == 0} { sn_retrieve_symbol ${string} all "" -exact 1 1 ${cmd} "" "" "" "*"\ -1 {{mi md} {fu fd}} } } method search_implementation {} { set ed [list_find_editor ${ActiveWidget}] if {${keep} && ${ed} != ""} { set cmd "${ed} gotofile_cb" } else { set cmd "" } if {${ed} != ""} { return [Editor&::search_implementation ${ed}] } set string [Get_Selection ${ed} ${ActiveWidget}] if {${string} == ""} { bell return } #find implementation set ret [sn_retrieve_symbol ${string} {fu mi} "" -exact 1 0 ${cmd}] #find probably definition (correct for Tcl) if {${ret} == 0} { sn_retrieve_symbol ${string} {fd md fr} "" -exact 1 1 ${cmd} } } method search_gotoline {} { set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { bell return } ${ed} GotoLine } method search_setmark {} { set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { bell return } [${ed} editor] mark set markpos insert }# FIXME: Targeted for removal. proc search_gotoerror {} { if {[catch {sn_grep_edit_file [selection get]}]} { bell } } method search_gotomark {} { set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { bell return } set t [${ed} editor] ${t} mark set lastpos insert ${t} mark set insert markpos ${t} see insert } #Execute grep with selection, when there is no selection, #call grep dialog box method search_grep {} {# FIXME: this is not quite right just yet. Perhaps handle# the case where there is nothing selected???? #set ed [list_find_editor ${ActiveWidget}] #if {${ed} == ""} { # bell # return #} #sn_grep $itk_component(notebook) raise grep $itk_component(grep) setPatternFromClipboard $itk_component(grep) StartGrep } method search_goto_post {m} { } proc history_post {m} { sn_post_history_menu ${m} } method tools_post {m} { set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { set rcsstate disabled } else { if {[${ed} validFilename]} { set rcsstate normal } else { set rcsstate disabled } } # RCS submenu is disabled when the filename isn't valid $itk_component(rc_menu) entryconfig [get_indep String ChooseCheckOut] \ -state ${rcsstate} $itk_component(rc_menu) entryconfig [get_indep String ChooseCheckIn] -state ${rcsstate} $itk_component(rc_menu) entryconfig [get_indep String ChooseDiscard] -state ${rcsstate} $itk_component(rc_menu) entryconfig [get_indep String ChooseLock] -state ${rcsstate} $itk_component(rc_menu) entryconfig [get_indep String ChooseUnlock] -state ${rcsstate} $itk_component(rc_menu) entryconfig [get_indep String ChooseDiff] -state ${rcsstate} $itk_component(rc_menu) entryconfig [get_indep String RevisionControlEditor] \ -state ${rcsstate} } method tools_ctree_post {m} { } method tools_classbr_post {m} { } method tools_xref_post {m} { } method tools_incbr_post {m} { } #add breakpoint or execute until the specified line method tools_breakpoint_or_until {{until "break"}} { set ed [list_find_editor ${ActiveWidget}] if {${ed} == ""} { bell return } set idx [[${ed} editor] index insert] if {${idx} == ""} { bell return } dbg_set_breakpoint [${ed} cget -filename] ${idx} ${until} } proc windows_new_window {{m ""} {page "edit"}} { global tkeWinNumber incr tkeWinNumber #verify if the tool command exists if {${page} != "edit" && [tool_Exists ${page}] != "normal"} { bell return } return [MultiWindow& .multiwindow-${tkeWinNumber} -raise ${page}] } proc windows_new_post {m} { set edit_state [tool_Exists edit] set ctree_state [tool_Exists ctree] set xref_state [tool_Exists xref] set retr_state [tool_Exists retr] set grep_state [tool_Exists grep] set inc_state [tool_Exists incbr] ${m} entryconfig [get_indep String WindowsNew] -state ${edit_state} ${m} entryconfig [get_indep String MultiClassHierarchy]\ -state ${ctree_state} ${m} entryconfig [get_indep String MultiClass] -state ${edit_state} ${m} entryconfig [get_indep String MultiXRef] -state ${xref_state} ${m} entryconfig [get_indep String MultiInclude] -state ${inc_state} ${m} entryconfig [get_indep String WindowsNewCTreeClass]\ -state ${ctree_state} ${m} entryconfig [get_indep String WindowsNewClassEditor]\ -state ${ctree_state} if {${ctree_state} == "normal" && ${xref_state} == "normal"} { set state normal } else { set state disabled } ${m} entryconfig [get_indep String WindowsNewClassXRef] -state ${state} ${m} entryconfig [get_indep String WindowsNewRetrEditor]\ -state ${retr_state} ${m} entryconfig
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?