diff --git a/extra/easy-help/easy-help.factor b/extra/easy-help/easy-help.factor new file mode 100644 index 0000000000..692a029b97 --- /dev/null +++ b/extra/easy-help/easy-help.factor @@ -0,0 +1,48 @@ + +USING: kernel multiline parser sequences splitting help.markup ; + +IN: easy-help + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: Description: + + ".." parse-multiline-string + string-lines + 1 tail + [ dup " " head? [ 4 tail ] [ ] if ] map + [ dup "" = [ drop { $nl } ] [ ] if ] map + \ $description prefix + parsed + + ; parsing + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: Example: + + { $heading "Example" } parsed + + ".." parse-multiline-string + string-lines + [ dup " " head? [ 4 tail ] [ ] if ] map + [ "" = not ] filter + ! \ $example prefix + \ $code prefix + parsed + + ; parsing + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: Summary: + + ".." parse-multiline-string + string-lines + 1 tail + [ dup " " head? [ 4 tail ] [ ] if ] map + [ dup "" = [ drop { $nl } ] [ ] if ] map + { $heading "Summary" } prefix + parsed + + ; parsing diff --git a/extra/size-of/size-of.factor b/extra/size-of/size-of.factor index d40ea6f8ba..06a7067636 100644 --- a/extra/size-of/size-of.factor +++ b/extra/size-of/size-of.factor @@ -1,19 +1,39 @@ USING: io io.encodings.ascii io.files io.files.temp io.launcher - locals math.parser sequences sequences.deep ; + locals math.parser sequences sequences.deep + help.syntax + easy-help ; IN: size-of -! Use 'size-of' to find out the size in bytes of a C type. -! -! The 'headers' argument is a list of header files to use. You may -! pass 'f' to only use 'stdio.h'. -! -! Examples: -! -! f "int" size-of . -! -! { "X11/Xlib.h" } "XAnyEvent" size-of . +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +DEFER: size-of + +HELP: size-of + +Description: + + Use 'size-of' to find out the size in bytes of a C type. + + The 'headers' argument is a list of header files to use. You may + pass 'f' to only use 'stdio.h'. .. + +Example: + + ! Find the size of 'int' + + f "int" size-of . .. + +Example: + + ! Find the size of the 'XAnyEvent' struct from Xlib.h + + { "X11/Xlib.h" } "XAnyEvent" size-of . .. + +; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :: size-of ( HEADERS TYPE -- n ) diff --git a/unmaintained/plot/plot.factor b/extra/ui/gadgets/plot/plot.factor similarity index 84% rename from unmaintained/plot/plot.factor rename to extra/ui/gadgets/plot/plot.factor index 52cd2faed7..f502b7eb38 100644 --- a/unmaintained/plot/plot.factor +++ b/extra/ui/gadgets/plot/plot.factor @@ -1,12 +1,41 @@ USING: kernel quotations arrays sequences math math.ranges fry opengl opengl.gl ui.render ui.gadgets.cartesian processing.shapes - accessors ; + accessors + help.syntax + easy-help ; IN: ui.gadgets.plot ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +ARTICLE: "ui.gadgets.plot" "Plot Gadget" + +Summary: + + A simple gadget for ploting two dimentional functions. + + Use the arrow keys to move around. + + Use 'a' and 'z' keys to zoom in and out. .. + +Example: + + [ sin ] add-function gadget. .. + +Example: + + + [ sin ] red function boa add-function + [ cos ] blue function boa add-function + gadget. .. + +; + +ABOUT: "ui.gadgets.plot" + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + TUPLE: plot < cartesian functions points ; : init-plot ( plot -- plot ) @@ -29,11 +58,11 @@ TUPLE: function function color ; GENERIC: plot-function ( plot object -- plot ) M: callable plot-function ( plot quotation -- plot ) - >r dup plot-range r> '[ dup @ 2array ] map line-strip ; + [ dup plot-range ] dip '[ dup @ 2array ] map line-strip ; M: function plot-function ( plot function -- plot ) dup color>> dup [ >stroke-color ] [ drop ] if - >r dup plot-range r> function>> '[ dup @ 2array ] map line-strip ; + [ dup plot-range ] dip function>> '[ dup @ 2array ] map line-strip ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/extra/ui/gadgets/slate/slate.factor b/extra/ui/gadgets/slate/slate.factor index 0505586b53..af2dfcccc2 100644 --- a/extra/ui/gadgets/slate/slate.factor +++ b/extra/ui/gadgets/slate/slate.factor @@ -1,8 +1,35 @@ -USING: kernel namespaces opengl ui.render ui.gadgets accessors ; +USING: kernel namespaces opengl ui.render ui.gadgets accessors + help.syntax + easy-help ; IN: ui.gadgets.slate +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +ARTICLE: "slate" "Slate Gadget" + +Summary: + + A gadget with an 'action' slot which should be set to a callable. .. + +Example: + + ! Load the right vocabs for the examples + + USING: processing.shapes ui.gadgets.slate ; .. + +Example: + + [ { { 10 10 } { 50 30 } { 10 50 } } polygon fill-mode ] + gadget. .. + +; + +ABOUT: "slate" + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + TUPLE: slate < gadget action pdim graft ungraft ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/unmaintained/tiling/tiling.factor b/extra/ui/gadgets/tiling/tiling.factor similarity index 82% rename from unmaintained/tiling/tiling.factor rename to extra/ui/gadgets/tiling/tiling.factor index cf6ea7f48e..8a3c878161 100644 --- a/unmaintained/tiling/tiling.factor +++ b/extra/ui/gadgets/tiling/tiling.factor @@ -1,10 +1,42 @@ USING: kernel sequences math math.order - ui.gadgets ui.gadgets.tracks ui.gestures - bake.fry accessors ; + ui.gadgets ui.gadgets.tracks ui.gestures accessors fry + help.syntax + easy-help ; IN: ui.gadgets.tiling +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +ARTICLE: "ui.gadgets.tiling" "Tiling Layout Gadgets" + +Summary: + + A gadget which tiles it's children. + + A tiling gadget may contain any number of children, but only a + fixed number is displayed at one time. How many are displayed can + be controlled via Control-[ and Control-]. + + The focus may be switched with Alt-Left and Alt-Right. + + The focused child may be moved via Shift-Alt-Left and + Shift-Alt-Right. .. + +Example: + + + "resource:" directory-files + [ [ drop ] tiling-add ] + each + "Files" open-window .. + +; + +ABOUT: "ui.gadgets.tiling" + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + TUPLE: tiling < track gadgets tiles first focused ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/unmaintained/size-of/size-of.factor b/unmaintained/size-of/size-of.factor deleted file mode 100644 index 8157ba7dcf..0000000000 --- a/unmaintained/size-of/size-of.factor +++ /dev/null @@ -1,39 +0,0 @@ - -USING: kernel namespaces sequences - io io.files io.launcher io.encodings.ascii - bake builder.util - accessors vars - math.parser ; - -IN: size-of - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -VAR: headers - -: include-headers ( -- seq ) - headers> [ `{ "#include <" , ">" } to-string ] map ; - -: size-of-c-program ( type -- lines ) - `{ - "#include " - include-headers - { "main() { printf( \"%i\" , sizeof( " , " ) ) ; }" } - } - to-strings ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: c-file ( -- path ) "size-of.c" temp-file ; - -: exe ( -- path ) "size-of" temp-file ; - -! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -: size-of ( type -- n ) - size-of-c-program c-file ascii set-file-lines - - { "gcc" c-file "-o" exe } to-strings - [ "Error compiling generated C program" print ] run-or-bail - - exe ascii contents string>number ; \ No newline at end of file