📄 misc.tcl
字号:
# 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.# # misc.tcl - Miscellaneous routines. # Copyright (C) 1998 Cygnus Solutions.# Put up splash graphic. Used for both splash screen and about box.# type is either 'splash' or 'about'. It is up to the caller to catch errors# generated by this routine. Returns the name of the window created.package require Itkproc sn_splash_dialog {type} { global sn_options sn_product_version global sn_path sn_product_name sn_suite_name global tcl_platform sn_elix set w .${type} sourcenav::Window ${w} wm withdraw ${w} ${w} configure -title [list ${sn_product_name}] sn_log "creating splash image [file join $sn_path(bitmapdir) splash.gif]]" image create photo cyg-sol -file [file join $sn_path(bitmapdir)\ splash.gif] -palette 0/0/8 ${w} configure -background white if {$tcl_platform(platform) == "windows"} { set font_large "Arial 10 bold" set font_small "Arial 8 bold" set font_super "Arial 6 bold" } else { set font_large [sn_make_font "" Bold 12] set font_small [sn_make_font "" Bold 10] set font_super [sn_make_font "" Bold 8] } label ${w}.logos -bg white -image cyg-sol text ${w}.text -bg white -relief flat -width 50 -highlightthickness 0\ -font ${font_large} -wrap word ${w}.text tag configure large -font ${font_large} ${w}.text tag configure small -font ${font_small} ${w}.text tag configure super -font ${font_super} -offset 6 ${w}.text tag configure center -justify center if {${sn_elix}} { ${w}.text insert end ${sn_suite_name} {center large} ${w}.text insert end "\n" {center large} } ${w}.text insert end ${sn_product_name} {center large} ${w}.text insert end "TM " {center super} ${w}.text insert end ${sn_product_version} {center large} ${w}.text insert end "\n\n" {center large} ${w}.text insert end [get_indep String SplashCopyrightText] {center large} ${w}.text insert end "\n" if {${type} == "about"} { ${w}.text insert end "\n\n" {center small} ${w}.text insert end [get_indep String SplashSubCopyrightText]\ {center small} ${w}.text insert end "\n\n" {center small} ${w}.text insert end [get_indep String SplashAllRightsReserved]\ {center small} # Make all of the TM strings superscript set search_index [${w}.text search -exact TM 0.0 end] while {${search_index} != {}} { ${w}.text tag add super ${search_index} "${search_index} +2 chars" set search_index [${w}.text index "${search_index} +2 chars"] set search_index [${w}.text search -exact TM ${search_index} end] } } set last_index [${w}.text index end] set num_lines [string range ${last_index} 0 [expr [string first\ "." ${last_index}] - 1]] set num_lines [expr ${num_lines} + 3] ${w}.text configure -height ${num_lines} pack ${w}.logos -side top pack ${w}.text ${w}.text config -state disabled catch {${w} resizable no no} return ${w}}proc sn_show_version_window {} { set w [sn_splash_dialog about] sn_motif_buttons ${w} bottom 0 [get_indep String ok] ${w}.button_0 configure -command " destroy ${w} set tkPriv(button) -1 " ${w} bind_tk <Return> "catch {${w}.button_0 invoke}" ${w} bind_tk <Escape> "catch {${w}.button_0 invoke}" catch {${w} grab set} ${w} move_to_mouse set tkPriv(button) "" tkwait variable tkPriv(button)}proc sn_show_splash_screen {} { global splash_start_time if {[winfo exists .splash]} { return } set splash_start_time [clock seconds] set w [sn_splash_dialog splash] wm overrideredirect ${w} 1 ${w} config_tk -relief solid -borderwidth 2 ${w} centerOnScreen ${w} deiconify# FIXME: Do we really need this call to take_focus here? ${w} take_focus #hide the window after a reasonable time, don't #wait in active mode global splash_screen_open set splash_screen_open "open" after 2500 "destroy .splash; set splash_screen_open closed" tkwait variable splash_screen_open}proc find_reusable_window {pat {raise 1}} { foreach w [sn_get_windows ${pat}] { upvar #0 ${w}.reusable reuse if {${reuse}} { if {${raise}} { if {[wm state ${w}] != "normal"} { wm deiconify ${w} } else { raise ${w} } } return ${w} } } return ""}proc convert_scope_to_num {scope} { switch ${scope}\ "all" { return [get_indep Pos All] }\ "cl" { return [get_indep Pos Classes] }\ "com" { return [get_indep Pos Commons] }\ "con" { return [get_indep Pos Const] }\ "cov" { return [get_indep Pos CommonsVars] }\ "iu" { return [get_indep Pos Includes] }\ "e" { return [get_indep Pos Enums] }\ "ec" { return [get_indep Pos EnumCons] }\ "f" { return [get_indep Pos Files] }\ "fr" { return [get_indep Pos Friends] }\ "fu" { return [get_indep Pos Functions] }\ "fd" { return [get_indep Pos FunctionsDec] }\ "gv" { return [get_indep Pos Variables] }\ "iv" { return [get_indep Pos ClassVars] }\ "iu" { return [get_indep Pos Includes] }\ "lv" { return [get_indep Pos PafLocVars] }\ "ma" { return [get_indep Pos Defines] }\ "md" { return [get_indep Pos Methods] }\ "mi" { return [get_indep Pos MethodImps] }\ "su" { return [get_indep Pos Subr] }\ "t" { return [get_indep Pos Typedefs] }\ "ud" { return [get_indep Pos Undefined] }\ "un" { return [get_indep Pos Unions] } return 0}proc convert_scope_to_str {scope} { switch ${scope}\ "all" { return [get_indep String All] }\ "cl" { return [get_indep String Classes] }\ "com" { return [get_indep String Commons] }\ "con" { return [get_indep String Const] }\ "cov" { return [get_indep String CommonsVars] }\ "iu" { return [get_indep String Includes] }\ "e" { return [get_indep String Enums] }\ "ec" { return [get_indep String EnumCons] }\ "f" { return [get_indep String Files] }\ "fr" { return [get_indep String Friends] }\ "fu" { return [get_indep String Functions] }\ "fd" { return [get_indep String FunctionsDec] }\ "gv" { return [get_indep String Variables] }\ "iv" { return [get_indep String ClassVars] }\ "iu" { return [get_indep String Includes] }\ "lv" { return [get_indep String PafLocVars] }\ "ma" { return [get_indep String Defines] }\ "md" { return [get_indep String Methods] }\ "mi" { return [get_indep String MethodImps] }\ "su" { return [get_indep String Subr] }\ "t" { return [get_indep String Typedefs] }\ "ud" { return [get_indep String Undefined] }\ "un" { return [get_indep String Unions] } return ""}proc convert_scope_to_plain_str {scope} { switch ${scope}\ "all" { return [get_indep String All] }\ "cl" { return [get_indep String ClassesNoKey] }\ "com" { return [get_indep String CommonsNoKey] }\ "con" { return [get_indep String ConstantsNoKey] }\ "cov" { return [get_indep String CommonsVarsNoKey] }\ "iu" { return [get_indep String IncludeNoKey] }\ "e" { return [get_indep String Enums] }\ "ec" { return [get_indep String EnumConsNoKey] }\ "f" { return [get_indep String Files] }\ "fr" { return [get_indep String FriendsNoKey] }\ "fu" { return [get_indep String FunctionsNoKey] }\ "fd" { return [get_indep String FunctionsDecNoKey] }\ "gv" { return [get_indep String VariablesNoKey] }\ "iv" { return [get_indep String ClassVarsNoKey] }\ "iu" { return [get_indep String IncludeNoKey] }\ "lv" { return [get_indep String PafLocVars] }\ "ma" { return [get_indep String DefinesNoKey] }\ "md" { return [get_indep String MethodsNoKey] }\ "mi" { return [get_indep String MethodImpsNoKey] }\ "su" { return [get_indep String SubroutinesNoKey] }\ "t" { return [get_indep String Typedefs] }\ "ud" { return [get_indep String Undefined] }\ "un" { return [get_indep String UnionsNoKey] } return ""}proc convert_scope_to_sym {scope} { switch ${scope}\ [get_indep String Classes] { return "cl" }\ [get_indep String Functions] { return "fu" }\ [get_indep String FunctionsDec] { return "fd" }\ [get_indep String Commons] { return "com" }\ [get_indep String CommonsVars] { return "cov" }\ [get_indep String Methods] { return "md" }\ [get_indep String MethodImps] { return "mi" }\ [get_indep String ClassVars] { return "iv" }\ [get_indep String Typedefs] { return "t" }\ [get_indep String Variables] { return "gv" }\ [get_indep String Enums] { return "e" }\ [get_indep String EnumCons] { return "ec"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -