From 9efc31186ec8987282a43ccdb36876805eeba1fb Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sun, 11 Jan 2009 10:54:49 -0600 Subject: [PATCH 01/16] L-system: Call 'set-color' in 'restore-turtle' --- extra/L-system/L-system.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extra/L-system/L-system.factor b/extra/L-system/L-system.factor index 5bc7ce1db6..0dbf94b1c6 100644 --- a/extra/L-system/L-system.factor +++ b/extra/L-system/L-system.factor @@ -207,7 +207,8 @@ DEFER: default-L-parser-values ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : save-turtle ( turtle -- turtle ) dup clone over saved>> push ; -: restore-turtle ( turtle -- turtle ) saved>> pop ; + +: restore-turtle ( turtle -- turtle ) saved>> pop dup color>> set-color ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! From 421c11d7a93367067d9a2b8040f523d39aabc953 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sun, 11 Jan 2009 11:02:48 -0600 Subject: [PATCH 02/16] Add L-system.models.tree-5 --- extra/L-system/models/tree-5/tree-5.factor | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 extra/L-system/models/tree-5/tree-5.factor diff --git a/extra/L-system/models/tree-5/tree-5.factor b/extra/L-system/models/tree-5/tree-5.factor new file mode 100644 index 0000000000..2647698351 --- /dev/null +++ b/extra/L-system/models/tree-5/tree-5.factor @@ -0,0 +1,37 @@ + +USING: accessors ui L-system ; + +IN: L-system.models.tree-5 + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: tree-5 ( -- ) + + L-parser-dialect >>commands + + [ 5 >>angle ] >>turtle-values + + "c(4)FFS" >>axiom + + { + { "S" "FFR>(60)R>(60)R>(60)R>(60)R>(60)R>(30)S" } + { "R" "[Ba]" } + { "a" "$tF[Cx]Fb" } + { "b" "$tF[Dy]Fa" } + { "B" "&B" } + { "C" "+C" } + { "D" "-D" } + + { "x" "a" } + { "y" "b" } + + { "F" "'(1.25)F'(.8)" } + } + >>rules ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: main ( -- ) [ L-system tree-5 "L-system" open-window ] with-ui ; + +MAIN: main + \ No newline at end of file From 09aeeadded9de0fe485115f73b744b4ce03f3b45 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sun, 11 Jan 2009 11:03:42 -0600 Subject: [PATCH 03/16] Initial checkin of 'git-tool' --- extra/git-tool/git-tool.factor | 440 +++++++++++++++++++++++++++++++++ 1 file changed, 440 insertions(+) create mode 100644 extra/git-tool/git-tool.factor diff --git a/extra/git-tool/git-tool.factor b/extra/git-tool/git-tool.factor new file mode 100644 index 0000000000..2b692f0963 --- /dev/null +++ b/extra/git-tool/git-tool.factor @@ -0,0 +1,440 @@ + +USING: accessors combinators.cleave combinators.short-circuit +concurrency.combinators destructors fry io io.directories +io.encodings io.encodings.utf8 io.launcher io.pathnames +io.pipes io.ports kernel locals math namespaces sequences +splitting strings ui ui.gadgets ui.gadgets.buttons +ui.gadgets.editors ui.gadgets.labels ui.gadgets.packs +ui.gadgets.tracks ; + +IN: git-status + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: head** ( seq obj -- seq/f ) dup number? [ head ] [ dupd find drop head ] if ; + +: tail** ( seq obj -- seq/f ) + dup number? + [ tail ] + [ dupd find drop [ tail ] [ drop f ] if* ] + if ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: ( DESC -- process stream stream ) + [ + [let | STDOUT-PIPE [ (pipe) |dispose ] + STDERR-PIPE [ (pipe) |dispose ] | + + [let | PROCESS [ DESC >process ] | + + PROCESS + [ STDOUT-PIPE out>> or ] change-stdout + [ STDERR-PIPE out>> or ] change-stderr + run-detached + + STDOUT-PIPE out>> dispose + STDERR-PIPE out>> dispose + + STDOUT-PIPE in>> utf8 + STDERR-PIPE in>> utf8 ] ] + ] + with-destructors ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: run-process/result ( desc -- process ) + + { + [ contents [ string-lines ] [ f ] if* ] + [ contents [ string-lines ] [ f ] if* ] + } + parallel-spread + [ >>stdout ] [ >>stderr ] bi* + dup wait-for-process >>status ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! process popup windows +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: popup-window ( title contents -- ) + dup string? [ ] [ "\n" join ] if + tuck set-editor-string swap open-window ; + +: popup-process-window ( process -- ) + [ stdout>> [ "output" swap popup-window ] when* ] + [ stderr>> [ "error" swap popup-window ] when* ] + [ + [ stdout>> ] [ stderr>> ] bi or not + [ "Process" "NO OUTPUT" popup-window ] + when + ] + tri ; + +: popup-if-error ( process -- ) + { [ status>> 0 = not ] [ popup-process-window t ] } 1&& drop ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: git-process ( REPO DESC -- process ) + REPO [ DESC run-process/result ] with-directory ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: git-status-section ( lines section -- lines/f ) + '[ _ = ] tail** + [ + [ "#\t" head? ] tail** + [ "#\t" head? not ] head** + [ 2 tail ] map + ] + [ f ] + if* ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: colon ( -- ch ) CHAR: : ; +: space ( -- ch ) 32 ; + +: git-status-line-file ( line -- file ) + { [ colon = ] 1 [ space = not ] } [ tail** ] each ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +TUPLE: + repository + to-commit-new + to-commit-modified + to-commit-deleted + modified + deleted + untracked ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: check-empty ( seq -- seq/f ) dup empty? [ drop f ] when ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: refresh-git-status ( GIT-STATUS -- GIT-STATUS ) + + [let | LINES [ GIT-STATUS repository>> "git-status" git-process stdout>> ] | + + GIT-STATUS + + LINES "# Changes to be committed:" git-status-section + [ "new file:" head? ] filter + [ git-status-line-file ] map + check-empty + >>to-commit-new + + LINES "# Changes to be committed:" git-status-section + [ "modified:" head? ] filter + [ git-status-line-file ] map + check-empty + >>to-commit-modified + + LINES "# Changes to be committed:" git-status-section + [ "deleted:" head? ] filter + [ git-status-line-file ] map + check-empty + >>to-commit-deleted + + LINES "# Changed but not updated:" git-status-section + [ "modified:" head? ] filter + [ git-status-line-file ] map + check-empty + >>modified + + LINES "# Changed but not updated:" git-status-section + [ "deleted:" head? ] filter + [ git-status-line-file ] map + check-empty + >>deleted + + LINES "# Untracked files:" git-status-section >>untracked ] ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: git-status ( REPO -- ) + + new REPO >>repository refresh-git-status ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: factor-git-status ( -- ) "resource:" git-status ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! git-tool +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: to-commit ( -- seq ) + { to-commit-new>> to-commit-modified>> to-commit-deleted>> } 1arr concat ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +:: refresh-status-pile ( STATUS PILE -- ) + + STATUS refresh-git-status drop + + PILE clear-gadget + + PILE + + ! Commit section + + [wlet | add-commit-path-button [| TEXT PATH | + + { 1 0 } + + TEXT