summaryrefslogtreecommitdiff
path: root/input.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'input.lisp')
-rw-r--r--input.lisp15
1 files changed, 10 insertions, 5 deletions
diff --git a/input.lisp b/input.lisp
index 3e646b4..4f803ec 100644
--- a/input.lisp
+++ b/input.lisp
@@ -5,17 +5,22 @@
(file nil :read-only t)
(data nil :read-only t))
-(defun has-data? (input)
- (< (input-cursor input)
+(defun has-data? (input &optional (window-size 1))
+ (< (+ window-size -1 (input-cursor input))
(length (input-data input))))
-(defun element (input)
+(defun peek-1 (input)
(char (input-data input)
(input-cursor input)))
-(defun advance (input)
+(defun peek-n (input window-size)
+ (subseq (input-data input)
+ (input-cursor input)
+ window-size))
+
+(defun advance (input &optional (amount 1))
(let ((new-input (copy-structure input)))
- (incf (input-cursor new-input))
+ (incf (input-cursor new-input) amount)
new-input))
(declaim (ftype (function (simple-string) (values input &optional)) from-string))