Attachment "bug983146.diff" to
ticket [983146ffff]
added by
mistachkin
2004-07-06 16:44:20.
Index: tools/man2help2.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/tools/man2help2.tcl,v
retrieving revision 1.13
diff -b -u -r1.13 man2help2.tcl
--- tools/man2help2.tcl 18 May 2004 12:16:02 -0000 1.13
+++ tools/man2help2.tcl 6 Jul 2004 09:41:42 -0000
@@ -160,6 +160,7 @@
"\t" {\tab } \
'' "\\rdblquote " \
`` "\\ldblquote " \
+ · "\\bullet" \
] $string]
# Check if this is the beginning of an international character string.
@@ -492,7 +493,7 @@
# text - Text to insert.
proc formattedText {text} {
- global chars
+ global file chars
while {$text != ""} {
set index [string first \\ $text]
@@ -523,6 +524,27 @@
regexp {'([^']*)'(.*)} $text all ch text
text $chars($ch)
}
+ ( {
+ set c2 [string range $text [expr {$index+2}] [expr {$index+3}]]
+ switch -- $c2 {
+ bu {
+ #
+ # HACK: Output bullet, partial fix for bug #983146 (JJM).
+ #
+ # I suspect that this code shouldn't need to be here
+ # because bullets are also handled in proc "char" in
+ # this file. However, I do not see where that proc is
+ # called from and it's obviously not getting hit in
+ # this case.
+ #
+ text "·"
+ }
+ default {
+ puts stderr "Unknown glyph sequence: \\($c2"
+ }
+ }
+ set text [string range $text [expr {$index+4}] end]
+ }
default {
puts stderr "Unknown sequence: \\$c"
set text [string range $text [expr {$index+2}] end]
@@ -575,9 +597,42 @@
proc setTabs {tabList} {
global file state
-
+ #
+ # HACK: Calculate width of text, partial fix for bug #983146 (JJM).
+ # RTF does not appear to support calculating the width of
+ # arbitrary text for use with tabs and such, so we do the best
+ # we can to fake it.
+ #
+ if {[llength [set matches [regexp -all -inline -- {\+?\\w'([^']*)'u} $tabList]]] > 0} {
+ if {[llength $matches] % 2 == 0} {
+ set sum 0
+ foreach {match submatch} $matches {
+ #
+ # FIXME: This is a VERY rough approximation of the width of one
+ # character in a proportional spaced font (Times New Roman,
+ # 10pt).
+ #
+ set width [expr {[string length $submatch] * 0.06}]
+ set sum [expr {$sum + $width}]
+ #
+ # NOTE: Are we operating in relative mode (indicated by "+")?
+ #
+ if {[string index $match 0] == "+"} then {
+ lappend newTabList ${sum}i
+ } else {
+ lappend newTabList ${width}i
+ }
+ }
+ } else {
+ puts stderr "bad tab stops: $tabList"
+ return
+ }
+ } else {
+ # must be in the standard format...
+ set newTabList $tabList
+ }
set state(tabs) {}
- foreach arg $tabList {
+ foreach arg $newTabList {
set distance [expr {$state(leftMargin) \
+ ($state(offset) * $state(nestingLevel)) + [getTwips $arg]}]
lappend state(tabs) [expr {round($distance)}]
@@ -806,7 +861,7 @@
# default state(indent).
#
# Arguments:
-# argList - List of arguments to the .IP macro.
+# argList - List of arguments to the .TP macro.
#
# HTML limitations: 'x' in '.TP x' is ignored.