5373
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
|
3 |
"
|
|
4 |
COPYRIGHT (c) 2018 by eXept Software AG
|
|
5 |
All Rights Reserved
|
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
4685
|
14 |
"{ Package: 'stx:libbasic2' }"
|
|
15 |
|
|
16 |
"{ NameSpace: Smalltalk }"
|
|
17 |
|
|
18 |
WriteStream subclass:#IndentStream
|
|
19 |
instanceVariableNames:'indentLevel indentString'
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
4696
|
22 |
category:'Streams-Misc'
|
4685
|
23 |
!
|
|
24 |
|
|
25 |
!IndentStream class methodsFor:'documentation'!
|
|
26 |
|
5373
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 2018 by eXept Software AG
|
|
30 |
All Rights Reserved
|
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
!
|
|
40 |
|
4685
|
41 |
documentation
|
|
42 |
"
|
|
43 |
a write stream which keeps a current indent and
|
|
44 |
automatically emits the indent on every cr.
|
|
45 |
|
|
46 |
[author:]
|
|
47 |
Claus Gittinger (ported from Squeak)
|
|
48 |
"
|
|
49 |
! !
|
|
50 |
|
|
51 |
!IndentStream class methodsFor:'instance creation'!
|
|
52 |
|
|
53 |
on: aCollection
|
|
54 |
|
|
55 |
^(super on: aCollection) initialize
|
|
56 |
!
|
|
57 |
|
|
58 |
with: aCollection
|
|
59 |
|
|
60 |
^(super with: aCollection) initialize
|
|
61 |
! !
|
|
62 |
|
|
63 |
!IndentStream methodsFor:'accessing'!
|
|
64 |
|
|
65 |
indentLevel
|
|
66 |
"the current indent"
|
|
67 |
|
|
68 |
^indentLevel
|
|
69 |
|
|
70 |
"Modified (comment): / 01-07-2018 / 10:16:32 / Claus Gittinger"
|
|
71 |
!
|
|
72 |
|
|
73 |
indentString:aString
|
|
74 |
"the string to use for indentation.
|
|
75 |
If left unset, a tab is used"
|
|
76 |
|
|
77 |
indentString := aString
|
|
78 |
|
|
79 |
"Created: / 01-07-2018 / 10:16:17 / Claus Gittinger"
|
|
80 |
! !
|
|
81 |
|
5242
|
82 |
!IndentStream methodsFor:'indentation'!
|
|
83 |
|
|
84 |
indent
|
|
85 |
|
|
86 |
self tab.
|
|
87 |
indentLevel := indentLevel + 1.
|
|
88 |
!
|
|
89 |
|
|
90 |
indentBack
|
|
91 |
|
|
92 |
indentLevel := indentLevel - 1.
|
|
93 |
! !
|
|
94 |
|
|
95 |
!IndentStream methodsFor:'initialization'!
|
|
96 |
|
|
97 |
initialize
|
|
98 |
|
|
99 |
super initialize.
|
|
100 |
indentLevel := 0.
|
|
101 |
! !
|
|
102 |
|
|
103 |
!IndentStream methodsFor:'writing'!
|
4685
|
104 |
|
|
105 |
cr
|
|
106 |
|
|
107 |
super cr.
|
|
108 |
self putIndent.
|
|
109 |
|
|
110 |
"Modified: / 01-07-2018 / 10:13:45 / Claus Gittinger"
|
|
111 |
!
|
|
112 |
|
|
113 |
crtab
|
|
114 |
|
|
115 |
self cr.
|
|
116 |
self indent.
|
|
117 |
!
|
|
118 |
|
|
119 |
putIndent
|
|
120 |
indentString notNil ifTrue:[
|
|
121 |
indentLevel timesRepeat:[
|
|
122 |
self nextPutAll:indentString
|
|
123 |
].
|
|
124 |
^ self.
|
|
125 |
].
|
|
126 |
"/ original
|
|
127 |
self tab: self indentLevel.
|
|
128 |
|
|
129 |
"Created: / 01-07-2018 / 10:13:40 / Claus Gittinger"
|
|
130 |
! !
|
|
131 |
|
|
132 |
!IndentStream class methodsFor:'documentation'!
|
|
133 |
|
|
134 |
version
|
|
135 |
^ '$Header$'
|
|
136 |
!
|
|
137 |
|
|
138 |
version_CVS
|
|
139 |
^ '$Header$'
|
|
140 |
! !
|
|
141 |
|