Paste: Alignment

Author: Muzzleflash
Mode: factor
Date: Wed, 31 Mar 2010 19:13:37
Plain Text |
GENERIC: line-offset ( editor -- offset )

M: editor line-offset
    dup alignment>>
    {
      { left-align [ drop { 0 0 } clone ] }
      { center-align [ [ dim>> first ]
        [ [ font>> ] [ control-value ] bi ] bi text-dim first
        [ 2 / ] bi@ - 0 2array ] }
      { right-align [ [ dim>> first ] [ [ font>> ]
        [ control-value ] bi text-dim first ] bi - 0 2array ] }
    } case ;

: with-translated-line ( editor qout -- )
    [ line-offset ] dip with-translation ; inline
    
    
PRIVATE>

M: editor draw-line ( line index editor -- )
    [ 
        [
            [ selected-lines get at ] dip over
            [ draw-selected-line ]
            [ nip draw-unselected-line ] if
        ] 3curry
    ] keep swap with-translated-line ;
    
M: editor draw-gadget*
    dup compute-selection selected-lines [
        [ draw-lines ] [ draw-caret ] bi
    ] with-variable ;

New Annotation

Summary:
Author:
Mode:
Body: