Merge branch 'master' of git://factorcode.org/git/factor

db4
Daniel Ehrenberg 2009-03-16 22:31:15 -05:00
commit a26fb62831
23 changed files with 63 additions and 74 deletions

View File

@ -0,0 +1 @@
unportable

View File

@ -1,2 +1,2 @@
Doug Coleman Doug Coleman
Slava Pestov Daniel Ehrenberg

View File

@ -83,14 +83,15 @@ ERROR: bmp-not-supported n ;
:: fixup-color-index ( loading-bitmap -- loading-bitmap ) :: fixup-color-index ( loading-bitmap -- loading-bitmap )
loading-bitmap width>> :> width loading-bitmap width>> :> width
width 3 * :> width*3
loading-bitmap height>> abs :> height loading-bitmap height>> abs :> height
loading-bitmap color-index>> length :> color-index-length loading-bitmap color-index>> length :> color-index-length
height 3 * :> height*3 color-index-length height /i :> stride
color-index-length width height*3 * - height*3 /i :> misaligned color-index-length width*3 height * - height /i :> padding
misaligned 0 > [ padding 0 > [
loading-bitmap [ loading-bitmap [
loading-bitmap width>> misaligned + 3 * <sliced-groups> stride <sliced-groups>
[ 3 misaligned * head* ] map concat [ width*3 head-slice ] map concat
] change-color-index ] change-color-index
] [ ] [
loading-bitmap loading-bitmap

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

View File

@ -477,10 +477,8 @@ ERROR: unknown-component-order ifd ;
[ unknown-component-order ] [ unknown-component-order ]
} case ; } case ;
: handle-alpha-data ( ifd -- ifd ) : normalize-alpha-data ( seq -- byte-array )
dup extra-samples find-tag { ! [ normalize-alpha-data ] change-bitmap
{ extra-samples-associated-alpha-data [
[
B{ } like dup B{ } like dup
byte-array>float-array byte-array>float-array
4 <sliced-groups> 4 <sliced-groups>
@ -490,13 +488,13 @@ ERROR: unknown-component-order ifd ;
] [ ] [
[ 3 head-slice ] dip '[ _ / ] change-each [ 3 head-slice ] dip '[ _ / ] change-each
] if ] if
] each ] each ;
] change-bitmap
] } : handle-alpha-data ( ifd -- ifd )
{ extra-samples-unspecified-alpha-data [ dup extra-samples find-tag {
] } { extra-samples-associated-alpha-data [ ] }
{ extra-samples-unassociated-alpha-data [ { extra-samples-unspecified-alpha-data [ ] }
] } { extra-samples-unassociated-alpha-data [ ] }
[ bad-extra-samples ] [ bad-extra-samples ]
} case ; } case ;

View File

@ -530,7 +530,7 @@ M: ebnf-non-terminal (transform) ( ast -- parser )
: EBNF: : EBNF:
reset-tokenizer CREATE-WORD dup ";EBNF" parse-multiline-string reset-tokenizer CREATE-WORD dup ";EBNF" parse-multiline-string
ebnf>quot swapd 1 1 <effect> define-declared "ebnf-parser" set-word-prop ebnf>quot swapd (( input -- ast )) define-declared "ebnf-parser" set-word-prop
reset-tokenizer ; parsing reset-tokenizer ; parsing

View File

@ -107,13 +107,11 @@ C: <box> box
transitions>quot ; transitions>quot ;
: states>code ( words dfa -- ) : states>code ( words dfa -- )
[
'[ '[
dup _ word>quot dup _ word>quot
(( last-match index string -- ? )) (( last-match index string -- ? ))
define-declared define-declared
] each ] each ;
] with-compilation-unit ;
: states>words ( dfa -- words dfa ) : states>words ( dfa -- words dfa )
dup transitions>> keys [ gensym ] H{ } map>assoc dup transitions>> keys [ gensym ] H{ } map>assoc
@ -126,12 +124,9 @@ C: <box> box
PRIVATE> PRIVATE>
: simple-define-temp ( quot effect -- word )
[ define-temp ] with-compilation-unit ;
: dfa>word ( dfa -- quot ) : dfa>word ( dfa -- quot )
dfa>main-word execution-quot '[ drop [ f ] 2dip @ ] dfa>main-word execution-quot '[ drop [ f ] 2dip @ ]
(( start-index string regexp -- i/f )) simple-define-temp ; (( start-index string regexp -- i/f )) define-temp ;
: dfa>shortest-word ( dfa -- word ) : dfa>shortest-word ( dfa -- word )
t shortest? [ dfa>word ] with-variable ; t shortest? [ dfa>word ] with-variable ;

View File

@ -4,7 +4,7 @@ USING: accessors combinators kernel kernel.private math sequences
sequences.private strings sets assocs prettyprint.backend sequences.private strings sets assocs prettyprint.backend
prettyprint.custom make lexer namespaces parser arrays fry locals prettyprint.custom make lexer namespaces parser arrays fry locals
regexp.parser splitting sorting regexp.ast regexp.negation regexp.parser splitting sorting regexp.ast regexp.negation
regexp.compiler words call call.private math.ranges ; regexp.compiler compiler.units words call call.private math.ranges ;
IN: regexp IN: regexp
TUPLE: regexp TUPLE: regexp
@ -35,7 +35,7 @@ M: lookbehind question>quot ! Returns ( index string -- ? )
: match-index-from ( i string regexp -- index/f ) : match-index-from ( i string regexp -- index/f )
! This word is unsafe. It assumes that i is a fixnum ! This word is unsafe. It assumes that i is a fixnum
! and that string is a string. ! and that string is a string.
dup dfa>> execute-unsafe( index string regexp -- i/f ) ; dup dfa>> execute-unsafe( index string regexp -- i/f ) ; inline
GENERIC: end/start ( string regexp -- end start ) GENERIC: end/start ( string regexp -- end start )
M: regexp end/start drop length 0 ; M: regexp end/start drop length 0 ;
@ -129,31 +129,28 @@ PRIVATE>
GENERIC: compile-regexp ( regex -- regexp ) GENERIC: compile-regexp ( regex -- regexp )
: regexp-initial-word ( i string regexp -- i/f ) : regexp-initial-word ( i string regexp -- i/f )
compile-regexp match-index-from ; [ compile-regexp ] with-compilation-unit match-index-from ;
: do-compile-regexp ( regexp -- regexp ) M: regexp compile-regexp ( regexp -- regexp )
dup '[ dup '[
dup \ regexp-initial-word = dup \ regexp-initial-word =
[ drop _ get-ast ast>dfa dfa>word ] when [ drop _ get-ast ast>dfa dfa>word ] when
] change-dfa ; ] change-dfa ;
M: regexp compile-regexp ( regexp -- regexp )
do-compile-regexp ;
M: reverse-regexp compile-regexp ( regexp -- regexp ) M: reverse-regexp compile-regexp ( regexp -- regexp )
t backwards? [ do-compile-regexp ] with-variable ; t backwards? [ call-next-method ] with-variable ;
DEFER: compile-next-match DEFER: compile-next-match
: next-initial-word ( i string regexp -- i start end string ) : next-initial-word ( i string regexp -- i start end string )
compile-next-match do-next-match ; [ compile-next-match ] with-compilation-unit do-next-match ;
: compile-next-match ( regexp -- regexp ) : compile-next-match ( regexp -- regexp )
dup '[ dup '[
dup \ next-initial-word = [ dup \ next-initial-word = [
drop _ [ compile-regexp dfa>> def>> ] [ reverse-regexp? ] bi drop _ [ compile-regexp dfa>> def>> ] [ reverse-regexp? ] bi
'[ { array-capacity string regexp } declare _ _ next-match ] '[ { array-capacity string regexp } declare _ _ next-match ]
(( i string regexp -- i start end string )) simple-define-temp (( i string regexp -- i start end string )) define-temp
] when ] when
] change-next-match ; ] change-next-match ;

View File

@ -8,7 +8,7 @@ ui.backend ui.clipboards ui.gadgets ui.gadgets.worlds
ui.backend.cocoa.views core-foundation core-foundation.run-loop ui.backend.cocoa.views core-foundation core-foundation.run-loop
core-graphics.types threads math.rectangles fry libc core-graphics.types threads math.rectangles fry libc
generalizations alien.c-types cocoa.views generalizations alien.c-types cocoa.views
combinators io.thread locals ; combinators io.thread locals call ;
IN: ui.backend.cocoa IN: ui.backend.cocoa
TUPLE: handle ; TUPLE: handle ;
@ -152,7 +152,7 @@ M: cocoa-ui-backend (with-ui)
"UI" assert.app [ "UI" assert.app [
[ [
init-clipboard init-clipboard
cocoa-init-hook get call cocoa-init-hook get call( -- )
start-ui start-ui
f io-thread-running? set-global f io-thread-running? set-global
init-thread-timer init-thread-timer

View File

@ -153,7 +153,7 @@ PRIVATE>
"UI update" spawn drop ; "UI update" spawn drop ;
: start-ui ( quot -- ) : start-ui ( quot -- )
call notify-ui-thread start-ui-thread ; call( -- ) notify-ui-thread start-ui-thread ;
: restore-windows ( -- ) : restore-windows ( -- )
[ [
@ -193,6 +193,6 @@ M: object close-window
] "ui" add-init-hook ] "ui" add-init-hook
: with-ui ( quot -- ) : with-ui ( quot -- )
ui-running? [ call ] [ '[ init-ui @ ] (with-ui) ] if ; ui-running? [ call( -- ) ] [ '[ init-ui @ ] (with-ui) ] if ;
HOOK: beep ui-backend ( -- ) HOOK: beep ui-backend ( -- )

View File

@ -1,17 +1,18 @@
USING: accessors arrays cocoa.dialogs combinators continuations USING: accessors arrays cocoa.dialogs combinators continuations
fry grouping io.encodings.utf8 io.files io.styles kernel math fry grouping io.encodings.utf8 io.files io.styles kernel math
math.parser models models.filter models.history namespaces random math.parser models models.arrow models.history namespaces random
sequences splitting ui ui.gadgets.alerts ui.gadgets.book-extras sequences splitting ui ui.gadgets.alerts ui.gadgets.book-extras
ui.gadgets.books ui.gadgets.buttons ui.gadgets.frames ui.gadgets.books ui.gadgets.buttons ui.gadgets.frames
ui.gadgets.grids ui.gadgets.labels ui.gadgets.tracks ui.gestures ; ui.gadgets.grids ui.gadgets.labels ui.gadgets.tracks ui.gestures
ui.gadgets.corners ;
IN: drills IN: drills
SYMBOLS: it startLength ; SYMBOLS: it startLength ;
: big ( gadget -- gadget ) { "sans-serif" plain 30 } >>font ; : big ( gadget -- gadget ) { "sans-serif" plain 30 } >>font ;
: card ( model quot -- button ) <filter> <label-control> big [ next ] <book-btn> ; : card ( model quot -- button ) <arrow> <label-control> big [ next ] <book-btn> ;
: op ( quot str -- gadget ) <label> big swap <book-bevel-btn> ; : op ( quot str -- gadget ) <label> big swap <book-bevel-btn> ;
: show ( model -- gadget ) dup it set-global [ random ] <filter> : show ( model -- gadget ) dup it set-global [ random ] <arrow>
{ [ [ first ] card ] { [ [ first ] card ]
[ [ [ second ] [ drop [ "malformed input" throw ] "Malformed Input" alert ] recover ] card ] [ [ [ second ] [ drop [ "malformed input" throw ] "Malformed Input" alert ] recover ] card ]
[ '[ |<< [ it get [ [ '[ |<< [ it get [
@ -20,8 +21,8 @@ SYMBOLS: it startLength ;
] change-model ] with-return ] "Yes" op ] ] change-model ] with-return ] "Yes" op ]
[ '[ |<< it get _ model-changed ] "No" op ] } cleave [ '[ |<< it get _ model-changed ] "No" op ] } cleave
2array { 1 0 } <track> swap [ 0.5 track-add ] each 2array { 1 0 } <track> swap [ 0.5 track-add ] each
3array <book*> <frame> { 450 175 } >>pref-dim swap @center grid-add 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 ] <filter> <label-control> @bottom grid-add ; it get [ length startLength get swap - number>string "/" startLength get number>string 3append ] <arrow> <label-control> @bottom grid-add ;
: drill ( -- ) [ : drill ( -- ) [
open-panel [ open-panel [

1
extra/drills/tags.txt Normal file
View File

@ -0,0 +1 @@
unportable

View File

@ -1,14 +1,14 @@
USING: peg.ebnf help.syntax help.markup strings ; USING: peg.ebnf help.syntax help.markup strings ;
IN: peg-lexer IN: peg-lexer
ABOUT: "peg-lexer"
HELP: ON-BNF: HELP: ON-BNF:
{ $syntax "ON-BNF: word ... ;ON-BNF" } { $syntax "ON-BNF: word ... ;ON-BNF" }
{ $description "Creates a parsing word using a parser for lexer control, adding the resulting ast to the stack. Parser syntax is as in " { $link POSTPONE: EBNF: } } ; { $description "Creates a parsing word using a parser for lexer control, adding the resulting ast to the stack. Parser syntax is as in " { $link POSTPONE: EBNF: } } ;
HELP: create-bnf HELP: create-bnf
{ $values { "word" string } { "parser" parser } } { $values { "name" string } { "parser" parser } }
{ $description "Runtime equivalent of " { $link POSTPONE: ON-BNF: } " also useful with manually constructed parsers." } ; { $description "Runtime equivalent of " { $link POSTPONE: ON-BNF: } " also useful with manually constructed parsers." } ;
HELP: factor HELP: factor
{ $values { "input" string } { "ast" "a sequence of tokens" } }
{ $description "Tokenizer that acts like standard factor lexer, separating tokens by whitespace." } ; { $description "Tokenizer that acts like standard factor lexer, separating tokens by whitespace." } ;

View File

@ -1,9 +1,9 @@
! Copyright (C) 2007, 2008 Slava Pestov. ! Copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays hashtables help.markup help.stylesheet io USING: arrays hashtables help.markup help.stylesheet io
io.styles kernel math models namespaces sequences ui ui.gadgets io.styles kernel math models namespaces sequences ui ui.gadgets
ui.gadgets.books ui.gadgets.panes ui.gestures ui.pens.gradient ui.gadgets.books ui.gadgets.panes ui.gestures ui.pens.gradient
parser accessors colors ; parser accessors colors fry ;
IN: slides IN: slides
CONSTANT: stylesheet CONSTANT: stylesheet
@ -104,4 +104,4 @@ TUPLE: slides < book ;
} set-gestures } set-gestures
: slides-window ( slides -- ) : slides-window ( slides -- )
[ <slides> "Slides" open-window ] with-ui ; '[ _ <slides> "Slides" open-window ] with-ui ;

View File

@ -1,4 +1,4 @@
USING: accessors ui ui.gadgets ui.gadgets.labels ui.gadgets.buttons ui.gadgets.packs locals sequences io.styles ; USING: accessors ui ui.gadgets ui.gadgets.labels ui.gadgets.buttons ui.gadgets.packs locals sequences io.styles ;
IN: ui.gadgets.alerts IN: ui.gadgets.alerts
:: alert ( quot string -- ) <pile> { 10 10 } >>gap 1 >>align string <label> { "sans-serif" plain 18 } >>font { 200 100 } >>pref-dim add-gadget :: alert ( quot string -- ) <pile> { 10 10 } >>gap 1 >>align string <label> { "sans-serif" plain 18 } >>font { 200 100 } >>pref-dim add-gadget
"okay" [ close-window ] quot append <bevel-button> add-gadget "" open-window ; "okay" [ close-window ] quot append <border-button> add-gadget "" open-window ;

View File

@ -6,6 +6,6 @@ IN: ui.gadgets.book-extras
: prev ( book -- ) model>> [ 1 - ] change-model ; : prev ( book -- ) model>> [ 1 - ] change-model ;
: (book-t) ( quot -- quot ) '[ : owner ( gadget -- book ) parent>> dup book? [ owner ] unless ; owner @ ] ; : (book-t) ( quot -- quot ) '[ : owner ( gadget -- book ) parent>> dup book? [ owner ] unless ; owner @ ] ;
: <book-btn> ( label quot -- button ) (book-t) <button> ; : <book-btn> ( label quot -- button ) (book-t) <button> ;
: <book-bevel-btn> ( label quot -- button ) (book-t) <bevel-button> ; : <book-bevel-btn> ( label quot -- button ) (book-t) <border-button> ;
: >>> ( label -- button ) [ next ] <book-btn> ; : >>> ( label -- button ) [ next ] <book-btn> ;
: <<< ( label -- button ) [ prev ] <book-btn> ; : <<< ( label -- button ) [ prev ] <book-btn> ;

View File

@ -1,6 +1,6 @@
USING: accessors sequences namespaces ui.render opengl fry ; USING: accessors sequences namespaces ui.render opengl fry kernel ;
IN: ui.utils IN: ui.utils
SYMBOLS: width height ; SYMBOLS: width height ;
: store-dim ( gadget -- ) dim>> [ first width set ] [ second height set ] bi ; : store-dim ( gadget -- ) dim>> [ first width set ] [ second height set ] bi ;
: with-dim ( gadget quot -- ) '[ _ store-dim @ ] with-scope ; : with-dim ( gadget quot -- ) '[ _ store-dim @ ] with-scope ; inline
: with-w/h ( gadget quot -- ) '[ origin get _ with-translation ] with-dim ; : with-w/h ( gadget quot -- ) '[ origin get _ with-translation ] with-dim ; inline

View File

@ -5,7 +5,7 @@
<t:title><t:label t:name="title" /></t:title> <t:title><t:label t:name="title" /></t:title>
<div class="description"> <div class="description">
<t:farkup t:name="parsed" t:parsed="true" /> <t:farkup t:name="content" />
</div> </div>
<p> <p>

View File

@ -47,7 +47,7 @@ article "ARTICLES" {
: <article> ( title -- article ) article new swap >>title ; : <article> ( title -- article ) article new swap >>title ;
TUPLE: revision id title author date content parsed description ; TUPLE: revision id title author date content description ;
revision "REVISIONS" { revision "REVISIONS" {
{ "id" "ID" INTEGER +db-assigned-id+ } { "id" "ID" INTEGER +db-assigned-id+ }
@ -55,7 +55,6 @@ revision "REVISIONS" {
{ "author" "AUTHOR" { VARCHAR 256 } +not-null+ } ! uid { "author" "AUTHOR" { VARCHAR 256 } +not-null+ } ! uid
{ "date" "DATE" TIMESTAMP +not-null+ } { "date" "DATE" TIMESTAMP +not-null+ }
{ "content" "CONTENT" TEXT +not-null+ } { "content" "CONTENT" TEXT +not-null+ }
{ "parsed" "PARSED" FACTOR-BLOB +not-null+ } ! Farkup AST
{ "description" "DESCRIPTION" TEXT } { "description" "DESCRIPTION" TEXT }
} define-persistent } define-persistent
@ -72,9 +71,6 @@ M: revision feed-entry-url id>> revision-url ;
: <revision> ( id -- revision ) : <revision> ( id -- revision )
revision new swap >>id ; revision new swap >>id ;
: compute-html ( revision -- )
dup content>> parse-farkup >>parsed drop ;
: validate-title ( -- ) : validate-title ( -- )
{ { "title" [ v-one-line ] } } validate-params ; { { "title" [ v-one-line ] } } validate-params ;
@ -141,13 +137,12 @@ M: revision feed-entry-url id>> revision-url ;
[ title>> ] [ id>> ] bi article boa insert-tuple ; [ title>> ] [ id>> ] bi article boa insert-tuple ;
: add-revision ( revision -- ) : add-revision ( revision -- )
[ compute-html ]
[ insert-tuple ] [ insert-tuple ]
[ [
dup title>> <article> select-tuple dup title>> <article> select-tuple
[ amend-article ] [ add-article ] if* [ amend-article ] [ add-article ] if*
] ]
tri ; bi ;
: <edit-article-action> ( -- action ) : <edit-article-action> ( -- action )
<page-action> <page-action>