Add support for external html docs
[maxima.git] / interfaces / xmaxima / Tkmaxima / String.tcl
blob22b79385073faf7e82afbae88e8168abab274f12
1 # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
3 # $Id: String.tcl,v 1.2 2002-09-07 05:21:42 mikeclarkson Exp $
5 ###### String.tcl ######
9 #-----------------------------------------------------------------
11 # trimSpace -- If a STRING contains no embedded newlines, then remove
12 # the surrounding whitespace, otherwise just remove trailing whitespace.
14 # Results:
16 # Side Effects: none
18 #----------------------------------------------------------------
20 proc trimSpace { ans } {
21 if { ![regexp "\n" $ans] } {
22 set ans [string trim $ans "\n \t"]
23 } elseif { [regexp "^\[\n\t \](\[^\n\]+)\[\n\t \]\$" $ans junk item] } {
24 set ans [string trim $ans "\n \t"]
25 } else {
26 # set ans [string range $ans 0 [expr {[string length $ans] - 2}]]
27 # try to make multiline things start with ans
28 set ans \n[string trimleft $ans \n]
30 return $ans
32 if { [regexp "^\[\n\t \]*(\[^\n\]+)\[\n\t \]*\$" $ans junk item] } {
33 set ans [string trim $ans "\n \t"]
34 } elseif { [regexp "\n" $ans] } {
35 set ans [string trim $ans "\n \t"]
36 return "\n$ans"
37 } else {
38 set ans [string trimright $ans "\n \t"]
40 return $ans
45 #-----------------------------------------------------------------
47 # genword -- make a string by copying STRING a total of COUNT times
49 # Results:string
51 # Side Effects: none
53 #----------------------------------------------------------------
55 proc genword { string count } {
56 set ans ""
57 while { [incr count -1] >= 0 } { append ans $string }
58 return $ans
61 ## endsource string.tcl