The code below is derived from the widget demo and should display hyperlinks on most lines.
There seems to be a pattern of lines not getting a hyperlink tag. Tried on a x86_64 linux build.
--- code ---
text .t -wrap word -width 70 -height 50 \
-setgrid 1 -highlightthickness 0
pack .t -expand 1 -fill both -padx 1
.t tag configure title -font TkDefaultFont
.t tag configure subtitle -font TkDefaultFont
.t tag configure bold -font TkDefaultFont
.t tag configure demospace -lmargin1 1c -lmargin2 1c
.t tag configure demo -lmargin1 1c -lmargin2 1c \
-foreground blue -underline 1
.t tag configure visited -lmargin1 1c -lmargin2 1c \
-foreground #303080 -underline 1
.t tag configure hot -foreground red -underline 1
proc addt {text} {
set style normal
set isNL 1
set demoCount 0
set new 0
foreach line [split $text \n] {
set line [string trim $line]
if {$line eq ""} {
continue
}
if {[string match @@* $line]} {
set data [string range $line 2 end]
set key [lindex $data 0]
set values [lrange $data 1 end]
switch -exact -- $key {
title {
.t insert end $values\n title \n normal
}
newline {
.t insert end \n $style
set isNL 1
}
subtitle {
.t insert end "\n" {} $values subtitle \
" \n " demospace
set demoCount 0
}
demo {
set description [lassign $values name]
.t insert end "[incr demoCount]. $description" \
[list demo demo-$name]
if {$new} {
.t image create end -image ::img::new -padx 5
set new 0
}
.t insert end " \n " demospace
}
new {
set new 1
}
default {
set style $key
}
}
continue
}
if {!$isNL} {
.t insert end " " $style
}
set isNL 0
.t insert end $line $style
}
}
set addt {
@@title Tag test
Bla bla bla ...
Bla bla bla ...
@@subtitle subtitle
}
for {set i 0} {$i < 1024} {incr i} {
append addt " @@demo tag$i\ttag$i\n"
}
addt $addt
--- /code ---
|