📄 scrolledtext.itk
字号:
configure -visibleitems $itk_option(-visibleitems) }}# ------------------------------------------------------------------# OPTION: -visibleitems## Specified the widthxheight in characters and lines for the text.# This option is only administered if the width and height options# are both set to zero, otherwise they take precedence. With the# visibleitems option engaged, geometry constraints are maintained# only on the text. The size of the other components such as # labels, margins, and scroll bars, are additive and independent, # effecting the overall size of the scrolled text. In contrast,# should the width and height options have non zero values, they# are applied to the scrolled text as a whole. The text is # compressed or expanded to maintain the geometry constraints.# ------------------------------------------------------------------configbody iwidgets::Scrolledtext::visibleitems { if {[regexp {^[0-9]+x[0-9]+$} $itk_option(-visibleitems)]} { if {($itk_option(-width) == 0) && \ ($itk_option(-height) == 0)} { set chars [lindex [split $itk_option(-visibleitems) x] 0] set lines [lindex [split $itk_option(-visibleitems) x] 1] set shell [lindex [grid info $itk_component(clipper)] 1] # # Due to a bug in the tk4.2 grid, we have to check the # propagation before setting it. Setting it to the same # value it already is will cause it to toggle. # if {! [grid propagate $shell]} { grid propagate $shell yes } $itk_component(text) configure -width $chars -height $lines } } else { error "bad visibleitems option\ \"$itk_option(-visibleitems)\": should be\ widthxheight" }}# ------------------------------------------------------------------# METHODS# ------------------------------------------------------------------# ------------------------------------------------------------------# METHOD: bbox index## Returns four element list describing the bounding box for the list# item at index# ------------------------------------------------------------------body iwidgets::Scrolledtext::bbox {index} { return [$itk_component(text) bbox $index]}# ------------------------------------------------------------------# METHOD clear ## Clear the text area.# ------------------------------------------------------------------body iwidgets::Scrolledtext::clear {} { $itk_component(text) delete 1.0 end}# ------------------------------------------------------------------# METHOD import filename## Load text from an existing file (import filename)# ------------------------------------------------------------------body iwidgets::Scrolledtext::import {filename {index end}} { set f [open $filename r] insert $index [read $f] close $f}# ------------------------------------------------------------------# METHOD export filename## write text to a file (export filename)# ------------------------------------------------------------------body iwidgets::Scrolledtext::export {filename} { set f [open $filename w] set txt [$itk_component(text) get 1.0 end] puts $f $txt flush $f close $f}# ------------------------------------------------------------------# METHOD compare index1 op index2## Compare indices according to relational operator.# ------------------------------------------------------------------body iwidgets::Scrolledtext::compare {index1 op index2} { return [$itk_component(text) compare $index1 $op $index2]}# ------------------------------------------------------------------# METHOD debug ?boolean?## Activates consistency checks in B-tree code associated with text# widgets.# ------------------------------------------------------------------body iwidgets::Scrolledtext::debug {args} { eval $itk_component(text) debug $args}# ------------------------------------------------------------------# METHOD delete first ?last?## Delete a range of characters from the text.# ------------------------------------------------------------------body iwidgets::Scrolledtext::delete {first {last {}}} { $itk_component(text) delete $first $last}# ------------------------------------------------------------------# METHOD dlineinfo index## Returns a five element list describing the area occupied by the# display line containing index.# ------------------------------------------------------------------body iwidgets::Scrolledtext::dlineinfo {index} { return [$itk_component(text) dlineinfo $index]}# ------------------------------------------------------------------# METHOD get index1 ?index2?## Return text from start index to end index.# ------------------------------------------------------------------body iwidgets::Scrolledtext::get {index1 {index2 {}}} { return [$itk_component(text) get $index1 $index2]}# ------------------------------------------------------------------# METHOD image option ?arg arg ...?## Manipulate images dependent on options.## ------------------------------------------------------------------body iwidgets::Scrolledtext::image {option args} { return [eval $itk_component(text) image $option $args]}# ------------------------------------------------------------------# METHOD index index## Return position corresponding to index.# ------------------------------------------------------------------body iwidgets::Scrolledtext::index {index} { return [$itk_component(text) index $index]}# ------------------------------------------------------------------# METHOD insert index chars ?tagList?## Insert text at index.# ------------------------------------------------------------------body iwidgets::Scrolledtext::insert {args} { eval $itk_component(text) insert $args}# ------------------------------------------------------------------# METHOD mark option ?arg arg ...?## Manipulate marks dependent on options.# ------------------------------------------------------------------body iwidgets::Scrolledtext::mark {option args} { return [eval $itk_component(text) mark $option $args]}# ------------------------------------------------------------------# METHOD scan option args## Implements scanning on texts.# ------------------------------------------------------------------body iwidgets::Scrolledtext::scan {option args} { eval $itk_component(text) scan $option $args}# ------------------------------------------------------------------# METHOD search ?switches? pattern index ?varName?## Searches the text for characters matching a pattern.# ------------------------------------------------------------------body iwidgets::Scrolledtext::search {args} { #----------------------------------------------------------- # BUG FIX: csmith (Chad Smith: csmith@adc.com), 11/18/99 #----------------------------------------------------------- # Need to run this command up one level on the stack since # the text widget may modify one of the arguments, which is # the case when -count is specified. #----------------------------------------------------------- return [uplevel eval $itk_component(text) search $args]}# ------------------------------------------------------------------# METHOD see index## Adjusts the view in the window so the character at index is # visible.# ------------------------------------------------------------------body iwidgets::Scrolledtext::see {index} { $itk_component(text) see $index}# ------------------------------------------------------------------# METHOD tag option ?arg arg ...?## Manipulate tags dependent on options.# ------------------------------------------------------------------body iwidgets::Scrolledtext::tag {option args} { return [eval $itk_component(text) tag $option $args]}# ------------------------------------------------------------------# METHOD window option ?arg arg ...?## Manipulate embedded windows.# ------------------------------------------------------------------body iwidgets::Scrolledtext::window {option args} { return [eval $itk_component(text) window $option $args]}# ------------------------------------------------------------------# METHOD xview## Changes x view in widget's window.# ------------------------------------------------------------------body iwidgets::Scrolledtext::xview {args} { return [eval $itk_component(text) xview $args]}# ------------------------------------------------------------------# METHOD yview## Changes y view in widget's window.# ------------------------------------------------------------------body iwidgets::Scrolledtext::yview {args} { return [eval $itk_component(text) yview $args]}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -