From f657c60c4f3c235e193ce8f4931eb0f9a01fc843 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Sun, 29 Mar 2009 22:58:04 -0500 Subject: [PATCH] Some cleanup in documents.elements --- basis/documents/elements/elements.factor | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/basis/documents/elements/elements.factor b/basis/documents/elements/elements.factor index adb498df13..9a8b82acac 100644 --- a/basis/documents/elements/elements.factor +++ b/basis/documents/elements/elements.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2006, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: arrays combinators documents fry kernel math sequences -unicode.categories accessors ; +accessors unicode.categories combinators.short-circuit ; IN: documents.elements GENERIC: prev-elt ( loc document elt -- newloc ) @@ -20,14 +20,14 @@ SINGLETON: char-elt M: char-elt prev-elt - drop [ drop -1 +col ] (prev-char) ; + drop [ drop -1 +col ] prev ; M: char-elt next-elt - drop [ drop 1 +col ] (next-char) ; + drop [ drop 1 +col ] next ; SINGLETON: one-char-elt @@ -55,7 +55,7 @@ M: one-char-elt next-elt 2drop ; [ [ first2 swap ] dip doc-line ] dip call ] dip =col ; inline -: ((word-elt)) ( n seq -- n seq ? ) +: blank-at? ( n seq -- n seq ? ) 2dup ?nth blank? ; : break-detector ( ? -- quot ) @@ -65,7 +65,7 @@ M: one-char-elt next-elt 2drop ; break-detector find-last-from drop ?1+ ; : (next-word) ( col str ? -- col ) - [ break-detector find-from drop ] [ drop length ] 2bi or ; + { [ break-detector find-from drop ] [ drop length ] } 2|| ; PRIVATE> @@ -83,13 +83,13 @@ SINGLETON: word-elt M: word-elt prev-elt drop - [ [ [ 1- ] dip ((word-elt)) (prev-word) ] (word-elt) ] - (prev-char) ; + [ [ [ 1- ] dip blank-at? (prev-word) ] (word-elt) ] + prev ; M: word-elt next-elt drop - [ [ ((word-elt)) (next-word) ] (word-elt) ] - (next-char) ; + [ [ blank-at? (next-word) ] (word-elt) ] + next ; SINGLETON: one-line-elt @@ -118,4 +118,4 @@ SINGLETON: doc-elt M: doc-elt prev-elt 3drop { 0 0 } ; -M: doc-elt next-elt drop nip doc-end ; \ No newline at end of file +M: doc-elt next-elt drop nip doc-end ;