1textutil::tabify(n)Text and string utilities, macro processintgextutil::tabify(n)
2
3
4
5______________________________________________________________________________
6
8 textutil::tabify - Procedures to (un)tabify strings
9
11 package require Tcl 8.2
12
13 package require textutil::tabify ?0.7?
14
15 ::textutil::tabify::tabify string ?num?
16
17 ::textutil::tabify::tabify2 string ?num?
18
19 ::textutil::tabify::untabify string ?num?
20
21 ::textutil::tabify::untabify2 string ?num?
22
23______________________________________________________________________________
24
26 The package textutil::tabify provides commands that convert between
27 tabulation and ordinary whitespace in strings.
28
29 The complete set of procedures is described below.
30
31 ::textutil::tabify::tabify string ?num?
32 Tabify the string by replacing any substring of num space chars
33 by a tabulation and return the result as a new string. num
34 defaults to 8.
35
36 ::textutil::tabify::tabify2 string ?num?
37 Similar to ::textutil::tabify this command tabifies the string
38 and returns the result as a new string. A different algorithm is
39 used however. Instead of replacing any substring of num spaces
40 this command works more like an editor. num defaults to 8.
41
42 Each line of the text in string is treated as if there are tab‐
43 stops every num columns. Only sequences of space characters con‐
44 taining more than one space character and found immediately
45 before a tabstop are replaced with tabs.
46
47 ::textutil::tabify::untabify string ?num?
48 Untabify the string by replacing any tabulation char by a sub‐
49 string of num space chars and return the result as a new string.
50 num defaults to 8.
51
52 ::textutil::tabify::untabify2 string ?num?
53 Untabify the string by replacing any tabulation char by a sub‐
54 string of at most num space chars and return the result as a new
55 string. Unlike textutil::tabify::untabify each tab is not
56 replaced by a fixed number of space characters. The command
57 overlays each line in the string with tabstops every num columns
58 instead and replaces tabs with just enough space characters to
59 reach the next tabstop. This is the complement of the actions
60 taken by ::textutil::tabify::tabify2. num defaults to 8.
61
62 There is one asymmetry though: A tab can be replaced with a sin‐
63 gle space, but not the other way around.
64
66 This document, and the package it describes, will undoubtedly contain
67 bugs and other problems. Please report such in the category textutil
68 of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please
69 also report any ideas for enhancements you may have for either package
70 and/or documentation.
71
72 When proposing code changes, please provide unified diffs, i.e the out‐
73 put of diff -u.
74
75 Note further that attachments are strongly preferred over inlined
76 patches. Attachments can be made by going to the Edit form of the
77 ticket immediately after its creation, and then using the left-most
78 button in the secondary navigation bar.
79
81 regexp(n), split(n), string(n)
82
84 formatting, string, tabstops
85
87 Text processing
88
89
90
91tcllib 0.7 textutil::tabify(n)