some UI tweaking
parent
3c8b073be0
commit
9f0434f30f
|
@ -3,8 +3,8 @@
|
||||||
IN: errors
|
IN: errors
|
||||||
USING: kernel-internals ;
|
USING: kernel-internals ;
|
||||||
|
|
||||||
: catchstack ( -- cs ) 6 getenv ;
|
: catchstack ( -- cs ) 6 getenv ; inline
|
||||||
: set-catchstack ( cs -- ) 6 setenv ;
|
: set-catchstack ( cs -- ) 6 setenv ; inline
|
||||||
|
|
||||||
IN: kernel
|
IN: kernel
|
||||||
USING: namespaces sequences ;
|
USING: namespaces sequences ;
|
||||||
|
@ -19,10 +19,16 @@ TUPLE: continuation data c call name catch ;
|
||||||
: set-c-stack ( c-stack -- )
|
: set-c-stack ( c-stack -- )
|
||||||
[ "not supported" throw ] when ;
|
[ "not supported" throw ] when ;
|
||||||
|
|
||||||
|
: interpret ( quot -- )
|
||||||
|
#! Call the quotation in the interpreter. When compiled,
|
||||||
|
#! the quotation is ignored.
|
||||||
|
call ;
|
||||||
|
|
||||||
: continuation ( -- interp )
|
: continuation ( -- interp )
|
||||||
#! The continuation is reified from after the *caller* of
|
#! The continuation is reified from after the *caller* of
|
||||||
#! this word returns.
|
#! this word returns. It must be declared inline for this
|
||||||
datastack c-stack callstack dup pop* dup pop*
|
#! invariant to be preserved in compiled code too.
|
||||||
|
datastack c-stack callstack [ dup pop* dup pop* ] interpret
|
||||||
namestack catchstack <continuation> ; inline
|
namestack catchstack <continuation> ; inline
|
||||||
|
|
||||||
: >continuation< ( continuation -- data c call name catch )
|
: >continuation< ( continuation -- data c call name catch )
|
||||||
|
@ -33,9 +39,11 @@ TUPLE: continuation data c call name catch ;
|
||||||
continuation-catch ; inline
|
continuation-catch ; inline
|
||||||
|
|
||||||
: ifcc ( terminator balance -- | quot: continuation -- )
|
: ifcc ( terminator balance -- | quot: continuation -- )
|
||||||
|
#! Note that the branch at the end must not be optimized out
|
||||||
|
#! by the compiler.
|
||||||
[
|
[
|
||||||
continuation
|
continuation
|
||||||
dup continuation-data f over push f swap push t
|
dup continuation-data f over push f swap push dup
|
||||||
] call 2swap if ; inline
|
] call 2swap if ; inline
|
||||||
|
|
||||||
: callcc0 ( quot -- | quot: continuation -- )
|
: callcc0 ( quot -- | quot: continuation -- )
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2004, 2005 Slava Pestov.
|
! Copyright (C) 2004, 2005 Slava Pestov.
|
||||||
! See http://factor.sf.net/license.txt for BSD license.
|
! See http://factor.sf.net/license.txt for BSD license.
|
||||||
IN: sdl
|
IN: sdl
|
||||||
USING: kernel lists math namespaces sequences ;
|
USING: errors kernel lists math namespaces sequences ;
|
||||||
|
|
||||||
SYMBOL: surface
|
SYMBOL: surface
|
||||||
SYMBOL: width
|
SYMBOL: width
|
||||||
|
@ -12,9 +12,12 @@ SYMBOL: bpp
|
||||||
>r 3dup bpp set height set width set r>
|
>r 3dup bpp set height set width set r>
|
||||||
SDL_SetVideoMode surface set ;
|
SDL_SetVideoMode surface set ;
|
||||||
|
|
||||||
|
: sdl-error ( 0/-1 -- )
|
||||||
|
0 = [ SDL_GetError throw ] unless ;
|
||||||
|
|
||||||
: with-screen ( width height bpp flags quot -- )
|
: with-screen ( width height bpp flags quot -- )
|
||||||
#! Set up SDL graphics and call the quotation.
|
#! Set up SDL graphics and call the quotation.
|
||||||
SDL_INIT_EVERYTHING SDL_Init drop
|
SDL_INIT_EVERYTHING SDL_Init sdl-error
|
||||||
1 SDL_EnableUNICODE drop
|
1 SDL_EnableUNICODE drop
|
||||||
SDL_DEFAULT_REPEAT_DELAY SDL_DEFAULT_REPEAT_INTERVAL
|
SDL_DEFAULT_REPEAT_DELAY SDL_DEFAULT_REPEAT_INTERVAL
|
||||||
SDL_EnableKeyRepeat drop
|
SDL_EnableKeyRepeat drop
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
USING: compiler hashtables kernel math namespaces sequences test ;
|
USING: compiler hashtables kernel math namespaces sequences test ;
|
||||||
|
|
||||||
: store-hash ( hashtable n -- )
|
: store-hash ( hashtable n -- )
|
||||||
[ >float dup pick set-hash ] each drop ;
|
[ dup pick set-hash ] each drop ;
|
||||||
|
|
||||||
: lookup-hash ( hashtable n -- )
|
: lookup-hash ( hashtable n -- )
|
||||||
[ >float over hash drop ] each drop ;
|
[ over hash drop ] each drop ;
|
||||||
|
|
||||||
: hashtable-benchmark ( -- )
|
: hashtable-benchmark ( -- )
|
||||||
100 [
|
100 [
|
||||||
80000 1000 <hashtable> swap 2dup store-hash lookup-hash
|
drop
|
||||||
] times ; compiled
|
80000 100000 <hashtable> swap 2dup store-hash lookup-hash
|
||||||
|
] each ; compiled
|
||||||
|
|
||||||
[ ] [ hashtable-benchmark ] unit-test
|
[ ] [ hashtable-benchmark ] unit-test
|
||||||
|
|
|
@ -2,7 +2,7 @@ IN: temporary
|
||||||
USING: generic image kernel math namespaces parser test ;
|
USING: generic image kernel math namespaces parser test ;
|
||||||
|
|
||||||
[
|
[
|
||||||
"/library/bootstrap/boot-stage1.factor" run-resource
|
"/library/bootstrap/boot-stage1.factor" run-resource drop
|
||||||
] with-image drop
|
] with-image drop
|
||||||
|
|
||||||
[ fixnum ] [ 4 class ] unit-test
|
[ fixnum ] [ 4 class ] unit-test
|
||||||
|
|
|
@ -111,10 +111,8 @@ SYMBOL: failures
|
||||||
{
|
{
|
||||||
"io/buffer" "compiler/optimizer"
|
"io/buffer" "compiler/optimizer"
|
||||||
"compiler/simple"
|
"compiler/simple"
|
||||||
"compiler/stack" "compiler/if"
|
"compiler/stack" "compiler/ifte"
|
||||||
"compiler/generic" "compiler/bail-out"
|
"compiler/generic" "compiler/bail-out"
|
||||||
"compiler/linearizer" "compiler/intrinsics"
|
"compiler/linearizer" "compiler/intrinsics"
|
||||||
"compiler/identities"
|
"compiler/identities"
|
||||||
} run-tests ;
|
} run-tests ;
|
||||||
|
|
||||||
: all-tests tests compiler-tests benchmarks ;
|
|
||||||
|
|
|
@ -54,10 +54,10 @@ SYMBOL: meta-executing
|
||||||
|
|
||||||
: host-word ( word -- )
|
: host-word ( word -- )
|
||||||
[
|
[
|
||||||
\ call push-r continuation [
|
\ call push-r
|
||||||
continuation over continuation-data push continue
|
[ continuation swap continue-with ] cons cons push-r
|
||||||
] cons cons push-r meta-interp continue
|
meta-interp continue
|
||||||
] call set-meta-interp pop-d 2drop ;
|
] callcc1 set-meta-interp pop-d 2drop ;
|
||||||
|
|
||||||
: meta-call ( quot -- )
|
: meta-call ( quot -- )
|
||||||
#! Note we do tail call optimization here.
|
#! Note we do tail call optimization here.
|
||||||
|
|
|
@ -36,23 +36,17 @@ sequences io strings vectors words ;
|
||||||
#! Step into current word.
|
#! Step into current word.
|
||||||
next do report ;
|
next do report ;
|
||||||
|
|
||||||
: continue
|
: end-walk
|
||||||
#! Continue executing the single-stepped continuation in the
|
#! Continue executing the single-stepped continuation in the
|
||||||
#! primary interpreter.
|
#! primary interpreter.
|
||||||
meta-d get set-datastack
|
\ call push-r meta-cf get push-r meta-interp continue ;
|
||||||
meta-c get set-catchstack
|
|
||||||
meta-cf get
|
|
||||||
meta-r get
|
|
||||||
meta-n get set-namestack
|
|
||||||
set-callstack call ;
|
|
||||||
|
|
||||||
: walk-banner ( -- )
|
: walk-banner ( -- )
|
||||||
"&s &r show stepper stacks" print
|
"&s &r show stepper stacks" print
|
||||||
"&get ( var -- value ) get stepper variable value" print
|
"&get ( var -- value ) get stepper variable value" print
|
||||||
"step -- single step over" print
|
"step -- single step over" print
|
||||||
"into -- single step into" print
|
"into -- single step into" print
|
||||||
"continue -- continue execution" print
|
"bye -- continue execution" print
|
||||||
"bye -- exit single-stepper" print
|
|
||||||
report ;
|
report ;
|
||||||
|
|
||||||
: walk-listener walk-banner "walk " listener-prompt set listener ;
|
: walk-listener walk-banner "walk " listener-prompt set listener ;
|
||||||
|
@ -71,4 +65,5 @@ sequences io strings vectors words ;
|
||||||
callstack namestack [
|
callstack namestack [
|
||||||
init-walk
|
init-walk
|
||||||
walk-listener
|
walk-listener
|
||||||
|
end-walk
|
||||||
] with-scope ;
|
] with-scope ;
|
||||||
|
|
|
@ -35,7 +35,7 @@ SYMBOL: open-fonts
|
||||||
global [ open-fonts nest drop ] bind
|
global [ open-fonts nest drop ] bind
|
||||||
|
|
||||||
: ttf-init ( -- )
|
: ttf-init ( -- )
|
||||||
TTF_Init -1 = [ SDL_GetError throw ] when
|
TTF_Init sdl-error
|
||||||
global [
|
global [
|
||||||
open-fonts [ [ cdr expired? not ] hash-subset ] change
|
open-fonts [ [ cdr expired? not ] hash-subset ] change
|
||||||
] bind ;
|
] bind ;
|
||||||
|
|
|
@ -74,3 +74,8 @@ M: gadget children-on ( rect/point gadget -- list )
|
||||||
[ nip pick-up ] [ rot 2drop ] if
|
[ nip pick-up ] [ rot 2drop ] if
|
||||||
] with-scope
|
] with-scope
|
||||||
] [ 2drop f ] if ;
|
] [ 2drop f ] if ;
|
||||||
|
|
||||||
|
! Mind-map/outliner node protocol
|
||||||
|
GENERIC: node-gadget ( node -- gadget )
|
||||||
|
GENERIC: node-left ( node -- seq )
|
||||||
|
GENERIC: node-right ( node -- seq )
|
||||||
|
|
|
@ -30,14 +30,11 @@ C: display ( -- display )
|
||||||
<pile> 2dup swap set-display-pane
|
<pile> 2dup swap set-display-pane
|
||||||
<scroller> over add-center ;
|
<scroller> over add-center ;
|
||||||
|
|
||||||
: make-presentations ( seq -- seq )
|
|
||||||
[ [ unparse-short <label> ] keep <object-button> ] map ;
|
|
||||||
|
|
||||||
: present-stack ( seq title display -- )
|
: present-stack ( seq title display -- )
|
||||||
[ display-title set-label-text ] keep
|
[ display-title set-label-text ] keep
|
||||||
[
|
[
|
||||||
display-pane dup clear-gadget
|
display-pane dup clear-gadget
|
||||||
>r reverse-slice make-presentations r> add-gadgets
|
>r reverse-slice [ <object-button> ] map r> add-gadgets
|
||||||
] keep relayout ;
|
] keep relayout ;
|
||||||
|
|
||||||
: ui-listener-hook ( -- )
|
: ui-listener-hook ( -- )
|
||||||
|
|
|
@ -24,6 +24,7 @@ USING: kernel parser sequences io ;
|
||||||
"/library/ui/panes.factor"
|
"/library/ui/panes.factor"
|
||||||
"/library/ui/presentations.factor"
|
"/library/ui/presentations.factor"
|
||||||
"/library/ui/books.factor"
|
"/library/ui/books.factor"
|
||||||
|
"/library/ui/outliner.factor"
|
||||||
"/library/ui/mindmap.factor"
|
"/library/ui/mindmap.factor"
|
||||||
"/library/ui/listener.factor"
|
"/library/ui/listener.factor"
|
||||||
"/library/ui/ui.factor"
|
"/library/ui/ui.factor"
|
||||||
|
|
|
@ -39,3 +39,9 @@ gadgets-labels generic kernel lists math namespaces sequences ;
|
||||||
: <menu> ( assoc -- gadget )
|
: <menu> ( assoc -- gadget )
|
||||||
#! Given an association list mapping labels to quotations.
|
#! Given an association list mapping labels to quotations.
|
||||||
menu-items line-border dup menu-theme ;
|
menu-items line-border dup menu-theme ;
|
||||||
|
|
||||||
|
: <menu-button> ( gadget quot -- button )
|
||||||
|
[ show-menu ] append <roll-button>
|
||||||
|
dup [ button-clicked ] [ button-down 1 ] set-action
|
||||||
|
dup [ button-update ] [ button-up 1 ] set-action ;
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
! Copyright (C) 2005 Slava Pestov.
|
! Copyright (C) 2005 Slava Pestov.
|
||||||
! See http://factor.sf.net/license.txt for BSD license.
|
! See http://factor.sf.net/license.txt for BSD license.
|
||||||
IN: gadgets-mindmap
|
IN: gadgets-mindmap
|
||||||
USING: gadgets gadgets-buttons gadgets-labels gadgets-layouts
|
USING: arrays gadgets gadgets-buttons gadgets-labels
|
||||||
generic kernel math sequences styles ;
|
gadgets-layouts generic kernel math sequences styles ;
|
||||||
|
|
||||||
! Mind-map tree-view gadget, like http://freemind.sf.net.
|
! Mind-map tree-view gadget, like http://freemind.sf.net.
|
||||||
|
|
||||||
! Mind-map node protocol
|
|
||||||
GENERIC: node-gadget ( node -- gadget )
|
|
||||||
GENERIC: node-left ( node -- seq )
|
|
||||||
GENERIC: node-right ( node -- seq )
|
|
||||||
|
|
||||||
TUPLE: mindmap left node gadget right expanded? left? right? ;
|
TUPLE: mindmap left node gadget right expanded? left? right? ;
|
||||||
|
|
||||||
|
DEFER: <expand-button>
|
||||||
|
|
||||||
: add-mindmap-node ( mindmap -- )
|
: add-mindmap-node ( mindmap -- )
|
||||||
dup mindmap-node node-gadget swap
|
dup mindmap-node node-gadget <expand-button> 2array
|
||||||
|
<shelf> [ add-gadgets ] keep swap
|
||||||
2dup add-gadget set-mindmap-gadget ;
|
2dup add-gadget set-mindmap-gadget ;
|
||||||
|
|
||||||
: collapse-mindmap ( mindmap -- )
|
: collapse-mindmap ( mindmap -- )
|
||||||
|
@ -67,7 +65,7 @@ TUPLE: mindmap left node gadget right expanded? left? right? ;
|
||||||
dup add-mindmap-node
|
dup add-mindmap-node
|
||||||
expand-right ;
|
expand-right ;
|
||||||
|
|
||||||
: toggle-expanded ( mindmap -- )
|
: toggle-mindmap ( mindmap -- )
|
||||||
dup mindmap-expanded?
|
dup mindmap-expanded?
|
||||||
[ collapse-mindmap ] [ expand-mindmap ] if ;
|
[ collapse-mindmap ] [ expand-mindmap ] if ;
|
||||||
|
|
||||||
|
@ -100,4 +98,4 @@ M: mindmap draw-gadget* ( mindmap -- )
|
||||||
: find-mindmap [ mindmap? ] find-parent ;
|
: find-mindmap [ mindmap? ] find-parent ;
|
||||||
|
|
||||||
: <expand-button> ( label -- gadget )
|
: <expand-button> ( label -- gadget )
|
||||||
<label> [ find-mindmap toggle-expanded ] <roll-button> ;
|
"+" <label> [ find-mindmap toggle-mindmap ] <roll-button> ;
|
||||||
|
|
|
@ -26,16 +26,17 @@ SYMBOL: commands
|
||||||
: command-menu ( presented -- menu )
|
: command-menu ( presented -- menu )
|
||||||
dup applicable
|
dup applicable
|
||||||
[ [ third command-quot ] keep second swons ] map-with
|
[ [ third command-quot ] keep second swons ] map-with
|
||||||
<menu> show-menu ;
|
<menu> ;
|
||||||
|
|
||||||
: <object-button> ( gadget object -- button )
|
: <command-button> ( gadget object -- button )
|
||||||
[ \ drop , literalize , \ command-menu , ] [ ] make
|
[ \ drop , literalize , \ command-menu , ] [ ] make
|
||||||
<roll-button>
|
<menu-button> ;
|
||||||
dup [ button-clicked ] [ button-down 1 ] set-action
|
|
||||||
dup [ button-update ] [ button-up 1 ] set-action ;
|
: <object-button> ( object -- button )
|
||||||
|
[ unparse-short <label> ] keep <command-button> ;
|
||||||
|
|
||||||
: init-commands ( gadget -- gadget )
|
: init-commands ( gadget -- gadget )
|
||||||
dup presented paint-prop [ <object-button> ] when* ;
|
dup presented paint-prop [ <command-button> ] when* ;
|
||||||
|
|
||||||
: <styled-label> ( style text -- label )
|
: <styled-label> ( style text -- label )
|
||||||
<label> swap dup [ alist>hash ] when over set-gadget-paint ;
|
<label> swap dup [ alist>hash ] when over set-gadget-paint ;
|
||||||
|
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
static void *null_dll;
|
static void *null_dll;
|
||||||
|
|
||||||
|
void ffi_test(void *font, char *text, int fg)
|
||||||
|
{
|
||||||
|
fprintf(stderr,"%d %d %d",font,text,fg);
|
||||||
|
}
|
||||||
|
|
||||||
void init_ffi(void)
|
void init_ffi(void)
|
||||||
{
|
{
|
||||||
null_dll = dlopen(NULL,RTLD_LAZY);
|
null_dll = dlopen(NULL,RTLD_LAZY);
|
||||||
|
|
Loading…
Reference in New Issue