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

📄 finddialog.itk

📁 这是一个Linux下的集成开发环境
💻 ITK
📖 第 1 页 / 共 2 页
字号:
    if {[_textExists]} {	set _searchPoint($itk_option(-textwidget)) 1.0	$itk_option(-textwidget) tag remove search-line 1.0 end	$itk_option(-textwidget) tag remove search-pattern 1.0 end    }    if {$itk_option(-clearcommand) != {}} {	eval $itk_option(-clearcommand)    }}# ------------------------------------------------------------------# PUBLIC METHOD: find## Search for a specific text string in the text widget given by# the -textwidget option.  Should this option not be set to an# existing widget, then a quick exit is made. # ------------------------------------------------------------------body ::iwidgets::Finddialog::find {} {    if {! [_textExists]} {	return    }    #    # Clear any existing indicators in the text widget.    #    $itk_option(-textwidget) tag remove search-line 1.0 end    $itk_option(-textwidget) tag remove search-pattern 1.0 end    #    # Make sure the search pattern isn't just blank.  If so, skip this.    #    set pattern [_get pattern]    if {[string trim $pattern] == ""} {	return    }    #    # After clearing out any old highlight indicators from a previous    # search, we'll be building our search command piece-meal based on     # the current settings of the checkbuttons in the find dialog.  The    # first we'll add is a variable to catch the count of the length    # of the string matching the pattern.    #    set precmd "$itk_option(-textwidget) search \	    -count [list [scope _matchLen($this)]]"    if {! [_get case]} {	append precmd " -nocase"    }    if {[_get regexp]} {	append precmd " -regexp"    } else {	append precmd " -exact"    }    #    # If we are going to find all matches, then the start point for    # the search will be the beginning of the text; otherwise, we'll    # use the last known starting point +/- a character depending on    # the direction.    #    if {[_get all]} {	set _searchPoint($itk_option(-textwidget)) 1.0    } else {	if {[_get backwards]} {	    append precmd " -backwards"	} else {	    append precmd " -forwards"	}    }    #    # Get the pattern to be matched and add it to the search command.    # Since it may contain embedded spaces, we'll wrap it in a list.    #    append precmd " [list $pattern]"        #    # If the search is for all matches, then we'll be performing the     # search until no more matches are found; otherwise, we'll break    # out of the loop after one search.    #    while {1} {	if {[_get all]} {	    set postcmd " $_searchPoint($itk_option(-textwidget)) end"	} else {	    set postcmd " $_searchPoint($itk_option(-textwidget))"	}	#	# Create the final search command out of the pre and post parts	# and evaluate it which returns the location of the matching string.	#	set cmd {}	append cmd $precmd $postcmd	if {[catch {eval $cmd} matchPoint] != 0} {	    set _searchPoint($itk_option(-textwidget)) 1.0	    return {}	}	#	# If a match exists, then we'll make this spot be the new starting	# position.  Then we'll tag the line and the pattern in the line.	# The foreground and background settings will lite these positions	# in the text widget up.	#	if {$matchPoint != {}} {	    set _searchPoint($itk_option(-textwidget)) $matchPoint 	    $itk_option(-textwidget) tag add search-line \	      "$_searchPoint($itk_option(-textwidget)) linestart" \		"$_searchPoint($itk_option(-textwidget))" 	    $itk_option(-textwidget) tag add search-line \	      "$_searchPoint($itk_option(-textwidget)) + \               $_matchLen($this) chars" \	      "$_searchPoint($itk_option(-textwidget)) lineend"	    $itk_option(-textwidget) tag add search-pattern \	       $_searchPoint($itk_option(-textwidget)) \		"$_searchPoint($itk_option(-textwidget)) + \                 $_matchLen($this) chars"	}	#	# Set the search point for the next time through to be one	# character more or less from the current search point based	# on the direction.	#	if {[_get all] || ! [_get backwards]} {	    set _searchPoint($itk_option(-textwidget)) \		[$itk_option(-textwidget) index \		     "$_searchPoint($itk_option(-textwidget)) + 1c"]	} else {	    set _searchPoint($itk_option(-textwidget)) \		[$itk_option(-textwidget) index \		     "$_searchPoint($itk_option(-textwidget)) - 1c"]	}	#	# If this isn't a find all operation or we didn't get a match, exit.	#	if {(! [_get all]) || ($matchPoint == {})} {	    break	}    }    #    # Configure the colors for the search-line and search-pattern.    #    $itk_option(-textwidget) tag configure search-line \	    -foreground $itk_option(-searchforeground)    $itk_option(-textwidget) tag configure search-line \	    -background $itk_option(-searchbackground)    $itk_option(-textwidget) tag configure search-pattern \	    -background $itk_option(-patternbackground)    $itk_option(-textwidget) tag configure search-pattern \	    -foreground $itk_option(-patternforeground)    #    # Adjust the view to be the last matched position.    #    if {$matchPoint != {}} {	$itk_option(-textwidget) see $matchPoint    }    #    # There may be multiple matches of the pattern on a single line,    # so we'll set the tag priorities such that the pattern tag is higher.    #    $itk_option(-textwidget) tag raise search-pattern search-line    #    # If a match command is defined, then call it with the match point.    #    if {$itk_option(-matchcommand) != {}} {	[subst $itk_option(-matchcommand)] $matchPoint    }    #    # Return the match point to the caller so they know if we found     # anything and if so where    #    return $matchPoint}# ------------------------------------------------------------------# PROTECTED METHOD: _get setting## Get the current value for the pattern, case, regexp, or backwards.# ------------------------------------------------------------------body ::iwidgets::Finddialog::_get {setting} {    switch $setting {	pattern {	    return [$itk_component(pattern) get]	}	case {	    return $_optionValues($this-case)	}	regexp {	    return $_optionValues($this-regexp)	}	backwards {	    return $_optionValues($this-backwards)	}	all {	    return $_optionValues($this-all)	}	default {	    error "bad get setting: \"$setting\", should be pattern,\		    case, regexp, backwards, or all"	}    }}# ------------------------------------------------------------------# PROTECTED METHOD: _textExists## Check the validity of the text widget option.  Does it exist and# is it of the class Text or Scrolledtext.# ------------------------------------------------------------------body ::iwidgets::Finddialog::_textExists {} {    if {$itk_option(-textwidget) == {}} {	return 0    }    if {! [winfo exists $itk_option(-textwidget)]} {	error "bad finddialog text widget value: \"$itk_option(-textwidget)\",\               the widget doesn't exist"    }    if {([winfo class $itk_option(-textwidget)] != "Text") &&	([itcl::find objects -isa iwidgets::Scrolledtext *::$itk_option(-textwidget)] == "")} {	error "bad finddialog text widget value: \"$itk_option(-textwidget)\",\               must be of the class Text or based on Scrolledtext"    }    return 1}

⌨️ 快捷键说明

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