📄 scrolledhtml.itk
字号:
set file $ar(src) } else { set file $_cwd/$ar(src) } if [catch {set img [::image create photo -file $file]} err] { if {[info exists ar(width)] && [info exists ar(height)] } { # suggestions exist, so make frame appropriate size and add a border $imgframe configure -width $ar(width) -height $ar(height) -borderwidth 2 pack propagate $imgframe false } # # If alt text is specified, display that # if [info exists ar(alt)] { # add a border $imgframe configure -borderwidth 2 set win $imgframe.text label $win -text "$ar(alt)" -background $_bgcolor \ -foreground $_color } else { # # use 'unknown image' set win $imgframe.image#auto # # make label containing image # label $win -image $_unknownimg -borderwidth 0 -background $_bgcolor } pack $win -fill both -expand true } else { ;# no error loading image lappend _images $img set win $imgframe.$img # # make label containing image # label $win -image $img -borderwidth 0 } pack $win # # set alignment # set align bottom if [info exists ar(align)] { switch $ar(align) { middle { set align center } right { set align center } default { set align [string tolower $ar(align)] } } } # # create window in text to display image # $_hottext window create end -window \ $imgframe -align $align # # set tag for window # $_hottext tag add $_tag $imgframe if $_anchorcount { set href [_peek href] set href_tag href[incr _counter] set tags [list $_tag $href_tag] if { $itk_option(-linkcommand)!= {} } { bind $win <1> [list uplevel #0 $itk_option(-linkcommand) $href] } } }}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_kbd## Display keyboard input# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_kbd {} { incr _textweight _entity_tt _set_tag}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_/kbd## change state back from displaying keyboard input# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_/kbd {} { _entity_/tt incr _textweight -1 _set_tag}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_li## begin new list entry# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_li {{args {}}} { _parse_fields ar $args if [info exists ar(value)] { set _licount $ar(value) } _entity_br switch -exact $_listyle { bullet { set old_font $_font set _font symbol _set_tag $_hottext insert end "\xb7" $_tag set _font $old_font _set_tag } none { } picture { _entity_img src="$_lipic" width=4 height=4 align=middle } A { _entity_b $_hottext insert end [format "%c) " [expr $_licount + 0x40]] $_tag _entity_/b incr _licount } a { _entity_b $_hottext insert end [format "%c) " [expr $_licount + 0x60]] $_tag _entity_/b incr _licount } I { _entity_b $_hottext insert end "[::iwidgets::roman $_licount]) " $_tag _entity_/b incr _licount } i { _entity_b $_hottext insert end "[::iwidgets::roman $_licount lower])] " $_tag _entity_/b incr _licount } default { _entity_b $_hottext insert end "$_licount) " $_tag _entity_/b incr _licount } }}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_listing## diplay code listing# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_listing {} { _entity_pre}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_/listing## end code listing# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_/listing {} { _entity_/pre}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_menu## diplay menu list# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_menu {{args {}}} { _entity_ul plain $args}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_/menu## end menu list# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_/menu {} { _entity_/ul}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_ol## begin ordered list# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_ol {{args {}}} { _parse_fields ar $args if $_left { _entity_br } else { _entity_p } if {![info exists ar(type)]} { set ar(type) 1 } _push licount $_licount if [info exists ar(start)] { set _licount $ar(start) } else { set _licount 1 } _push left $_left _push left2 $_left2 if {$_left2 == $_left } { incr _left2 [expr $_indentincr+3] } else { incr _left2 $_indentincr } incr _left $_indentincr _push listyle $_listyle set _listyle $ar(type) _set_tag}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_/ol## end ordered list# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_/ol {} { set _left [_pop left] set _left2 [_pop left2] set _listyle [_pop listyle] set _licount [_pop licount] _set_tag _entity_p}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_p## paragraph break# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_p {{args {}}} { _parse_fields ar $args if [info exists ar(align)] { _set_align $ar(align) } else { set _justify L } _set_tag if [info exists ar(id)] { set _anchor($ar(id)) [$itk_component(text) index end] } set x [$_hottext get end-3c] set y [$_hottext get end-2c] if {$x == "" && $y == ""} return if {$y == ""} { $_hottext insert end "\n\n" return } if {$x == "\n" && $y == "\n"} return if {$y == "\n"} { $_hottext insert end "\n" return } $_hottext insert end "\n\n"}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_pre## display preformatted text# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_pre {{args {}}} { _entity_tt _entity_br incr _pre}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_/pre## change state back from preformatted text# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_/pre {} { _entity_/tt set _pre 0 _entity_p}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_samp## display sample text.# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_samp {} { _entity_kbd}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_/samp## switch back to non-sample text# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_/samp {} { _entity_/kbd}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_small## Change current font to a smaller size# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_small {} { _push pointsndx $_pointsndx if {[incr _pointsndx -2] < 0} { set _pointsndx 0 } _set_tag }# ------------------------------------------------------------------# PRIVATE METHOD: _entity_/small## change current font back from smaller size# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_/small {} { set _pointsndx [_pop pointsndx] _set_tag}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_sub## display subscript# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_sub {} { _push offset $_offset incr _offset -2 _entity_small}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_/sub## switch back to non-subscript# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_/sub {} { set _offset [_pop offset] _entity_/small}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_sup## display superscript# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_sup {} { _push offset $_offset incr _offset 4 _entity_small}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_/sup## switch back to non-superscript# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_/sup {} { set _offset [_pop offset] _entity_/small}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_strong## display strong text. (i.e. make font bold)# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_strong {} { incr _textweight _set_tag}# ------------------------------------------------------------------# PRIVATE METHOD: _entity_/strong## switch back to non-strong text# ------------------------------------------------------------------body iwidgets::Scrolledhtml::_entity_/strong {} { incr _textweight -1 _set_tag }# ------------------------------------------------------------------# PRIVATE METHOD: _entity_table## display a table.# ---------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -