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

📄 sninit.tcl

📁 This Source-Navigator, an IDE for C/C++/Fortran/Java/Tcl/PHP/Python and a host of other languages.
💻 TCL
📖 第 1 页 / 共 4 页
字号:
# Copyright (c) 2000, 2001, 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.# # init.tcl - Miscellaneous initialisation routines.# Copyright (C) 1998 Cygnus Solutions.#Initialize Source-Navigator mostly for default settings## Description for sninit.tcl and preferences.tcl:#The problem here that the preferences are stored ones in project#and possibly another time in the default preferences. This means#that the project settings override default settings. the#default settings are only used when you create a project.#This is a bug. We have to define the settings that are#	- project related#	- global settings (like font, color, ..)##I'm going to do this ASAP. For now if you want to change fonts#in Preferences click the button "Save As Default". This will#affect only _new_ projects.##Now the Preferences loading process is described as followed:#1. SN is launched:#	sninit.tcl is started and default settings are#	loaded.#2. ~/.sn/profile is loaded#3. SN looks afterthere for a file ~/.sn/project.pre, if#   it is availiable, it load it's contents, now it overrides#   the most default settings.#4. New created projects will use the settings in 1-3.#5. When you launch a project, it's own settings will be loaded.##Every step overrides the previous one. This is correct, but#needs to define what can be overriden and what not.#However there are some variables that are made as exception!!#1. Defined three levels for configuration settings.##   A. System variables (sys,)#        All parameters that are normally set by startup to define#        platform dependent settings have the prefix "sys,".#        This variables are not saved/restored into/from the#        preferences settings.#        Example: iscolor, alt-traverse##   B. Global settings (def,)#        This settings are valid for every SN session. This settings#        are stored in the user's file ~/.sn/project.pre. They are not#        part of the project settings.#        Example: all color/font settings, language, parser extensions##   C. Project and Default settings (both,)#        This are settings that need to be set for projects, as example#        by creation, but should take effect for next new projects.#        They have all the prefix "both,". There is only a few of those.#        This settings are stored both in global and project settings.#        Example: xref-locals, db-directory##   D. Project settings#        All other settings without a prefix of the upove are project#        dependent only. The most of them are used internally.#        Example: readonly, history##   The point here is that we use only one array to store all of them.#   - This reduces mistakes and#   - get out of failed (alot of) global initializations and#   - Self description of the source code, first look to know#     what kind of parameter is going on.#   - A clear and reasonable way to follow up how things are implemented#     in SN.##2. Exported settable parameters for users#   Before, it was possible to set every parameter in SN. It was even#   possible to unset a parameter using the "profile" file (using a "%").#   This is bad because#        -SN crashes when user specify invalid parameters#        -Not possible to test the options for valid data. #        -Only tcl freaks can work with this stuff (not all of them)#        -Only SN has this way of doing things#        -Not documented##   Now we have the possibility to "export" whitch options are settable:#        -Export parameters that can be changed from customers#        -Don't allow changing another parameters#        -Test settings for it's validy.#        -Start SN always with valid data.##   ***Internal an interface has been made for exporting variables:#        proc sn_add_option \#            {cat var {value ""} {type "string"} {trigger ""} {valid ""}}##   "cat" defines how to classify the option "def, both, sys or ''".##   It has the following important features:#        -It's possible to define a callback procedure to be executed#         when customers are trying to modify an option.#         There are some default triggers, like sn_notempty_trigger.##         Example: parser-ext is handled internal, to make possible to set#         another values, it calls a callback procedure supporting the#         command line argument but store the information to be used in SN:##                sn_add_option sys parser-ext ""\  "string" sn_parser_extension_trigger##         The function sn_parser_extension_trigger is automatically called to#         set the user specification and tests it for it's validy.##        -Defines a set of possible values.##         Example: report-bugs can be be only "www" or "mail", initial is "www"##                sn_add_option def report-bugs "www" "logical" "" {www mail}##         Another example, a logical variable "xref" is used to define#         "xref-create", where the last is a command line argument for the#         parser (-x). The user shouldn't use "xref-create=-x", but rather#         tells "xref=yes" or "xref=no".##         By default logical variables are tested for {yes no y n 1 0}##        -Lists all availiable settable parameters and can provide ways to#advice#         the user for correct settings.###        -Open. It's open to be extended to support more functionality. As#         Example, we can extend it to display more help for every settable#         parameter.###        -Makes sure that the user deliver correct settings.###        -Reasonable for not tcl users.##   Just now exported variables are:#        readonly, xref, html-viewer, make-command,#        ascii-print-command, browser-spacing, gdb-command,#        rcs-type, language, encoding, parser-ext##3. Naming confentions of variables.#   All possible styles were used in SN to define option variables. Like#        Using "_":#                sn_sym_dir, paf_source_dirs#        Using all combinations of Upper/Lower and "_":#                Xref_CreateCrossRef, edit_TabSize##   The fact that command line arguments don't have "_" and don't use    #   Upper/Lower combinations, I have choosen the way to set variables,#   like:#                db-directory                    (older sn_sym_dir)#                include-source-directories      (older paf_source_dirs)#                select-bg                       (older sel-background)#                xref-create                     (older Xref_CreateCrossRef)#                ...##   All (also not exported) option names have been renamed in this way.#   I even tried to rename those to understand what this variable is#   doing. It was alot of work!##4. Load/Save Preferences#   This was a big problem in SN. It hasn't worked correct when an option#   has been renamed or deleted. As example integer variables could be#   read as empty and will crash SN.#   Now it's possible to#        -Rename/delete every variable you want#        -SN will discover if a variable is correct stored#        -No need to use nasty catch commands to avoid somelike problems.#        -Backward compatipility is guaranteed.#         Because the Database has been changed since 4.1, we can only#         Load projects from 4.1 (without reparsing).    #         More older projects need to be reparsed.#################################################################################set copyright "Copyright (c) 1997-2000 Red Hat, Inc.\n All rights\  reserved."#force flag#on windows we must force focusing the window#on unix, let the window manager do this.if {$tcl_platform(platform) == "windows"} {    set sn_force_flag "-force"} else {    set sn_force_flag ""}# The standard Tcl auto_reset proc is buggy.# NOTE: The script just lets you to use the .tcl files instead of# the .tob ones.proc sn_auto_reset {path} {    global auto_execs auto_index auto_oldpath auto_path    sn_log "auto reset ${path}"    # Unload every known itcl class because they have to be loaded again!    set classes [itcl_info classes]    if {${classes} != ""} {        catch {itcl_unload ${classes}}    }    set ignore {unknown pkg_mkIndex tclPkgSetup tclPkgUnknown}    foreach p [info procs] {        if {[info exists auto_index(${p})] && ![string match auto_* ${p}] &&\          [string first {.tob} $auto_index(${p})] > 0 &&([lsearch\          -exact ${ignore} ${p}] < 0)} {            catch {rename ${p} {}}        }    }    catch {unset auto_execs}    catch {unset auto_index}    catch {unset auto_oldpath}    set auto_path [linsert ${auto_path} 0 [realpath -pwd [pwd] ${path}]]    sn_log "auto_path changed to <${auto_path}>"}#define_font is the way to set fonts for windows. It's dynamic#and fonts will be automatically changed in SN when the user#changes his default font settings in Windows preferences.proc init_some_font_attributes {} {    global sn_options tcl_platform    if {$tcl_platform(platform) == "windows"} {        set sn_options(def,font-family) "*"        set sn_options(def,font-size) "*"        set sn_options(def,balloon-font-size) "*"        catch {font delete global/default}        define_font global/default -family ansi        set sn_options(def,layout-font) ansi        set sn_options(def,layout-fg) SystemMenuText        set sn_options(def,layout-bg) SystemMenu    } else {        set sn_options(def,font-family) "Adobe"        set sn_options(def,font-size) "120"        set sn_options(def,balloon-font-size) "100"        set sn_options(def,layout-font)\          "-$sn_options(def,font-family)-Helvetica-Medium-R-Normal--*-$sn_options(def,font-size)-*-*-*-*-iso8859-1"        set sn_options(def,layout-fg) black        #darkgray        set sn_options(def,layout-bg) "#c0c0c0"    }}# initializes global variables.proc sn_init_globals {} {    uplevel #0 {        #window counter        set tkeWinNumber 0        #SN scopes        #in: Inheritences        #iu: Include        #iv: Instance variables        #lv: Local variables        set sn_general_scopes [lsort {cl con e ec fd fr fu gv iv ma md mi t un}]        set sn_fortran_scopes [lsort {fu com con cov su}]        set sn_local_scopes [lsort {in iv lv ud}]        set sn_other_scopes [lsort {fil in iu lv ud}]        set sn_current_scopes ${sn_general_scopes}        set sn_scopes ${sn_general_scopes}        set sn_all_scopes ""        eval lappend sn_all_scopes ${sn_general_scopes} ${sn_fortran_scopes}\          ${sn_other_scopes}        set sn_all_scopes [lsort ${sn_all_scopes}]        #init more internal variables        set ProcessingCancelled 0        set tkeWinNumber 0        set sn_statistic_run 0        if {${sn_debug}} {            set env(SN_DBIMP) 1        }        # Do not allow the exec command to exec unknown commands!        set auto_noexec 1    }    uplevel #0 {        #now we use an array for SN options        global sn_options env        global sn_path        global sn_root        #make sure that env(HOME) exists        if {! [info exists env(HOME)] || $env(HOME) == ""} {            if {$tcl_platform(platform) == "windows"} {                if {[info exists env(USERPROFILE)]} {                    set env(HOME) env(USERPROFILE)                } else {                    set env(HOME) "C:${sn_root}"                }            } else {                set env(HOME) ${sn_root}            }        }        #project settings        #export database directory to be not empty.        sn_add_option both db-directory ".snprj" string        #export project-readonly flag        sn_add_option "" readonly no logical        set sn_options(project_extensions) [list [list {Project files}\          {*.proj}] [list {All files} {*}]]        #extension for executables        if {$tcl_platform(platform) == "windows"} {            set sn_options(executable_ext) [list [list {Executables}\              {*.exe;*.com}] [list {All files} {*}]]            set sn_options(executable_defaultext) ".exe"        } else {            set sn_options(executable_ext) [list [list {All files} {*}]]            set sn_options(executable_defaultext) ""        }        #database        set sn_options(both,user-read) 1        set sn_options(both,user-write) 1        set sn_options(both,group-read) 1        set sn_options(both,group-write) 1        set sn_options(both,others-read) 0        set sn_options(both,others-write) 0        set sn_options(both,create-comment-db) ""        set sn_options(def,db_cachesize) 300        set sn_options(def,xref-db-cachesize) 3000        sn_add_option def refresh-project "0" "logical"        #parser switches to use.        set sn_options(sys,parser_switches) "-x"        if {$tcl_platform(platform) == "windows"} {            set y [winfo screenheight .]            if {${y} <= 480} {                set sn_options(def,desktop-font-size) 8            } else {                set sn_options(def,desktop-font-size) 12            }        } else {            set sn_options(def,desktop-font-size) 12        }        init_some_font_attributes        if {$tcl_platform(platform) == "windows"} {            define_font global/fixed -family ansi            set sn_options(def,default-font) ansi            set sn_options(def,default-fg) SystemWindowText            set sn_options(def,default-bg) SystemWindow            set sn_options(def,highlight-fg) SystemWindowText            set sn_options(def,highlight-bg) SystemWindow        } else {            set sn_options(def,default-font)\              "-$sn_options(def,font-family)-Courier-Medium-R-Normal--*-$sn_options(def,font-size)-*-*-*-*-iso8859-1"            set sn_options(def,default-fg) black            set sn_options(def,default-bg) white            set sn_options(def,highlight-fg) black            set sn_options(def,highlight-bg) "#c0c0c0"        }        #color for the border around the widget, should be the same        #as the background        if {$tcl_platform(platform) == "windows"} {            #bold font            define_font global/bold -family ansi -weight bold            set sn_options(def,bold-font) global/bold            set sn_options(def,select-fg) SystemHighlightText            set sn_options(def,select-bg) SystemHighlight        } else {            #bold font            set sn_options(def,bold-font)\              "-$sn_options(def,font-family)-Courier-Bold-R-Normal--*-$sn_options(def,font-size)-*-*-*-*-iso8859-1"            if {$sn_options(iscolor)} {

⌨️ 快捷键说明

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