removed >list usage

cvs
Slava Pestov 2005-07-23 05:16:28 +00:00
parent bd73c4eded
commit 5526fc24bb
1 changed files with 3 additions and 11 deletions

View File

@ -1,7 +1,7 @@
! Copyright (C) 2005 Slava Pestov. ! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license. ! See http://factor.sf.net/license.txt for BSD license.
IN: gadgets IN: gadgets
USING: generic kernel line-editor lists math matrices namespaces USING: generic kernel line-editor math matrices namespaces
sdl sequences strings styles vectors ; sdl sequences strings styles vectors ;
! An editor gadget wraps a line editor object and passes ! An editor gadget wraps a line editor object and passes
@ -29,19 +29,11 @@ TUPLE: editor line caret ;
: run-char-widths ( font str -- wlist ) : run-char-widths ( font str -- wlist )
#! List of x co-ordinates of each character. #! 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+ ; 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 ) : x>offset ( x font str -- offset )
run-char-widths 0 -rot (x>offset) ; run-char-widths [ <= ] find-with drop ;
: set-caret-x ( x editor -- ) : set-caret-x ( x editor -- )
#! Move the caret to a clicked location. #! Move the caret to a clicked location.