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

📄 entry.tcl

📁 genesis 2000 v9.1软件下载
💻 TCL
📖 第 1 页 / 共 2 页
字号:
## Arguments:# w -		The entry window.# x -		X-coordinate within the window.proc tkEntryClosestGap {w x} {    set pos [$w index @$x]    set bbox [$w bbox $pos]    if {($x - [lindex $bbox 0]) < ([lindex $bbox 2]/2)} {	return $pos    }    incr pos}# tkEntryButton1 --# This procedure is invoked to handle button-1 presses in entry# widgets.  It moves the insertion cursor, sets the selection anchor,# and claims the input focus.## Arguments:# w -		The entry window in which the button was pressed.# x -		The x-coordinate of the button press.proc tkEntryButton1 {w x} {    global tkPriv    set tkPriv(selectMode) char    set tkPriv(mouseMoved) 0    set tkPriv(pressX) $x    $w icursor [tkEntryClosestGap $w $x]    $w selection from insert    if {[lindex [$w configure -state] 4] == "normal"} {focus $w}}# tkEntryMouseSelect --# This procedure is invoked when dragging out a selection with# the mouse.  Depending on the selection mode (character, word,# line) it selects in different-sized units.  This procedure# ignores mouse motions initially until the mouse has moved from# one character to another or until there have been multiple clicks.## Arguments:# w -		The entry window in which the button was pressed.# x -		The x-coordinate of the mouse.proc tkEntryMouseSelect {w x} {    global tkPriv    set cur [tkEntryClosestGap $w $x]    set anchor [$w index anchor]    if {($cur != $anchor) || (abs($tkPriv(pressX) - $x) >= 3)} {	set tkPriv(mouseMoved) 1    }    switch $tkPriv(selectMode) {	char {	    if {$tkPriv(mouseMoved)} {		if {$cur < $anchor} {		    $w selection range $cur $anchor		} elseif {$cur > $anchor} {		    $w selection range $anchor $cur		} else {		    $w selection clear		}	    }	}	word {	    if {$cur < [$w index anchor]} {		set before [tcl_wordBreakBefore [$w get] $cur]		set after [tcl_wordBreakAfter [$w get] [expr {$anchor-1}]]	    } else {		set before [tcl_wordBreakBefore [$w get] $anchor]		set after [tcl_wordBreakAfter [$w get] [expr {$cur - 1}]]	    }	    if {$before < 0} {		set before 0	    }	    if {$after < 0} {		set after end	    }	    $w selection range $before $after	}	line {	    $w selection range 0 end	}    }    update idletasks}# tkEntryPaste --# This procedure sets the insertion cursor to the current mouse position,# pastes the selection there, and sets the focus to the window.## Arguments:# w -		The entry window.# x -		X position of the mouse.proc tkEntryPaste {w x} {    global tkPriv    $w icursor [tkEntryClosestGap $w $x]    catch {$w insert insert [selection get -displayof $w]}    if {[lindex [$w configure -state] 4] == "normal"} {focus $w}}# tkEntryAutoScan --# This procedure is invoked when the mouse leaves an entry window# with button 1 down.  It scrolls the window left or right,# depending on where the mouse is, and reschedules itself as an# "after" command so that the window continues to scroll until the# mouse moves back into the window or the mouse button is released.## Arguments:# w -		The entry window.proc tkEntryAutoScan {w} {    global tkPriv    set x $tkPriv(x)    if {![winfo exists $w]} return    if {$x >= [winfo width $w]} {	$w xview scroll 2 units	tkEntryMouseSelect $w $x    } elseif {$x < 0} {	$w xview scroll -2 units	tkEntryMouseSelect $w $x    }    set tkPriv(afterId) [after 50 tkEntryAutoScan $w]}# tkEntryKeySelect --# This procedure is invoked when stroking out selections using the# keyboard.  It moves the cursor to a new position, then extends# the selection to that position.## Arguments:# w -		The entry window.# new -		A new position for the insertion cursor (the cursor hasn't#		actually been moved to this position yet).proc tkEntryKeySelect {w new} {    if {![$w selection present]} {	$w selection from insert	$w selection to $new    } else {	$w selection adjust $new    }    $w icursor $new}# tkEntryInsert --# Insert a string into an entry at the point of the insertion cursor.# If there is a selection in the entry, and it covers the point of the# insertion cursor, then delete the selection before inserting.## Arguments:# w -		The entry window in which to insert the string# s -		The string to insert (usually just a single character)proc tkEntryInsert {w s} {    if {$s == ""} {	return    }    catch {	set insert [$w index insert]	if {([$w index sel.first] <= $insert)		&& ([$w index sel.last] >= $insert)} {	    $w delete sel.first sel.last	}    }    $w insert insert $s    tkEntrySeeInsert $w}# tkEntryBackspace --# Backspace over the character just before the insertion cursor.# If backspacing would move the cursor off the left edge of the# window, reposition the cursor at about the middle of the window.## Arguments:# w -		The entry window in which to backspace.proc tkEntryBackspace w {    if {[$w selection present]} {	$w delete sel.first sel.last    } else {	set x [expr {[$w index insert] - 1}]	if {$x >= 0} {$w delete $x}	if {[$w index @0] >= [$w index insert]} {	    set range [$w xview]	    set left [lindex $range 0]	    set right [lindex $range 1]	    $w xview moveto [expr {$left - ($right - $left)/2.0}]	}    }}# tkEntrySeeInsert --# Make sure that the insertion cursor is visible in the entry window.# If not, adjust the view so that it is.## Arguments:# w -		The entry window.proc tkEntrySeeInsert w {    set c [$w index insert]    set left [$w index @0]    if {$left > $c} {	$w xview $c	return    }    set x [winfo width $w]    while {([$w index @$x] <= $c) && ($left < $c)} {	incr left	$w xview $left    }}# tkEntrySetCursor -# Move the insertion cursor to a given position in an entry.  Also# clears the selection, if there is one in the entry, and makes sure# that the insertion cursor is visible.## Arguments:# w -		The entry window.# pos -		The desired new position for the cursor in the window.proc tkEntrySetCursor {w pos} {    $w icursor $pos    $w selection clear    tkEntrySeeInsert $w}# tkEntryTranspose -# This procedure implements the "transpose" function for entry widgets.# It tranposes the characters on either side of the insertion cursor,# unless the cursor is at the end of the line.  In this case it# transposes the two characters to the left of the cursor.  In either# case, the cursor ends up to the right of the transposed characters.## Arguments:# w -		The entry window.proc tkEntryTranspose w {    set i [$w index insert]    if {$i < [$w index end]} {	incr i    }    set first [expr {$i-2}]    if {$first < 0} {	return    }    set new [string index [$w get] [expr {$i-1}]][string index [$w get] $first]    $w delete $first $i    $w insert insert $new    tkEntrySeeInsert $w}# tkEntryNextWord --# Returns the index of the next word position after a given position in the# entry.  The next word is platform dependent and may be either the next# end-of-word position or the next start-of-word position after the next# end-of-word position.## Arguments:# w -		The entry window in which the cursor is to move.# start -	Position at which to start search.if {$tcl_platform(platform) == "windows"}  {    proc tkEntryNextWord {w start} {	set pos [tcl_endOfWord [$w get] [$w index $start]]	if {$pos >= 0} {	    set pos [tcl_startOfNextWord [$w get] $pos]	}	if {$pos < 0} {	    return end	}	return $pos    }} else {    proc tkEntryNextWord {w start} {	set pos [tcl_endOfWord [$w get] [$w index $start]]	if {$pos < 0} {	    return end	}	return $pos    }}# tkEntryPreviousWord --## Returns the index of the previous word position before a given# position in the entry.## Arguments:# w -		The entry window in which the cursor is to move.# start -	Position at which to start search.proc tkEntryPreviousWord {w start} {    set pos [tcl_startOfPreviousWord [$w get] [$w index $start]]    if {$pos < 0} {	return 0    }    return $pos}

⌨️ 快捷键说明

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