📄 finddialog.itk
字号:
## Finddialog# ----------------------------------------------------------------------# This class implements a dialog for searching text. It prompts the# user for a search string and the method of searching which includes# case sensitive, regular expressions, backwards, and all.## ----------------------------------------------------------------------# AUTHOR: Mark L. Ulferts EMAIL: mulferts@austin.dsccc.com## @(#) RCS: $Id: finddialog.itk,v 1.3 2001/08/07 19:56:48 smithc Exp $# ----------------------------------------------------------------------# Copyright (c) 1996 DSC Technologies Corporation# ======================================================================# Permission to use, copy, modify, distribute and license this software # and its documentation for any purpose, and without fee or written # agreement with DSC, is hereby granted, provided that the above copyright # notice appears in all copies and that both the copyright notice and # warranty disclaimer below appear in supporting documentation, and that # the names of DSC Technologies Corporation or DSC Communications # Corporation not be used in advertising or publicity pertaining to the # software without specific, written prior permission.# # DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING # ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-# INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE# AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL # DSC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR # ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS # SOFTWARE.# ======================================================================## Usual options.#itk::usual Finddialog { keep -background -cursor -foreground -selectcolor}# ------------------------------------------------------------------# IPRFINDDIALOG# ------------------------------------------------------------------itcl::class ::iwidgets::Finddialog { inherit iwidgets::Dialogshell constructor {args} {} itk_option define -selectcolor selectColor Background {} itk_option define -clearcommand clearCommand Command {} itk_option define -matchcommand matchCommand Command {} itk_option define -patternbackground patternBackground Background \#707070 itk_option define -patternforeground patternForeground Foreground White itk_option define -searchbackground searchBackground Background \#c4c4c4 itk_option define -searchforeground searchForeground Foreground Black itk_option define -textwidget textWidget TextWidget {} public { method clear {} method find {} } protected { method _get {setting} method _textExists {} common _optionValues ;# Current settings of check buttons. common _searchPoint ;# Starting location for searches common _matchLen ;# Matching pattern string length }}## Provide a lowercased access method for the ::finddialog class.# proc ::iwidgets::finddialog {pathName args} { uplevel ::iwidgets::Finddialog $pathName $args}## Use option database to override default resources of base classes.#option add *Finddialog.title "Find" widgetDefault# ------------------------------------------------------------------# CONSTRUCTOR# ------------------------------------------------------------------itcl::body ::iwidgets::Finddialog::constructor {args} { # # Add the find pattern entryfield. # itk_component add pattern { iwidgets::Entryfield $itk_interior.pattern -labeltext "Find:" } bind [$itk_component(pattern) component entry] \ <Return> "[itcl::code $this invoke]; break" # # Add the find all checkbutton. # itk_component add all { checkbutton $itk_interior.all \ -variable [itcl::scope _optionValues($this-all)] \ -text "All" } # # Add the case consideration checkbutton. # itk_component add case { checkbutton $itk_interior.case \ -variable [itcl::scope _optionValues($this-case)] \ -text "Consider Case" } # # Add the regular expression checkbutton. # itk_component add regexp { checkbutton $itk_interior.regexp \ -variable [itcl::scope _optionValues($this-regexp)] \ -text "Use Regular Expression" } # # Add the find backwards checkbutton. # itk_component add backwards { checkbutton $itk_interior.backwards \ -variable [itcl::scope _optionValues($this-backwards)] \ -text "Find Backwards" } # # Add the find, clear, and close buttons, making find be the default. # add Find -text Find -command [itcl::code $this find] add Clear -text Clear -command [itcl::code $this clear] add Close -text Close -command [itcl::code $this deactivate 0] default Find # # Use the grid to layout the components. # grid $itk_component(pattern) -row 0 -column 0 \ -padx 10 -pady 10 -columnspan 4 -sticky ew grid $itk_component(all) -row 1 -column 0 grid $itk_component(case) -row 1 -column 1 grid $itk_component(regexp) -row 1 -column 2 grid $itk_component(backwards) -row 1 -column 3 grid columnconfigure $itk_interior 0 -weight 1 grid columnconfigure $itk_interior 1 -weight 1 grid columnconfigure $itk_interior 2 -weight 1 grid columnconfigure $itk_interior 3 -weight 1 # # Initialize all the configuration options. # eval itk_initialize $args}# ------------------------------------------------------------------# OPTIONS# ------------------------------------------------------------------# ------------------------------------------------------------------# OPTION: -clearcommand## Specifies a command to be invoked following a clear operation. # The command is meant to be a means of notification that the# clear has taken place and allow other actions to take place such# as disabling a find again menu.# ------------------------------------------------------------------itcl::configbody iwidgets::Finddialog::clearcommand {}# ------------------------------------------------------------------# OPTION: -matchcommand## Specifies a command to be invoked following a find operation. # The command is called with a match point as an argument. Should# a match not be found the match point is {}.# ------------------------------------------------------------------itcl::configbody iwidgets::Finddialog::matchcommand {}# ------------------------------------------------------------------# OPTION: -patternbackground## Specifies the background color of the text matching the search# pattern. It may have any of the forms accepted by Tk_GetColor.# ------------------------------------------------------------------itcl::configbody iwidgets::Finddialog::patternbackground {}# ------------------------------------------------------------------# OPTION: -patternforeground## Specifies the foreground color of the pattern matching a search# operation. It may have any of the forms accepted by Tk_GetColor.# ------------------------------------------------------------------itcl::configbody iwidgets::Finddialog::patternforeground {}# ------------------------------------------------------------------# OPTION: -searchforeground## Specifies the foreground color of the line containing the matching# pattern from a search operation. It may have any of the forms # accepted by Tk_GetColor.# ------------------------------------------------------------------itcl::configbody iwidgets::Finddialog::searchforeground {}# ------------------------------------------------------------------# OPTION: -searchbackground## Specifies the background color of the line containing the matching# pattern from a search operation. It may have any of the forms # accepted by Tk_GetColor.# ------------------------------------------------------------------itcl::configbody iwidgets::Finddialog::searchbackground {}# ------------------------------------------------------------------# OPTION: -textwidget## Specifies the scrolledtext or text widget to be searched.# ------------------------------------------------------------------itcl::configbody iwidgets::Finddialog::textwidget { if {$itk_option(-textwidget) != {}} { set _searchPoint($itk_option(-textwidget)) 1.0 }}# ------------------------------------------------------------------# METHODS# ------------------------------------------------------------------# ------------------------------------------------------------------# PUBLIC METHOD: clear ## Clear the pattern entryfield and the indicators. # ------------------------------------------------------------------itcl::body ::iwidgets::Finddialog::clear {} { $itk_component(pattern) clear
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -