summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtkread29
1 files changed, 28 insertions, 1 deletions
diff --git a/tkread b/tkread
index 126156f..30639ce 100755
--- a/tkread
+++ b/tkread
@@ -123,13 +123,40 @@ proc markup {widget} {
if [file exists $localfile] {
set curimg [image create photo -file $localfile]
$widget image create $insertion -image $curimg
+ set cur $insertion
} else {
- $widget insert [indexmovechar $insertion "- 2"] $alt
+ $widget insert $insertion $alt
+ set cur [indexmovechar $insertion "+ [string length $alt]"]
}
set cur [$widget search {![} $cur end]
}
+ # remove links
+ # TODO: save the link contents and allow the links to be shown / hidden with a keystroke
+ set cur [$widget search {[} 0.0 end]
+ while {$cur != ""} {
+ set altstart [indexmovechar $cur "+ 1"]
+ set cur [$widget search "](" $cur end]
+ if {$cur == ""} { break }
+ set altend $cur
+ set srcstart [indexmovechar $cur "+ 1"]
+ set cur [$widget search ")" $cur end]
+ if {$cur == ""} { break }
+ set srcend $cur
+
+ set alt [$widget get $altstart $altend]
+ set src [$widget get $srcstart $srcend]
+
+ $widget delete [indexmovechar $altstart "- 1"] [indexmovechar $srcend "+ 1"]
+ set insertion [indexmovechar $altstart "- 1"]
+ $widget insert $insertion $alt
+
+ set cur [indexmovechar $insertion "+ [string length $alt]"]
+ set cur [$widget search {[} $cur end]
+ }
+
+
# process underlined headings
foreach fmt $underlinefmt {
set searchchar [lindex $fmt 0]