PPStream.st
changeset 421 7e08b31e0dae
parent 405 0470a5e6e712
child 427 a7f5e6de19d2
equal deleted inserted replaced
420:b2f2f15cef26 421:7e08b31e0dae
    70 		nextPutAll: (collection copyFrom: position + 1 to: readLimit)
    70 		nextPutAll: (collection copyFrom: position + 1 to: readLimit)
    71 ! !
    71 ! !
    72 
    72 
    73 !PPStream methodsFor:'queries'!
    73 !PPStream methodsFor:'queries'!
    74 
    74 
       
    75 column
       
    76 	^ self column: position.
       
    77 !
       
    78 
       
    79 column: pos
       
    80 	| column clear tmp |
       
    81 	
       
    82 	pos > readLimit ifTrue: [ ^ Error signal: 'Oot of bounds' ].	
       
    83 
       
    84 	tmp := position.
       
    85 	column := 0.	
       
    86 	clear := true.
       
    87 
       
    88 	(0 to: pos) do: 
       
    89 	[:index |
       
    90 		position := index.
       
    91 		self isStartOfLine ifTrue: [ clear := true ].
       
    92 
       
    93 		clear ifTrue: [ column := 0. clear := false ].
       
    94 		column := column + 1.
       
    95 		(position > readLimit) ifTrue: [ position := tmp. ^ column ].
       
    96 	].
       
    97 	position := tmp.
       
    98 	^ column
       
    99 !
       
   100 
    75 insideCRLF
   101 insideCRLF
    76 	(position < 1) ifTrue: [ ^ false ].
   102 	(position < 1) ifTrue: [ ^ false ].
    77 	
   103 	
    78 	^ (self peek = (Character codePoint: 10)) and: [ self peekBack = (Character codePoint: 13) ]
   104 	^ (self peek = (Character codePoint: 10)) and: [ self peekBack = (Character codePoint: 13) ]
    79 !
   105 !
    88 	(position = 0) ifTrue: [ ^ true ].
   114 	(position = 0) ifTrue: [ ^ true ].
    89 
   115 
    90 	self insideCRLF ifTrue: [ ^ false ].
   116 	self insideCRLF ifTrue: [ ^ false ].
    91 	
   117 	
    92 	^ (self peekBack = (Character codePoint: 13)) or: [ self peekBack = (Character codePoint: 10)].
   118 	^ (self peekBack = (Character codePoint: 13)) or: [ self peekBack = (Character codePoint: 10)].
       
   119 !
       
   120 
       
   121 line
       
   122 	^ self line: position
       
   123 !
       
   124 
       
   125 line: pos
       
   126 	| tmp line |
       
   127 	(pos = -1) ifTrue: [  ^ 0 ].
       
   128 	(pos > readLimit) ifTrue: [ ^ self error: 'Out of limit' ].
       
   129 	
       
   130 	tmp := position.
       
   131 	line := 0.
       
   132 	
       
   133 	(0 to: pos) do: 
       
   134 	[:index |
       
   135 		position := index.
       
   136 		self isStartOfLine ifTrue: [ line := line + 1 ]
       
   137 	].
       
   138 	position := tmp.
       
   139 	^ line
    93 ! !
   140 ! !
    94 
   141 
    95 !PPStream class methodsFor:'documentation'!
   142 !PPStream class methodsFor:'documentation'!
    96 
   143 
    97 version
   144 version