From 5526fc24bb18aab83ed18c3224a0c611319f9baf Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 23 Jul 2005 05:16:28 +0000 Subject: [PATCH] removed >list usage --- library/ui/editors.factor | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/library/ui/editors.factor b/library/ui/editors.factor index 0ac783f0ad..f1a6e5bd4d 100644 --- a/library/ui/editors.factor +++ b/library/ui/editors.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: gadgets -USING: generic kernel line-editor lists math matrices namespaces +USING: generic kernel line-editor math matrices namespaces sdl sequences strings styles vectors ; ! An editor gadget wraps a line editor object and passes @@ -29,19 +29,11 @@ TUPLE: editor line caret ; : run-char-widths ( font str -- wlist ) #! List of x co-ordinates of each character. - >list [ ch>string size-string drop ] map-with + >vector [ ch>string size-string drop ] map-with dup 0 [ + ] accumulate swap 2 v/n v+ ; -: (x>offset) ( n x wlist -- offset ) - dup [ - uncons >r over > - [ r> 2drop ] [ >r 1 + r> r> (x>offset) ] ifte - ] [ - 2drop - ] ifte ; - : x>offset ( x font str -- offset ) - run-char-widths 0 -rot (x>offset) ; + run-char-widths [ <= ] find-with drop ; : set-caret-x ( x editor -- ) #! Move the caret to a clicked location.