--- a/PPStream.st Wed Nov 19 10:52:37 2014 +0000
+++ b/PPStream.st Mon Nov 24 00:09:23 2014 +0000
@@ -72,6 +72,32 @@
!PPStream methodsFor:'queries'!
+column
+ ^ self column: position.
+!
+
+column: pos
+ | column clear tmp |
+
+ pos > readLimit ifTrue: [ ^ Error signal: 'Oot of bounds' ].
+
+ tmp := position.
+ column := 0.
+ clear := true.
+
+ (0 to: pos) do:
+ [:index |
+ position := index.
+ self isStartOfLine ifTrue: [ clear := true ].
+
+ clear ifTrue: [ column := 0. clear := false ].
+ column := column + 1.
+ (position > readLimit) ifTrue: [ position := tmp. ^ column ].
+ ].
+ position := tmp.
+ ^ column
+!
+
insideCRLF
(position < 1) ifTrue: [ ^ false ].
@@ -90,6 +116,27 @@
self insideCRLF ifTrue: [ ^ false ].
^ (self peekBack = (Character codePoint: 13)) or: [ self peekBack = (Character codePoint: 10)].
+!
+
+line
+ ^ self line: position
+!
+
+line: pos
+ | tmp line |
+ (pos = -1) ifTrue: [ ^ 0 ].
+ (pos > readLimit) ifTrue: [ ^ self error: 'Out of limit' ].
+
+ tmp := position.
+ line := 0.
+
+ (0 to: pos) do:
+ [:index |
+ position := index.
+ self isStartOfLine ifTrue: [ line := line + 1 ]
+ ].
+ position := tmp.
+ ^ line
! !
!PPStream class methodsFor:'documentation'!