misc drills improvements

db4
Sam Anklesaria 2009-04-24 23:24:23 -05:00
parent 8be8357e4d
commit de345b6fb6
3 changed files with 68 additions and 23 deletions

View File

@ -0,0 +1,15 @@
USING: tools.deploy.config ;
H{
{ deploy-unicode? f }
{ deploy-threads? t }
{ deploy-math? t }
{ deploy-name "drills" }
{ deploy-ui? t }
{ deploy-compiler? t }
{ "stop-after-last-window?" t }
{ deploy-word-props? f }
{ deploy-c-types? f }
{ deploy-io 2 }
{ deploy-word-defs? f }
{ deploy-reflection 1 }
}

View File

@ -0,0 +1,36 @@
USING: accessors arrays cocoa.dialogs combinators continuations
fry grouping io.encodings.utf8 io.files io.styles kernel math
math.parser models models.arrow models.history namespaces random
sequences splitting ui ui.gadgets.alerts ui.gadgets.book-extras
ui.gadgets.books ui.gadgets.buttons ui.gadgets.frames
ui.gadgets.grids ui.gadgets.labels ui.gadgets.tracks fonts
wrap.strings system ;
IN: drills.deployed
SYMBOLS: it startLength ;
: big ( gadget -- gadget ) T{ font { name "sans-serif" } { size 30 } } >>font ;
: card ( model quot -- button ) <arrow> <label-control> big [ next ] <book-btn> ;
: op ( quot str -- gadget ) <label> big swap <book-bevel-btn> ;
: show ( model -- gadget ) dup it set-global [ random ] <arrow>
{ [ [ first ] card ]
[ [ second ] card ]
[ '[ |<< it get _ model-changed ] "No" op ]
[ '[ |<< [ it get [
_ value>> swap remove
[ [ it get go-back ] "Drill Complete" alert return ] when-empty
] change-model ] with-return ] "Yes" op ]
} cleave
2array { 1 0 } <track> swap [ 0.5 track-add ] each
3array <book*> 3 3 <frame> { 1 1 } >>filled-cell { 450 175 } >>pref-dim swap { 1 1 } grid-add
it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> { 1 2 } grid-add ;
: drill ( -- ) [
open-panel [
[ utf8 file-lines [ "\t" split [ 25 wrap-string ] map ] map dup [ first2 swap 2array ] map append ] map concat
[ length startLength set-global ] keep <history> [ add-history ] [ show ] bi
"Got it?" open-window
] [ 0 exit ] if*
] with-ui ;
MAIN: drill

View File

@ -3,40 +3,34 @@ fry grouping io.encodings.utf8 io.files io.styles kernel math
math.parser models models.arrow models.history namespaces random
sequences splitting ui ui.gadgets.alerts ui.gadgets.book-extras
ui.gadgets.books ui.gadgets.buttons ui.gadgets.frames
ui.gadgets.grids ui.gadgets.labels ui.gadgets.tracks ui.gestures
ui.gadgets.corners ;
ui.gadgets.grids ui.gadgets.labels ui.gadgets.tracks fonts
wrap.strings ;
IN: drills
SYMBOLS: it startLength ;
: big ( gadget -- gadget ) { "sans-serif" plain 30 } >>font ;
: big ( gadget -- gadget ) T{ font { name "sans-serif" } { size 30 } } >>font ;
: card ( model quot -- button ) <arrow> <label-control> big [ next ] <book-btn> ;
: op ( quot str -- gadget ) <label> big swap <book-bevel-btn> ;
: show ( model -- gadget ) dup it set-global [ random ] <arrow>
{ [ [ first ] card ]
[ [ [ second ] [ drop [ "malformed input" throw ] "Malformed Input" alert ] recover ] card ]
[ '[ |<< [ it get [
_ value>> swap remove
[ [ it get go-back ] "Drill Complete" alert return ] when-empty
] change-model ] with-return ] "Yes" op ]
[ '[ |<< it get _ model-changed ] "No" op ] } cleave
[ [ second ] card ]
[ '[ |<< it get _ model-changed ] "No" op ]
[ '[ |<< [ it get [
_ value>> swap remove
[ [ it get go-back ] "Drill Complete" alert return ] when-empty
] change-model ] with-return ] "Yes" op ]
} cleave
2array { 1 0 } <track> swap [ 0.5 track-add ] each
3array <book*> 3 3 <frame> { 450 175 } >>pref-dim swap @center grid-add
it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> @bottom grid-add ;
3array <book*> 3 3 <frame> { 1 1 } >>filled-cell { 450 175 } >>pref-dim swap { 1 1 } grid-add
it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> { 1 2 } grid-add ;
: drill ( -- ) [
: drill ( -- ) [
open-panel [
[ utf8 file-lines [ "\t" split
[ " " split 4 group [ " " join ] map ] map ] map ] map concat dup [ [ first ] [ second ] bi swap 2array ] map append
[ length startLength set-global ] keep <history> [ add-history ] [ show ] bi
"Got it?" open-window
[ utf8 file-lines [ "\t" split [ 25 wrap-string ] map ] map dup [ first2 swap 2array ] map append ] map concat
[ length startLength set-global ] keep <history> [ add-history ] [ show ] bi
"Got it?" open-window
] when*
] with-ui ;
MAIN: drill
! FIXME: command-line opening
! TODO: Menu bar
! TODO: Pious hot-buttons
MAIN: drill