⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makepane.tcl

📁 This Source-Navigator, an IDE for C/C++/Fortran/Java/Tcl/PHP/Python and a host of other languages.
💻 TCL
📖 第 1 页 / 共 3 页
字号:
    method ExportMakefile {} {        sn_log "IDE_DEBUG(Make target_cb): target = ${target} "        if {${target} == "<External Makefile>"} {            # We cannot generate a Makefile for this.            bell            return        } else {            # Get the filename and path which will be            # used to save the Makefile.            set filename [tk_getSaveFile]            if {${filename}!=""} {                # Generate the Makefile                set mkgen [MakefileGen .mkg_save_mkfile ${target}]                set mkfile [${mkgen} GenerateMakefile ${filename}]                itcl::delete object .mkg_save_mkfile            }        }    }    method ExecMake {{build_action ""}} {        global sn_options        upvar #0 ${this}-makecommand makecommand        #make is running        if {${Proceed} != 0} {            close_make            return        }        #verify if all files are saved        set modified 0        foreach editor [itcl_info objects "*" -class Editor&] {            if {[${editor} cget -file_changed]} {                set modified 1            }        }        #ask to save changed files before running make        if {${modified}} {            set answer [tk_dialog auto [get_indep String MultiMake]\              [get_indep String WantToFastSave] error_image 0\              [get_indep String Yes] [get_indep String No] [get_indep String\              Cancel]]            if {${answer} == 2} {                return            }            if {${answer} == 0} {                Editor&::SaveAll            }        }        #add command and directory to history        make_add_history ${entries}.entry ${entries}.dir        # if user requires a make -k or make clean        # doesn't get it from the GUI widget.        if {${build_action}==""} {            #read make command            get_make_cmd make_cmd        } else {            set make_cmd [file nativename $sn_options(both,make-command)]        }        # Check to see if we are executing a        # users Makefile or an SN build target.        if {${target}!="<External Makefile>"} {            # We are building an SN build target.            set mkgen [MakefileGen .mkg ${target}]            set mkfile [${mkgen} GenerateMakefile]            itcl::delete object ${mkgen}            # Only pass the last component of the            # Makefile path as the -f argument.            set mkfile [file tail $mkfile]            set make_cmd "${make_cmd} -f ${mkfile}"            # If we are building an embedded target            # we need to generate the .runcfg file.            global sn_elix            set b_target [snBuildTarget .tmptarget]            ${b_target} LoadData ${target}            set tool_chain [GetToolChainObject [${b_target} GetToolChain]]            if {${sn_elix} && [${tool_chain} GetIsEmbedded]} {                global sn_options                set prefix [file join [pwd] [${b_target} GetBuildDirectory]]/                set fd [open ${prefix}.runcfg w]                fconfigure ${fd} \                    -encoding $sn_options(def,system-encoding) \                    -blocking 0                set cmd [Elix&::make_config_command\                  [${tool_chain} GetShortName] ${prefix}]                puts ${fd} ${cmd}                close ${fd}            }            itcl::delete object ${b_target}        }        # Do we have to force rebuild        if {${build_action}=="forced"} {            # Everything to be rebuilt.            set make_cmd "${make_cmd} -k"        }\        elseif {${build_action}=="clean"} {            set make_cmd "${make_cmd} clean"        } elseif {${target}!="<External Makefile>"} {            set b_target [snBuildTarget .tmptarget]            ${b_target} LoadData ${target}            if {[${b_target} GetNeedsRebuild]} {                set make_cmd "${make_cmd} clean all"                ${b_target} SetNeedsRebuild 0                ${b_target} SaveData            }            itcl::delete object ${b_target}        }        #on window we must mask all "\"        regsub -all {\\} ${make_cmd} {\\\\} make_cmd        # Bah! Tcl provides no way to read both        # stdout and stderr from a pipe so we        # pipe them both to cat and read that.        lappend make_cmd |& cat        #1. store last used make directory        if {[file isdirectory ${startdir}]} {            set sn_options(make-lastdir) ${startdir}            #change to make directory            catch {cd ${startdir}}        }        #2. start command        sn_log "Executing make: ${make_cmd} in directory [pwd]"        set ret [catch {set make_fd [open "| ${make_cmd}" r]} msg]        #3. cd back to the project directory        cd $sn_options(sys,project-dir)        if {${ret}} {            sn_error_dialog "${make_cmd}:\n${msg}"            return        }        sn_log "encoding is -encoding $sn_options(def,system-encoding)"        fconfigure ${make_fd} \            -encoding $sn_options(def,system-encoding) \            -blocking 0 \            -buffering line        fileevent ${make_fd} readable [itcl::code $this dispatch_MakeEvent]        handle_proceed disabled    }    method get_make_cmd {make_cmd} {        global sn_options        global env tcl_platform        upvar #0 ${this}-makecommand makecommand        upvar ${make_cmd} cmd        #don't return it as a list element.        set cmd ${makecommand}        return ${cmd}    }    method close_make {{cancel ""}} {        handle_proceed normal ${cancel}        bell    }    #disable/enable input fields when the process is running/terminated    method handle_proceed {state {cancel ""}} {        set ButtonPressed 0        if {${state} == "normal"} {            if {[catch {close ${make_fd}} err]} {	        sn_log "caught make close error \"$err\""	    }            ${browser} configure -state normal            if {${cancel} == "cancel"} {# FIXME: put in string table!                set endstr "*** Canceled ***"            } else {                set endstr "+++ End +++"            }            ${browser} insert end ${endstr}            ${browser} configure -state disabled            if {${toolbarf} != ""} {                ${toolbarf}.prev configure -state normal                ${toolbarf}.next configure -state normal            }            ${btns}.start configure -state normal            ${btns}.cancel configure -state disabled            ${btns}.launch configure -state normal            ${entries}.entry.choose configure -state normal            ${entries}.entry configure -state normal            if {${target} == "<External Makefile>"} {                ${entries}.dir.choose configure -state normal                ${entries}.dir configure -state normal            }            ${entries}.targets configure -state normal            set Proceed 0        } else {            # The make is now running            set Proceed 1            ${browser} configure -state normal            ${browser} delete 0.0 end            ${browser} configure -state disabled            if {${toolbarf} != ""} {                ${toolbarf}.prev configure -state disabled                ${toolbarf}.next configure -state disabled            }            ${btns}.start configure -state disabled            ${btns}.cancel configure -state normal            ${btns}.launch configure -state disabled            ${entries}.entry.choose configure -state disabled            ${entries}.entry configure -state disabled            ${entries}.dir.choose configure -state disabled            ${entries}.dir configure -state disabled            ${entries}.targets configure -state disabled        }    }    method Title {{full 1}} {        global sn_options        set t [string trimright [get_indep String MultiMake] "."]        set txt [${entries}.entry cget -entrytext]        if {${txt} != ""} {            set t "${t}: ${txt}"        }        if {${full}} {            return [sn_title ${t}]        } else {            return ${t}        }    }    method Icon {} {        return [sn_view_icon [get_indep String MultiMake]]    }    method SetTitle {} {	set top [winfo toplevel $itk_component(hull)]	${top} configure -title [Title] -iconname [Icon]    }    method handle_return {} {	set ind [lindex [${browser} tag ranges sel] 0]	sn_log "handle_return index is $ind"        if {$ind != ""} {            ${browser} tag remove sel 0.0 end            ${browser} tag add sel [list $ind linestart] [list $ind lineend + 1c]            set res [sn_make_edit_file [${browser} get [list $ind linestart]\              [list $ind lineend]]]            if {${res} == "" && !${hold}} {                itcl::delete object $this            }        }        set ButtonPressed 1    }    # A single click will select a given line, if we have    # an split pane goto the given symbol in the other pane    private method handle_single_click {} {        sn_log handle_single_click        if {${selectcommand} != ""} {            eval ${selectcommand} [Selection]        }        set ButtonPressed 1    }    # These methods handle our custom interaction with the    # text widget. We use a text widget like it is a listbox    # so we have to do our own special bindings.    private method text_b1_down { w x y } {        # Get the line number at the given x y position        set line [lindex [split [$w index @$x,$y] .] 0]        text_select_line $line        bind $w <ButtonRelease-1> [itcl::code $this text_b1_up %W %x %y]    }    private method text_b1_motion { w x y } {        # Get the line number at the given x y position        set line [lindex [split [$w index @$x,$y] .] 0]        text_select_line $line    }    private method text_b1_up { w x y } {        sn_log "text_b1_up"        set text_b1_really_up_after [after 500 [itcl::code $this handle_single_click]]    }    private method text_b1_double { w x y } {        after cancel $text_b1_really_up_after        bind $w <ButtonRelease-1> {}        sn_log "makepane Text -> Button double $text_b1_current_line_num"        $this handle_return    }    # Highlight the given line in the grep results    private method text_select_line { linenum } {        sn_log "text_select_line $linenum"        if {$linenum == $text_b1_current_line_num} {            return        }        set w $browser        $w tag remove sel 0.0 end        $w tag add sel $linenum.0 [list $linenum.0 lineend]        $w see $linenum.0        set text_b1_current_line_num $linenum        set text_current_line [$w get $linenum.0 [list $linenum.0 lineend]]        sn_log "new selected line_num is $text_b1_current_line_num, line is \"$text_current_line\""    }    # Move the selected line up or down by one element    private method incr_selected_line { amount } {        if {$amount != "+1" && $amount != "-1"} {            error "incr amount must be +1 or -1, you gave \"$amount\""                    }        # Get last index and take last newline into account        set lastline [lindex [split [$browser index end] .] 0]        incr lastline -1        set nextline [expr {$text_b1_current_line_num + $amount}]        if {$nextline == 0} {            # Text widget treats line 0 as line 1            text_select_line $lastline        } elseif {$nextline > $lastline} {            # If they are on the last line, shoot them back to line 1            text_select_line 1        } else {            text_select_line $nextline        }    }    method Split_Line {} {        global sn_options        set rng [${browser} tag ranges sel]        if {${rng} == ""} {            return ""        }        set line [eval ${browser} get ${rng}]        if {${line} == ""} {            return        }        set pars [sn_goto_comp_error_or_grep ${line}]        if {${pars} == ""} {            return ""        }        set file [lindex ${pars} 0]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -