📄 makepane.tcl
字号:
set pos [lindex ${pars} 1] set file [sn_convert_FileName ${file}] return [list ${file} ${pos}] } method filter {{all 0}} { } method activate {} { if {${symbols} != "" &&(${next} == "" || [${next} whoami] != "edit")} { #delete old contents ${symbols} configure -contents "" ${symbols} selecttext "" ${symbols} configure -state disabled } if {${toolbarf} != ""} { pack ${toolbarf} -side left } } method deactivate {} { if {${symbols} != "" &&(${next} == "" || [${next} whoami] != "edit")} { ${symbols} configure -state disabled } if {${menu} != ""} { } if {${toolbarf} != ""} { pack forget ${toolbarf} } } #this function is called, when the symbols combobox #is called method postcommand {m} { } method Selection {} { global tcl_platform set sel [Split_Line] if {${sel} != ""} { set file [lindex ${sel} 0] set line [lindex ${sel} 1] if {$tcl_platform(platform) != "windows"} { set last [string last "/" ${file}] set len [string length ${file}] #sometimes we get strang results from\ 'sn_goto_comp_error_or_grep' if {${last} != -1 && [expr ${last} + 1] == ${len} ||\ [string first "**" ${file}] == 0} { set file "" set line "" } } } else { set file "" set line "" } return [list "" "" "" ${file} ${line} "" "" ""] } method gotosymbol {{scope ""} {sym ""} {cls ""} {file ""} {from ""} {type\ ""} {prm ""} {to ""} {always 1}} { if {${sym} != ""} { #convert string to be used for make regsub -all {\^|\\|\.|\*|\$|\-|\[|\]} ${sym} {\\&} sym regsub -all {\<|\>} ${sym} {[&]} sym } return 1 } method clearselection {} { ${browser} tag remove sel 0.0 end } method Update_Layout {} { global sn_options ${browser} configure -font $sn_options(def,default-font)\ -selectforeground $sn_options(def,select-fg)\ -selectbackground $sn_options(def,select-bg) } method Focus {} { focus ${browser} } #make a title for the Dump position, this is usefull #for the views stack (prev/next) method DumpTitle {{dump ""}} { if {${dump} == ""} { set dump [Dump] } set scp [lindex ${dump} 0] set sym [lindex ${dump} 1] set cls [lindex ${dump} 2] set name [string trim "${sym}(${scp}) ${cls}"] return "Make ${name}" } method AddHistoryFromDump {dump title} { } #return the important data to restore this widget #in later time again (used by saving the project) method Dump {} { return [Selection] } #gets the result from the function "Dump" to #restore the older state (used by restoring the project) method Restore {str} { eval ${this} gotosymbol ${str} #Focus } method Close {{mode 0}} { return 1 } method whoami {} { return make } method next {} { return ${next} }# FIXME: This is currently broken, need to figure out where it is used. #if an editor is added to the make, call the #goto function of the editor method goto {combo txt} { if {${next} != "" && [${next} whoami] == "edit"} { #dump the current view into the history stack ${topw} history_stack_add_point ${next} ${next} goto ${combo} ${txt} } } method make_select_command {combo txt} { global sn_options global ${this}-makecommand set i [[${combo} component treew] search -exact -- ${txt} 0] if {${i} != ""} { set txt [lindex $sn_options(make_history_cmd) ${i}] set ${this}-makecommand [lindex ${txt} 0] set startdir [lindex ${txt} 1] } } #command history with directory proc make_history_moveup {cmdw cmddir} { global sn_options #add pattern into the history stack sn_add_to_histroy_stack sn_options(make_history_cmd) ${cmddir} #add the new history to the combo box set elms "" foreach el $sn_options(make_history_cmd) { lappend elms "[lindex ${el} 0] <[lindex ${el} end]>" } ${cmdw} configure -contents ${elms} } proc make_add_history {cmdw dirw} { global sn_options set cmd [${cmdw} cget -entrytext] set dir [${dirw} cget -entrytext] #command history with directory if {${cmd} != ""} { set cmddir [list ${cmd} ${dir}] sn_add_to_histroy_stack sn_options(make_history_cmd) ${cmddir} } #add the new history to the combo box set elms "" foreach el $sn_options(make_history_cmd) { lappend elms "[lindex ${el} 0] <[lindex ${el} end]>" } ${cmdw} configure -contents ${elms} #directory list if {${dir} != "" && [file isdir ${dir}]} { sn_add_to_histroy_stack sn_options(make_history_dir) ${dir} } ${dirw} configure -contents $sn_options(make_history_dir) } private method dispatch_MakeEvent {} { if {[catch {set res [gets ${make_fd} line]} err]} { sn_log "caught make pipe error \"$err\"" ${this} close_make return } sn_log "read $res bytes, eof is [eof ${make_fd}], line is \"$line\"" if {${res} == -1 && [string length $line] == 0 && ![eof ${make_fd}]} { # This means a read returned no data but the channel is # not at EOF, this can happen when cmd prints to stderr # handle this case by simply doing nothing. return } elseif {${res} > 0} { ${browser} configure -state normal ${browser} insert end ${line}\n ${browser} configure -state disabled if {! ${ButtonPressed}} { if {[${browser} tag ranges sel] == {}} { ${browser} see end } } } elseif {${res} < 0} { ${this} close_make } update idletasks } # Variables used in implementing custom listbox like # bindings on the text widet private variable text_b1_really_up_after "" private variable text_b1_current_line_num -1 private variable text_current_line private variable ButtonPressed 0 private variable target private variable startdir "" protected variable make_fd "" protected variable Proceed 0 protected variable entries "" protected variable btns "" protected variable toolbarf "" # Text widget that stores the lines # of output from the make command. protected variable browser "" #don't close window after selecting an entry public variable hold 1 public variable width 80 public variable height 10 public variable symbols "" public variable symbols_filter "" itk_option define -toolbar toolbar ToolBar "" itk_option define -mesg_area mesg_area MsgArea "" public variable selectcommand "" public variable doubleclickcommand "" public variable cancelcommand "" #contains the next widget, when the window is spliten #into more than one area #Simulate a single chain public variable next ""}#returns the object file of a source fileproc sn_object_file {file} { global tcl_platform set i [string last "." ${file}] if {$tcl_platform(platform) == "windows"} { set obj "obj" } else { set obj "o" } #file contains no extension if {${i} < 1} { return ${file}.${obj} } return [string range ${file} 0 ${i}]${obj}}proc sn_make {} { global sn_options global tkeWinNumber set s [find_reusable_window "make-"] if {${s} == ""} { incr tkeWinNumber set s .sn-make-${tkeWinNumber} sn_create_window ${s} 1 Make ${s}.make -toolbar ${s}.exp -mesg_area ${s}.status.msg pack ${s}.make -expand y -fill both -side left set menu [${s} cget -menu] set toolmenu [menu .make_tool_menu${tkeWinNumber} -tearoff 0]# FIXME: Add to string table ${menu} insert 3 cascade -menu ${toolmenu} -label "Tools" add_make_tools_menu ${toolmenu} ${s}.make # FIXME : This should be converted to a non-modal Dialog. ${s} withdraw ${s} centerOnScreen ${s} deiconify ${s} raise } else { ${s} raise } return ${s}}proc add_make_tools_menu {tools_menu w_make} { ${tools_menu} insert 10 command -label "Build" -command " ${w_make}\ ExecMake " ${tools_menu} insert 11 command -label "Force Build" -command " ${w_make}\ ExecMake forced " ${tools_menu} insert 12 command -label "Clean Build" -command " ${w_make}\ ExecMake clean " ${tools_menu} add separator ${tools_menu} add command -label "Export Makefile..." -command " ${w_make}\ ExportMakefile "}# This method will be invoked when the user right clicks# in the output window. This code is copied from the# browser class. This is a really sucky way to extend# a widget but we need to ship the product!proc make_post_menu {w x y} { set m .sn_pop_menu_listbox # It has to be destroyed because we might have problems with "tk_popup"! catch {destroy ${m}} menu ${m} -tearoff 0 -postcommand "make_post_menu_update ${m} ${w}" wm overrideredirect ${m} 1 tk_popup ${m} ${x} ${y}}# This will be invoked when the menu is actually ready to displayproc make_post_menu_update {m w} { ${m} delete 0 end ${m} add command -label [get_indep String SaveBufferAs] -command\ " make_respond_to_save_as ${m} ${w} "}# This will be called if they choose "save as" from right click menuproc make_respond_to_save_as {m w} { global sn_options # Get a file name to save the buffer as! set file [tk_getSaveFile -initialfile build.out] # They clicked Cancel if {${file} == ""} { return } # write the contents of the widget into the file if {[catch {open ${file} w} fd]} { sn_error_dialog "${fd}" return } fconfigure ${fd} -encoding $sn_options(def,system-encoding) -blocking 0 puts ${fd} [${w} get 0.0 end] close ${fd}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -