Fixing code for first-class fonts

db4
Slava Pestov 2009-01-26 02:21:28 -06:00
parent 4f5a927afb
commit bb27511753
16 changed files with 59 additions and 55 deletions

View File

@ -3,7 +3,7 @@
USING: hashtables io io.streams.plain io.streams.string USING: hashtables io io.streams.plain io.streams.string
colors summary make accessors splitting math.order colors summary make accessors splitting math.order
kernel namespaces assocs destructors strings sequences kernel namespaces assocs destructors strings sequences
present fry ; present fry strings.tables ;
IN: io.styles IN: io.styles
GENERIC: stream-format ( str style stream -- ) GENERIC: stream-format ( str style stream -- )
@ -116,19 +116,6 @@ M: plain-writer make-span-stream
M: plain-writer make-block-stream M: plain-writer make-block-stream
nip <ignore-close-stream> ; nip <ignore-close-stream> ;
: format-column ( seq ? -- seq )
[
dup [ length ] map supremum
'[ _ CHAR: \s pad-right ] map
] unless ;
: map-last ( seq quot -- seq )
[ dup length <reversed> ] dip '[ 0 = @ ] 2map ; inline
: format-table ( table -- seq )
flip [ format-column ] map-last
flip [ " " join ] map ;
M: plain-writer stream-write-table M: plain-writer stream-write-table
[ drop format-table [ print ] each ] with-output-stream* ; [ drop format-table [ print ] each ] with-output-stream* ;

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -1,4 +1,4 @@
! Copyright (C) 2009 Slava Pestov. ! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: tools.test ui.text.core-text ; USING: tools.test strings.tables ;
IN: ui.text.core-text.tests IN: strings.tables.tests

View File

@ -0,0 +1,21 @@
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel sequences fry ;
IN: strings.tables
<PRIVATE
: format-column ( seq ? -- seq )
[
dup [ length ] map supremum
'[ _ CHAR: \s pad-right ] map
] unless ;
: map-last ( seq quot -- seq )
[ dup length <reversed> ] dip '[ 0 = @ ] 2map ; inline
PRIVATE>
: format-table ( table -- seq )
flip [ format-column ] map-last
flip [ " " join ] map ;

View File

@ -1,5 +1,6 @@
USING: documents help.markup help.syntax ui.gadgets USING: documents help.markup help.syntax ui.gadgets
ui.gadgets.scrollers models strings ui.commands ; ui.gadgets.scrollers models strings ui.commands
ui.text colors ;
IN: ui.gadgets.editors IN: ui.gadgets.editors
HELP: editor HELP: editor
@ -9,8 +10,8 @@ $nl
{ $list { $list
{ { $snippet "font" } " - a " { $link font } "." } { { $snippet "font" } " - a " { $link font } "." }
{ { $snippet "color" } " - a " { $link color } "." } { { $snippet "color" } " - a " { $link color } "." }
{ { $snippet "caret-color" } " - a " { $link color } ". } { { $snippet "caret-color" } " - a " { $link color } "." }
{ { $snippet "selection-color" } " - a " { $link color } ". } { { $snippet "selection-color" } " - a " { $link color } "." }
{ { $snippet "caret" } " - a " { $link model } " storing a line/column pair." } { { $snippet "caret" } " - a " { $link model } " storing a line/column pair." }
{ { $snippet "mark" } " - a " { $link model } " storing a line/column pair. If there is no selection, the mark is equal to the caret, otherwise the mark is located at the opposite end of the selection from the caret." } { { $snippet "mark" } " - a " { $link model } " storing a line/column pair. If there is no selection, the mark is equal to the caret, otherwise the mark is located at the opposite end of the selection from the caret." }
{ { $snippet "focused?" } " - a boolean." } { { $snippet "focused?" } " - a boolean." }

View File

@ -1,7 +1,7 @@
! Copyright (C) 2006, 2009 Slava Pestov. ! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays kernel math namespaces make sequences words io USING: arrays kernel math namespaces make sequences words io
math.vectors ui.gadgets columns accessors math.vectors ui.gadgets columns accessors strings.tables
math.geometry.rect locals fry ; math.geometry.rect locals fry ;
IN: ui.gadgets.grids IN: ui.gadgets.grids

View File

@ -1,15 +1,15 @@
! Copyright (C) 2005, 2009 Slava Pestov. ! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays ui.gadgets ui.gadgets.borders ui.gadgets.buttons USING: arrays hashtables io kernel namespaces sequences
io.styles strings quotations math opengl combinators
math.vectors sorting splitting assocs classes.tuple models
continuations destructors accessors math.geometry.rect fry
ui.gadgets ui.gadgets.borders ui.gadgets.buttons
ui.gadgets.labels ui.gadgets.scrollers ui.gadgets.paragraphs ui.gadgets.labels ui.gadgets.scrollers ui.gadgets.paragraphs
ui.gadgets.incremental ui.gadgets.packs ui.gadgets.theme ui.gadgets.incremental ui.gadgets.packs ui.gadgets.theme
ui.gadgets.menus ui.clipboards ui.gestures ui.traverse ui.render ui.gadgets.menus ui.clipboards ui.gestures ui.traverse ui.render
hashtables io kernel namespaces sequences io.styles strings ui.text ui.gadgets.presentations ui.gadgets.grids
quotations math opengl combinators math.vectors sorting ui.gadgets.grid-lines ;
splitting assocs ui.gadgets.presentations
ui.gadgets.grids ui.gadgets.grid-lines
classes.tuple models continuations destructors accessors
math.geometry.rect fry ;
IN: ui.gadgets.panes IN: ui.gadgets.panes
TUPLE: pane < pack TUPLE: pane < pack
@ -192,10 +192,11 @@ M: pane-stream make-span-stream
[ font swap at "monospace" or >>name ] [ font swap at "monospace" or >>name ]
[ [
font-style swap at { font-style swap at {
{ f [ ] }
{ plain [ ] } { plain [ ] }
{ bold [ t >>bold ] } { bold [ t >>bold? ] }
{ italic [ t >>italic ] } { italic [ t >>italic? ] }
{ bold-italic [ t >>bold t >>italic ] } { bold-italic [ t >>bold? t >>italic? ] }
} case } case
] ]
[ font-size swap at 12 or >>size ] [ font-size swap at 12 or >>size ]

View File

@ -1,6 +1,4 @@
IN: ui.gadgets.slots.tests IN: ui.gadgets.slots.tests
USING: assocs ui.gadgets.slots tools.test refs ; USING: assocs ui.gadgets.slots tools.test refs ;
\ <editable-slot> must-infer [ t ] [ [ ] [ ] { 1 2 3 } 2 <value-ref> <slot-editor> slot-editor? ] unit-test
[ t ] [ { 1 2 3 } 2 <value-ref> <slot-editor> slot-editor? ] unit-test

View File

@ -5,7 +5,7 @@ IN: ui.operations
: $operations ( element -- ) : $operations ( element -- )
>quotation call >quotation call
f f operations>commands f operations>commands
command-map. ; command-map. ;
: $operation ( element -- ) : $operation ( element -- )

View File

@ -5,7 +5,7 @@ io.streams.string math help help.markup accessors ;
: my-pprint pprint ; : my-pprint pprint ;
[ drop t ] \ my-pprint [ ] [ ] f operation boa "op" set [ drop t ] \ my-pprint [ ] f operation boa "op" set
[ [ 3 my-pprint ] ] [ [ [ 3 my-pprint ] ] [
3 "op" get command>> command-quot 3 "op" get command>> command-quot
@ -13,7 +13,7 @@ io.streams.string math help help.markup accessors ;
[ "3" ] [ [ 3 "op" get invoke-command ] with-string-writer ] unit-test [ "3" ] [ [ 3 "op" get invoke-command ] with-string-writer ] unit-test
[ drop t ] \ my-pprint [ ] [ editor-string ] f operation boa [ drop t ] \ my-pprint [ editor-string ] f operation boa
"op" set "op" set
[ "\"4\"" ] [ [ "\"4\"" ] [

View File

@ -24,8 +24,8 @@ CONSTANT: font-names
: font-traits ( font -- n ) : font-traits ( font -- n )
[ 0 ] dip [ 0 ] dip
[ bold>> [ (bold) ] when ] [ bold?>> [ (bold) ] when ]
[ italic>> [ (italic) ] when ] bi ; [ italic?>> [ (italic) ] when ] bi ;
: apply-font-traits ( font style -- font' ) : apply-font-traits ( font style -- font' )
[ drop ] [ [ 0.0 f ] dip font-traits dup ] 2bi [ drop ] [ [ 0.0 f ] dip font-traits dup ] 2bi

View File

@ -5,6 +5,8 @@ IN: ui.text
TUPLE: font name size bold? italic? ; TUPLE: font name size bold? italic? ;
: <font> ( -- font ) font new ; inline
<PRIVATE <PRIVATE
SYMBOL: font-renderer SYMBOL: font-renderer

View File

@ -2,3 +2,9 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: tools.test ui.tools.listener.completion ; USING: tools.test ui.tools.listener.completion ;
IN: ui.tools.listener.completion.tests IN: ui.tools.listener.completion.tests
[ t ] [ { "USING:" "A" "B" "C" } complete-USING:? ] unit-test
[ f ] [ { "USING:" "A" "B" "C" ";" } complete-USING:? ] unit-test
[ t ] [ { "X" ";" "USING:" "A" "B" "C" } complete-USING:? ] unit-test

View File

@ -1,7 +1,7 @@
! Copyright (C) 2009 Slava Pestov. ! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors documents kernel math math.order USING: accessors documents kernel math math.order
sequences fry ; sequences fry io.styles ;
IN: ui.tools.listener.history IN: ui.tools.listener.history
TUPLE: history document elements index ; TUPLE: history document elements index ;

View File

@ -96,13 +96,6 @@ IN: ui.tools.listener.tests
[ ] [ <listener-gadget> "listener" set ] unit-test [ ] [ <listener-gadget> "listener" set ] unit-test
"listener" get [ "listener" get [
[ "dup" ] [
\ dup word-completion-string
] unit-test
[ "equal?" ]
[ \ array \ equal? method word-completion-string ] unit-test
<pane> <interactor> "i" set <pane> <interactor> "i" set
[ t ] [ "i" get interactor? ] unit-test [ t ] [ "i" get interactor? ] unit-test
@ -149,10 +142,4 @@ IN: ui.tools.listener.tests
<gadget> "l" get show-popup <gadget> "l" get show-popup
<gadget> "l" get show-popup <gadget> "l" get show-popup
"l" get hide-popup "l" get hide-popup
] unit-test ] unit-test
[ t ] [ { "USING:" "A" "B" "C" } complete-USING:? ] unit-test
[ f ] [ { "USING:" "A" "B" "C" ";" } complete-USING:? ] unit-test
[ t ] [ { "X" ";" "USING:" "A" "B" "C" } complete-USING:? ] unit-test

View File

@ -1,7 +1,7 @@
USING: help.markup help.syntax strings quotations debugger USING: help.markup help.syntax strings quotations debugger
namespaces ui.backend ui.gadgets ui.gadgets.worlds namespaces ui.backend ui.gadgets ui.gadgets.worlds
ui.gadgets.tracks ui.gadgets.packs ui.gadgets.grids ui.gadgets.tracks ui.gadgets.packs ui.gadgets.grids
math.geometry.rect colors ; math.geometry.rect colors ui.text ;
IN: ui IN: ui
HELP: windows HELP: windows
@ -68,7 +68,7 @@ ARTICLE: "ui-glossary" "UI glossary"
{ $table { $table
{ "color" { "an instance of " { $link color } } } { "color" { "an instance of " { $link color } } }
{ "dimension" "a pair of integers denoting pixel size on screen" } { "dimension" "a pair of integers denoting pixel size on screen" }
{ "font" { "an instance of " { link font } } } { "font" { "an instance of " { $link font } } }
{ "gadget" { "a graphical element which responds to user input. Gadgets are tuples which (directly or indirectly) inherit from " { $link gadget } "." } } { "gadget" { "a graphical element which responds to user input. Gadgets are tuples which (directly or indirectly) inherit from " { $link gadget } "." } }
{ "label specifier" { "a string, " { $link f } " or a gadget. See " { $link "ui.gadgets.buttons" } } } { "label specifier" { "a string, " { $link f } " or a gadget. See " { $link "ui.gadgets.buttons" } } }
{ "orientation specifier" { "one of " { $snippet "{ 0 1 }" } " or " { $snippet "{ 1 0 }" } ", with the former denoting vertical orientation and the latter denoting horizontal. Using a vector instead of symbolic constants allows these values to be directly useful in co-ordinate calculations" } } { "orientation specifier" { "one of " { $snippet "{ 0 1 }" } " or " { $snippet "{ 1 0 }" } ", with the former denoting vertical orientation and the latter denoting horizontal. Using a vector instead of symbolic constants allows these values to be directly useful in co-ordinate calculations" } }