diff options
author | Andrej Shadura <andrewsh@debian.org> | 2018-05-08 15:59:31 +0200 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2018-05-08 15:59:31 +0200 |
commit | 47aa8b00b2b11df13a100489e0f904a4947177ef (patch) | |
tree | b35c9acc778ea2f761f3c549f7bee2f4491b3144 /lib/bottompanel/find_in_files.tcl | |
parent | 5b8466f7fae0e071c0f4eda13051c93313910028 (diff) |
Import Upstream version 1.4.7
Diffstat (limited to 'lib/bottompanel/find_in_files.tcl')
-rw-r--r--[-rwxr-xr-x] | lib/bottompanel/find_in_files.tcl | 133 |
1 files changed, 77 insertions, 56 deletions
diff --git a/lib/bottompanel/find_in_files.tcl b/lib/bottompanel/find_in_files.tcl index d085110..dccc823 100755..100644 --- a/lib/bottompanel/find_in_files.tcl +++ b/lib/bottompanel/find_in_files.tcl @@ -2,7 +2,7 @@ # Part of MCU 8051 IDE ( http://mcu8051ide.sf.net ) ############################################################################ -# Copyright (C) 2007-2009 by Martin Ošmera # +# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera # # martin.osmera@gmail.com # # # # This program is free software; you can redistribute it and#or modify # @@ -21,6 +21,11 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################ +# >>> File inclusion guard +if { ! [ info exists _FIND_IN_FILES_TCL ] } { +set _FIND_IN_FILES_TCL _ +# <<< File inclusion guard + # -------------------------------------------------------------------------- # DESCRIPTION # Implements panel "Find in files", GUI and function @@ -28,12 +33,11 @@ # -------------------------------------------------------------------------- class FindInFiles { - - common count 0 ;# Counter of class instances + common find_inf_count 0 ;# Counter of class instances # Variables related to object initialization private variable parent ;# Widget: parent widget - private variable gui_initialized 0 ;# Bool: GUI initialized + private variable find_inf_gui_initialized 0 ;# Bool: GUI initialized private variable obj_idx ;# Int: Object index private variable abort_variable 0 ;# Bool: Abort search @@ -53,8 +57,8 @@ class FindInFiles { constructor {} { # Increment object counter - incr count - set obj_idx $count + incr find_inf_count + set obj_idx $find_inf_count # Load configuration set ::FindInFiles::recursive_$obj_idx [lindex $::CONFIG(FIND_IN_FILES_CONFIG) 0] @@ -65,13 +69,13 @@ class FindInFiles { set ::FindInFiles::pattern_$obj_idx [lindex $::CONFIG(FIND_IN_FILES_CONFIG) 5] # Validate loaded configuration - if {![string is boolean -strict [subst "\$::FindInFiles::recursive_$obj_idx"]]} { + if {![string is boolean -strict [subst -nocommands "\$::FindInFiles::recursive_$obj_idx"]]} { set ::FindInFiles::recursive_$obj_idx 1 } - if {![string is boolean -strict [subst "\$::FindInFiles::regular_expr_$obj_idx"]]} { + if {![string is boolean -strict [subst -nocommands "\$::FindInFiles::regular_expr_$obj_idx"]]} { set ::FindInFiles::regular_expr_$obj_idx 0 } - if {![string is boolean -strict [subst "\$::FindInFiles::case_sensitive_$obj_idx"]]} { + if {![string is boolean -strict [subst -nocommands "\$::FindInFiles::case_sensitive_$obj_idx"]]} { set ::FindInFiles::case_sensitive_$obj_idx 1 } } @@ -88,7 +92,7 @@ class FindInFiles { # @return void public method PrepareFindInFiles {_parent} { set parent $_parent - set gui_initialized 0 + set find_inf_gui_initialized 0 } ## Inform this tab than it has became active @@ -102,8 +106,12 @@ class FindInFiles { ## Create GUI of messages tab # @return void public method CreateFindInFilesGUI {} { - if {$gui_initialized} {return} - set gui_initialized 1 + if {$find_inf_gui_initialized} {return} + set find_inf_gui_initialized 1 + + if {${::DEBUG}} { + puts "CreateFindInFilesGUI \[ENTER\]" + } create_findinfilesgui create_tags_and_bindings @@ -150,7 +158,7 @@ class FindInFiles { set ::FindInFiles::folder_$obj_idx [$this cget -projectPath] bind $folder_entry <Return> "$this findinfiles_search" bind $folder_entry <KP_Enter> "$this findinfiles_search" - pack $folder_entry -side left -fill x -expand 1 + pack $folder_entry -side left -fill x -expand 1 -pady 2 # Button "Select directory" pack [ttk::button $folder_entry_frm.select_dir_but \ -image ::ICONS::16::fileopen \ @@ -186,8 +194,8 @@ class FindInFiles { -width 7 \ ] setStatusTip -widget $clear_button -text [mc "Clear results"] - pack $find_stop_button -side left - pack $clear_button -side left + pack $find_stop_button -side left -padx 2 + pack $clear_button -side left -padx 2 # Separator pack [ttk::separator $top_bottom_frame.sep \ -orient vertical \ @@ -243,13 +251,22 @@ class FindInFiles { ## Bottom frame (text widget and its scrollbar) set bottom_frame [frame $main_frame.bottom_frame] - set text_widget [text $bottom_frame.text \ - -bg white -state disabled -bd 1 -wrap none \ - -highlightthickness 0 -exportselection 0 \ - -cursor left_ptr -width 0 -height 0 \ - -yscrollcommand "$bottom_frame.scrollbar set" \ - -font [font create -family helvetica -size -12] \ - -fg {#555555} \ + set text_widget [text $bottom_frame.text \ + -bg white \ + -state disabled \ + -bd 1 \ + -wrap none \ + -highlightthickness 0 \ + -exportselection 0 \ + -cursor left_ptr \ + -width 0 \ + -height 0 \ + -yscrollcommand "$bottom_frame.scrollbar set" \ + -font [font create \ + -family helvetica \ + -size [expr {int(-12 * $::font_size_factor)}] \ + ] \ + -fg {#555555} \ ] pack $text_widget -side left -fill both -expand 1 pack [ttk::scrollbar $bottom_frame.scrollbar \ @@ -269,7 +286,7 @@ class FindInFiles { # @return void private method create_tags_and_bindings {} { # Create tags - set bold_font [font create -family helvetica -size -12 -weight bold] + set bold_font [font create -family helvetica -size [expr {int(-12 * $::font_size_factor)}] -weight bold] $text_widget tag configure tag_highlight -foreground {#000000} -font $bold_font $text_widget tag configure tag_filename -foreground {#0000DD} $text_widget tag configure tag_linenumber -foreground {#00DD00} @@ -292,7 +309,7 @@ class FindInFiles { {goto} "Go to this line"} {command "Clear" {} 0 "findinfiles_clear" {editdelete} "Clear this panel"} - } $menu 0 "$this " 0 {} + } $menu 0 "$this " 0 {} [namespace current] $menu entryconfigure [::mc "Clear"] -state disabled } @@ -302,7 +319,7 @@ class FindInFiles { KIFSD::FSD ::fsd \ -title [mc "Choose directory - MCU 8051 IDE"] \ -fileson 0 -master . \ - -directory [subst "\$::FindInFiles::folder_$obj_idx"] + -directory [subst -nocommands "\$::FindInFiles::folder_$obj_idx"] fsd setokcmd "set ::FindInFiles::folder_$obj_idx \[::fsd get\]" fsd activate } @@ -311,11 +328,11 @@ class FindInFiles { # @return void public method findinfiles_search {} { # Gain search options - set folder [file normalize [subst "\$::FindInFiles::folder_$obj_idx"]] - set mask [subst "\$::FindInFiles::mask_$obj_idx"] - set pattern [subst "\$::FindInFiles::pattern_$obj_idx"] - set reg_expr [subst "\$::FindInFiles::regular_expr_$obj_idx"] - set case_sen [subst "\$::FindInFiles::case_sensitive_$obj_idx"] + set folder [file normalize [subst -nocommands "\$::FindInFiles::folder_$obj_idx"]] + set mask [subst -nocommands "\$::FindInFiles::mask_$obj_idx"] + set pattern [subst -nocommands "\$::FindInFiles::pattern_$obj_idx"] + set reg_expr [subst -nocommands "\$::FindInFiles::regular_expr_$obj_idx"] + set case_sen [subst -nocommands "\$::FindInFiles::case_sensitive_$obj_idx"] # Validate search options if {![string length $folder] || ![string length $mask] || ![string length $pattern]} { @@ -369,7 +386,7 @@ class FindInFiles { eval "append files { } \[glob -directory {$folder} -nocomplain -types {f l} -- $m\]" } } - if {[subst "\$::FindInFiles::recursive_$obj_idx"]} { + if {[subst -nocommands "\$::FindInFiles::recursive_$obj_idx"]} { append files { } [regsub -all {[\{\}]} [recursive_search $folder $mask] {\\&}] } @@ -396,7 +413,7 @@ class FindInFiles { # Enable / Disable clear button and clear entry in the popup menu if {[$text_widget index {1.0 lineend}] == {1.0}} { set state disabled - } { + } else { set state normal } $menu entryconfigure [::mc "Clear"] -state $state @@ -430,7 +447,7 @@ class FindInFiles { # Open file if {[catch { set file [open $filename r] - }]} { + }]} then { return 0 } @@ -474,7 +491,7 @@ class FindInFiles { set found 0 if {$case_sen} { set found [regexp -start $idx -- $pattern $line matched_str] - } { + } else { set found [regexp -nocase -start $idx -- $pattern $line matched_str] } @@ -489,7 +506,7 @@ class FindInFiles { set last_idx $idx } # Pure string pattern - } { + } else { while {$idx != -1} { set idx [string first $pattern $line $idx] if {$last_idx >= $idx} { @@ -571,7 +588,7 @@ class FindInFiles { set index [$text_widget index [list @$x,$y linestart]] if {[$text_widget compare $index == [list $index lineend]]} { set state disabled - } { + } else { set state normal } $menu entryconfigure [::mc "Go to"] -state $state @@ -619,9 +636,9 @@ class FindInFiles { set filename [file join $folder $filename] if {[$this openfile $filename 1 . def def 0 0 {}] != {}} { $this switch_to_last - update idle + update idletasks $this editor_procedure {} parseAll {} - } { + } else { return } } @@ -651,8 +668,8 @@ class FindInFiles { { if {$for_what == $number} { set string $content - } { - set string [subst "\$::FindInFiles::$var"] + } else { + set string [subst -nocommands "\$::FindInFiles::$var"] } if {![string length $string]} { set state disabled @@ -676,7 +693,7 @@ class FindInFiles { set y [winfo pointery .] # Create legend window - set win [toplevel .findinfiles_help_win -class {Help} -bg {#EEEEEE}] + set win [toplevel .findinfiles_help_win -class {Help} -bg ${::COMMON_BG_COLOR}] set frame [frame $win.f -bg {#555555} -bd 0 -padx 1 -pady 1] wm overrideredirect $win 1 @@ -703,14 +720,14 @@ class FindInFiles { pack $frame -fill both -expand 1 # Fill the text widget - $text insert end "Comma separated list of file masks (e.g \"*.c,*.h,*.asm\")\n" - $text insert end "The mask may contain any of the following special characters:\n" - $text insert end " ? Matches any single character.\n" - $text insert end " * Matches any sequence of zero or more characters.\n" - $text insert end " \[chars\] Matches any single character in chars.\n" - $text insert end " If chars contains a sequence of the form a-b then any\n" - $text insert end " character between a and b (inclusive) will match.\n" - $text insert end " \x Matches the character x." + $text insert end [mc "Comma separated list of file masks (e.g \"*.c,*.h,*.asm\")\n"] + $text insert end [mc "The mask may contain any of the following special characters:\n"] + $text insert end [mc " ? Matches any single character.\n"] + $text insert end [mc " * Matches any sequence of zero or more characters.\n"] + $text insert end [mc " \[chars\] Matches any single character in chars.\n"] + $text insert end [mc " If chars contains a sequence of the form a-b then any\n"] + $text insert end [mc " character between a and b (inclusive) will match.\n"] + $text insert end [mc " \\x Matches the character x."] # Show the text $text configure -state disabled @@ -738,13 +755,17 @@ class FindInFiles { # - Intented for session management # @return void public method findinfiles_get_config {} { - return [list \ - [subst "\$::FindInFiles::recursive_$obj_idx"] \ - [subst "\$::FindInFiles::regular_expr_$obj_idx"] \ - [subst "\$::FindInFiles::case_sensitive_$obj_idx"] \ - [subst "\$::FindInFiles::folder_$obj_idx"] \ - [subst "\$::FindInFiles::mask_$obj_idx"] \ - [subst "\$::FindInFiles::pattern_$obj_idx"] \ + return [list \ + [subst -nocommands "\$::FindInFiles::recursive_$obj_idx"] \ + [subst -nocommands "\$::FindInFiles::regular_expr_$obj_idx"] \ + [subst -nocommands "\$::FindInFiles::case_sensitive_$obj_idx"] \ + [subst -nocommands "\$::FindInFiles::folder_$obj_idx"] \ + [subst -nocommands "\$::FindInFiles::mask_$obj_idx"] \ + [subst -nocommands "\$::FindInFiles::pattern_$obj_idx"] \ ] } } + +# >>> File inclusion guard +} +# <<< File inclusion guard |