Download from: http://vectorstream.com/tcl/packages/ License: BSD style Author: [JMN]usage:
package require overtype overtype::left ?-overflow [1|0]? ?-elipsis [1|0]? ?-ellipsistext ...? undertext overtext overtype::centre ?-bias [left|right]? ?-overflow [1|0]? undertext overtext overtype::right ?-overflow [1|0]? undertext overtextovertype::center is equivalent to overtype::centreexamples:
%overtype::left [string repeat - 10] title title----- %overtype::centre [string repeat - 10] title --title--- %overtype::centre -bias right [string repeat - 10] title ---title-- %overtype::right [string repeat - 10] title -----title set pad [string repeat - 10] %overtype::left $pad stringdoesn'tfit stringdoes %overtype::left -overflow 1 $pad stringdoesn'tfit stringdoesn'tfit %overtype::left -overflow 0 -ellipsis 1 $pad stringdoesn'tfit stringd... %overtype::left -overflow 0 -ellipsis 1 -ellipsistext +++ $pad stringdoesn'tfit stringd+++
There may well be alternative ways of doing this sort of thing. e.g '[format "%-*s" 10 blah]' seems to be equivalent to '[overtype::left [string repeat " " 10] blah]'I just find it easier to remember how to use the overtype functions. (actually I don't need to remember much at all.. typing 'overtype::left' without args for example gives an error reporting the usage string shown above)Note the lack of ellipsis support for overtype::right & overtype::center. If someone cares enough to add it, I'll be happy to incorporate it in the package. (should truncation in a left-right language such as English always occur on the right.. or should there be an option?)I'd also be interested to see it generalised to support languages that read right to left.. but I haven't given it enough thought to see how exactly that would work.
See also format