Merge branch 'master' of git://factorcode.org/git/factor
commit
a1b5ae3285
|
@ -5,7 +5,7 @@ db.errors.postgresql db.postgresql io.files.unique kernel namespaces
|
||||||
tools.test db.tester continuations ;
|
tools.test db.tester continuations ;
|
||||||
IN: db.errors.postgresql.tests
|
IN: db.errors.postgresql.tests
|
||||||
|
|
||||||
postgresql-test-db [
|
[
|
||||||
|
|
||||||
[ "drop table foo;" sql-command ] ignore-errors
|
[ "drop table foo;" sql-command ] ignore-errors
|
||||||
[ "drop table ship;" sql-command ] ignore-errors
|
[ "drop table ship;" sql-command ] ignore-errors
|
||||||
|
@ -29,4 +29,4 @@ postgresql-test-db [
|
||||||
sql-syntax-error?
|
sql-syntax-error?
|
||||||
] must-fail-with
|
] must-fail-with
|
||||||
|
|
||||||
] with-db
|
] test-postgresql
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
USING: definitions io.launcher kernel parser words sequences math
|
USING: definitions io.launcher kernel parser words sequences math
|
||||||
math.parser namespaces editors make system combinators.short-circuit
|
math.parser namespaces editors make system combinators.short-circuit
|
||||||
fry threads ;
|
fry threads vocabs.loader ;
|
||||||
IN: editors.emacs
|
IN: editors.emacs
|
||||||
|
|
||||||
SYMBOL: emacsclient-path
|
SYMBOL: emacsclient-path
|
||||||
|
@ -22,3 +22,5 @@ M: object default-emacsclient ( -- path ) "emacsclient" ;
|
||||||
where first2 emacsclient ;
|
where first2 emacsclient ;
|
||||||
|
|
||||||
[ emacsclient ] edit-hook set-global
|
[ emacsclient ] edit-hook set-global
|
||||||
|
|
||||||
|
os windows? [ "editors.emacs.windows" require ] when
|
||||||
|
|
|
@ -6,68 +6,80 @@
|
||||||
! http://cairographics.org/samples/text/
|
! http://cairographics.org/samples/text/
|
||||||
|
|
||||||
|
|
||||||
USING: cairo.ffi math math.constants byte-arrays kernel ui ui.render
|
USING: cairo.ffi math math.constants byte-arrays kernel ui
|
||||||
ui.gadgets opengl.gl accessors ;
|
ui.render combinators ui.gadgets opengl.gl accessors
|
||||||
|
namespaces opengl ;
|
||||||
|
|
||||||
IN: cairo-demo
|
IN: cairo-demo
|
||||||
|
|
||||||
|
|
||||||
: make-image-array ( -- array )
|
: make-image-array ( -- array )
|
||||||
384 256 4 * * <byte-array> ;
|
384 256 4 * * <byte-array> ;
|
||||||
|
|
||||||
: convert-array-to-surface ( array -- cairo_surface_t )
|
: convert-array-to-surface ( array -- cairo_surface_t )
|
||||||
CAIRO_FORMAT_ARGB32 384 256 over 4 *
|
CAIRO_FORMAT_ARGB32 384 256 over 4 *
|
||||||
cairo_image_surface_create_for_data ;
|
cairo_image_surface_create_for_data ;
|
||||||
|
|
||||||
|
|
||||||
TUPLE: cairo-demo-gadget < gadget image-array cairo-t ;
|
TUPLE: cairo-demo-gadget < gadget image-array cairo-t ;
|
||||||
|
|
||||||
M: cairo-demo-gadget draw-gadget* ( gadget -- )
|
M: cairo-demo-gadget draw-gadget* ( gadget -- )
|
||||||
0 0 glRasterPos2i
|
origin get [
|
||||||
1.0 -1.0 glPixelZoom
|
0 0 glRasterPos2i
|
||||||
[ 384 256 GL_RGBA GL_UNSIGNED_BYTE ] dip
|
1.0 -1.0 glPixelZoom
|
||||||
image-array>> glDrawPixels ;
|
[ 384 256 GL_RGBA GL_UNSIGNED_BYTE ] dip
|
||||||
|
image-array>> glDrawPixels
|
||||||
|
] with-translation ;
|
||||||
|
|
||||||
: create-surface ( gadget -- cairo_surface_t )
|
: create-surface ( gadget -- cairo_surface_t )
|
||||||
make-image-array [ swap (>>image-array) ] keep
|
make-image-array [ swap (>>image-array) ] keep
|
||||||
convert-array-to-surface ;
|
convert-array-to-surface ;
|
||||||
|
|
||||||
: init-cairo ( gadget -- cairo_t )
|
: init-cairo ( gadget -- cairo_t )
|
||||||
create-surface cairo_create ;
|
create-surface cairo_create ;
|
||||||
|
|
||||||
M: cairo-demo-gadget pref-dim* drop { 384 256 0 } ;
|
M: cairo-demo-gadget pref-dim* drop { 384 256 } ;
|
||||||
|
|
||||||
|
ERROR: no-cairo-t ;
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
|
||||||
: draw-hello-world ( gadget -- )
|
: draw-hello-world ( gadget -- )
|
||||||
cairo-t>>
|
cairo-t>> [ no-cairo-t ] unless*
|
||||||
dup "Sans" CAIRO_FONT_SLANT_NORMAL CAIRO_FONT_WEIGHT_BOLD cairo_select_font_face
|
{
|
||||||
dup 90.0 cairo_set_font_size
|
[
|
||||||
dup 10.0 135.0 cairo_move_to
|
"Sans" CAIRO_FONT_SLANT_NORMAL CAIRO_FONT_WEIGHT_BOLD
|
||||||
dup "Hello" cairo_show_text
|
cairo_select_font_face
|
||||||
dup 70.0 165.0 cairo_move_to
|
]
|
||||||
dup "World" cairo_text_path
|
[ 90.0 cairo_set_font_size ]
|
||||||
dup 0.5 0.5 1 cairo_set_source_rgb
|
[ 10.0 135.0 cairo_move_to ]
|
||||||
dup cairo_fill_preserve
|
[ "Hello" cairo_show_text ]
|
||||||
dup 0 0 0 cairo_set_source_rgb
|
[ 70.0 165.0 cairo_move_to ]
|
||||||
dup 2.56 cairo_set_line_width
|
[ "World" cairo_text_path ]
|
||||||
dup cairo_stroke
|
[ 0.5 0.5 1 cairo_set_source_rgb ]
|
||||||
dup 1 0.2 0.2 0.6 cairo_set_source_rgba
|
[ cairo_fill_preserve ]
|
||||||
dup 10.0 135.0 5.12 0 pi 2 * cairo_arc
|
[ 0 0 0 cairo_set_source_rgb ]
|
||||||
dup cairo_close_path
|
[ 2.56 cairo_set_line_width ]
|
||||||
dup 70.0 165.0 5.12 0 pi 2 * cairo_arc
|
[ cairo_stroke ]
|
||||||
cairo_fill ;
|
[ 1 0.2 0.2 0.6 cairo_set_source_rgba ]
|
||||||
|
[ 10.0 135.0 5.12 0 pi 2 * cairo_arc ]
|
||||||
|
[ cairo_close_path ]
|
||||||
|
[ 70.0 165.0 5.12 0 pi 2 * cairo_arc ]
|
||||||
|
[ cairo_fill ]
|
||||||
|
} cleave ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
M: cairo-demo-gadget graft* ( gadget -- )
|
M: cairo-demo-gadget graft* ( gadget -- )
|
||||||
dup dup init-cairo swap (>>cairo-t) draw-hello-world ;
|
dup dup init-cairo swap (>>cairo-t) draw-hello-world ;
|
||||||
|
|
||||||
M: cairo-demo-gadget ungraft* ( gadget -- )
|
M: cairo-demo-gadget ungraft* ( gadget -- )
|
||||||
cairo-t>> cairo_destroy ;
|
cairo-t>> cairo_destroy ;
|
||||||
|
|
||||||
: <cairo-demo-gadget> ( -- gadget )
|
: <cairo-demo-gadget> ( -- gadget )
|
||||||
cairo-demo-gadget new-gadget ;
|
cairo-demo-gadget new-gadget ;
|
||||||
|
|
||||||
: run ( -- )
|
: run ( -- )
|
||||||
[
|
[
|
||||||
<cairo-demo-gadget> "Hello World from Factor!" open-window
|
<cairo-demo-gadget> "Hello World from Factor!" open-window
|
||||||
] with-ui ;
|
] with-ui ;
|
||||||
|
|
||||||
MAIN: run
|
MAIN: run
|
||||||
|
|
Loading…
Reference in New Issue