#!/usr/local/bin/wish -f

set text [exec man true]

text .foo
pack .foo

regsub -all -- "(.\b)*" $text "" textonly

regsub -all -- "b|i" $text "a" tags
regsub -all -- "(_\b)+." $tags "i" tags
regsub -all -- "(.\b)+." $tags "b" tags

.foo insert 0.0 $textonly

.foo configure -font -*-courier-medium-r-normal--12-120-*-iso8859-1
.foo tag configure bold -font -*-courier-bold-r-normal--12-120-*-iso8859-1
.foo tag configure italic -font -*-courier-medium-o-normal--12-120-*-iso8859-1

for {set i 0} "\$i < [string length $tags]" {incr i} {
  if [string match "i" [string index $tags $i]] {
    .foo tag add italic "1.0 + $i chars"
  } elseif [string match "b" [string index $tags $i]] {
    .foo tag add bold "1.0 + $i chars"
  }
}


