From 812277815fd1ac0605d00d1656fbe61d03bf54e3 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 22 Nov 2007 14:21:32 -0500 Subject: [PATCH 1/6] Improve multi-click detection logic --- extra/ui/gestures/gestures.factor | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) mode change 100644 => 100755 extra/ui/gestures/gestures.factor diff --git a/extra/ui/gestures/gestures.factor b/extra/ui/gestures/gestures.factor old mode 100644 new mode 100755 index 0e337c538a..756ddfbf00 --- a/extra/ui/gestures/gestures.factor +++ b/extra/ui/gestures/gestures.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs kernel math models namespaces sequences words strings system hashtables math.parser -math.vectors tuples classes ui.gadgets timers ; +math.vectors tuples classes ui.gadgets timers combinators ; IN: ui.gestures : set-gestures ( class hash -- ) "gestures" set-word-prop ; @@ -176,9 +176,23 @@ drag-timer construct-empty drag-timer set-global : hand-click-rel ( gadget -- loc ) hand-click-loc get-global swap screen-loc v- ; +: multi-click-timeout? ( -- ? ) + millis hand-last-time get - double-click-timeout get <= ; + +: multi-click-button? ( button -- button ? ) + dup hand-last-button get = ; + +: multi-click-position? ( -- ? ) + hand-loc get hand-click-loc get v- norm 10 <= ; + : multi-click? ( button -- ? ) - millis hand-last-time get - double-click-timeout get <= - swap hand-last-button get = and ; + { + { [ multi-click-timeout? not ] [ f ] } + { [ multi-click-button? not ] [ f ] } + { [ multi-click-position? not ] [ f ] } + { [ multi-click-position? not ] [ f ] } + { [ t ] [ t ] } + } cond nip ; : update-click# ( button -- ) global [ From 687d2aa6a4707afc807a926fc91bc73bfc95b0a3 Mon Sep 17 00:00:00 2001 From: Chris Double Date: Fri, 23 Nov 2007 14:32:02 +1300 Subject: [PATCH 2/6] Fix article manager bitrot --- extra/webapps/article-manager/furnace/article.furnace | 2 +- extra/webapps/article-manager/furnace/tag.furnace | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/webapps/article-manager/furnace/article.furnace b/extra/webapps/article-manager/furnace/article.furnace index 41929301a6..f0647aa442 100644 --- a/extra/webapps/article-manager/furnace/article.furnace +++ b/extra/webapps/article-manager/furnace/article.furnace @@ -1,4 +1,4 @@ -<% USING: kernel io http.server namespaces sequences math html.elements random furnace webapps.article-manager webapps.article-manager.database ; %> +<% USING: kernel io http.server namespaces sequences math html.elements random furnace webapps.article-manager webapps.article-manager.database html.elements ; %> <% f "navigation" render-template %>
diff --git a/extra/webapps/article-manager/furnace/tag.furnace b/extra/webapps/article-manager/furnace/tag.furnace index 493ce2e613..a778deb9be 100644 --- a/extra/webapps/article-manager/furnace/tag.furnace +++ b/extra/webapps/article-manager/furnace/tag.furnace @@ -1,4 +1,4 @@ -<% USING: kernel io http.server namespaces sequences math html furnace webapps.article-manager.database webapps.article-manager ; %> +<% USING: kernel io http.server namespaces sequences math html furnace webapps.article-manager.database webapps.article-manager html.elements ; %> <% f "navigation" render-template %> From cd844658959e2203c38d23a1da203da1a17d5426 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 22 Nov 2007 20:47:58 -0500 Subject: [PATCH 3/6] Documentation fix --- core/quotations/quotations-docs.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 core/quotations/quotations-docs.factor diff --git a/core/quotations/quotations-docs.factor b/core/quotations/quotations-docs.factor old mode 100644 new mode 100755 index f647bb2a66..3a32b63ae9 --- a/core/quotations/quotations-docs.factor +++ b/core/quotations/quotations-docs.factor @@ -22,7 +22,7 @@ $nl ABOUT: "quotations" HELP: callable -{ $class-description "The class whose instances can be passed to " { $link call } ". This includes quotations, " { $link f } " (which behaves like an empty quotation), and composed quotations built up with " { $link curry } "." } ; +{ $class-description "The class whose instances can be passed to " { $link call } ". This includes quotations and composed quotations built up with " { $link curry } " or " { $link compose } "." } ; HELP: quotation { $description "The class of quotations. See " { $link "syntax-quots" } " for syntax and " { $link "quotations" } " for general information." } ; From a61c0d5f7c1ec5c9c51a24ac4a83c900d9b37da8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 22 Nov 2007 20:48:24 -0500 Subject: [PATCH 4/6] Fix definition of macro predicate class --- extra/macros/macros.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 extra/macros/macros.factor diff --git a/extra/macros/macros.factor b/extra/macros/macros.factor old mode 100644 new mode 100755 index 9c06822463..1c23a1c85e --- a/extra/macros/macros.factor +++ b/extra/macros/macros.factor @@ -19,7 +19,7 @@ IN: macros : MACRO: (:) (MACRO:) ; parsing -PREDICATE: word macro +PREDICATE: compound macro "macro" word-prop >boolean ; M: macro definer drop \ MACRO: \ ; ; From 204069e01d8b0768a00850ef500c3dd2754ae39f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 22 Nov 2007 21:00:56 -0500 Subject: [PATCH 5/6] Improve editor gadget selection behavior --- extra/documents/documents.factor | 6 +++ extra/ui/gadgets/editors/editors.factor | 56 +++++++++++++++++-------- extra/ui/gestures/gestures.factor | 13 +++--- extra/ui/windows/windows.factor | 6 ++- 4 files changed, 55 insertions(+), 26 deletions(-) mode change 100644 => 100755 extra/documents/documents.factor diff --git a/extra/documents/documents.factor b/extra/documents/documents.factor old mode 100644 new mode 100755 index bc4dc412fc..01034e0e3f --- a/extra/documents/documents.factor +++ b/extra/documents/documents.factor @@ -167,6 +167,12 @@ M: char-elt prev-elt M: char-elt next-elt drop [ drop 1 +col ] (next-char) ; +TUPLE: one-char-elt ; + +M: one-char-elt prev-elt 2drop ; + +M: one-char-elt next-elt 2drop ; + : (word-elt) ( loc document quot -- loc ) pick >r >r >r first2 swap r> doc-line r> call diff --git a/extra/ui/gadgets/editors/editors.factor b/extra/ui/gadgets/editors/editors.factor index 65758ab54c..84cc01cdb6 100755 --- a/extra/ui/gadgets/editors/editors.factor +++ b/extra/ui/gadgets/editors/editors.factor @@ -4,7 +4,7 @@ USING: arrays documents ui.clipboards ui.commands ui.gadgets ui.gadgets.borders ui.gadgets.buttons ui.gadgets.labels ui.gadgets.scrollers ui.gadgets.theme ui.render ui.gestures io kernel math models namespaces opengl opengl.gl sequences strings -io.styles math.vectors sorting colors combinators ; +io.styles math.vectors sorting colors combinators assocs ; IN: ui.gadgets.editors TUPLE: editor @@ -94,8 +94,11 @@ M: editor ungraft* rot editor-line x>offset , ] { } make ; +: clicked-loc ( editor -- loc ) + [ hand-rel ] keep point>loc ; + : click-loc ( editor model -- ) - >r [ hand-rel ] keep point>loc r> set-model ; + >r clicked-loc r> set-model ; : focus-editor ( editor -- ) t over set-editor-focused? relayout-1 ; @@ -244,11 +247,37 @@ M: editor user-input* M: editor gadget-text* editor-string % ; -: start-selection ( editor -- ) - dup editor-caret click-loc ; - : extend-selection ( editor -- ) - dup request-focus start-selection ; + dup request-focus dup editor-caret click-loc ; + +: mouse-elt ( -- elelement ) + hand-click# get { + { 2 T{ one-word-elt } } + { 3 T{ one-line-elt } } + } at T{ one-char-elt } or ; + +: drag-direction? ( loc editor -- ? ) + editor-mark* <=> 0 < ; + +: drag-selection-caret ( loc editor element -- loc ) + >r [ drag-direction? ] 2keep + gadget-model + r> prev/next-elt ? ; + +: drag-selection-mark ( loc editor element -- loc ) + >r [ drag-direction? not ] 2keep + nip dup editor-mark* swap gadget-model + r> prev/next-elt ? ; + +: drag-caret&mark ( editor -- caret mark ) + dup clicked-loc swap mouse-elt + [ drag-selection-caret ] 3keep + drag-selection-mark ; + +: drag-selection ( editor -- ) + dup drag-caret&mark + pick editor-mark set-model + swap editor-caret set-model ; : editor-cut ( editor clipboard -- ) dupd gadget-copy remove-selection ; @@ -296,17 +325,10 @@ M: editor gadget-text* editor-string % ; dup T{ one-word-elt } select-elt ] unless gadget-selection ; -: (position-caret) ( editor -- ) - dup extend-selection - dup editor-mark click-loc ; - : position-caret ( editor -- ) - hand-click# get { - { 1 [ (position-caret) ] } - { 2 [ T{ one-word-elt } select-elt ] } - { 3 [ T{ one-line-elt } select-elt ] } - [ 2drop ] - } case ; + mouse-elt dup T{ one-char-elt } = + [ drop dup extend-selection dup editor-mark click-loc ] + [ select-elt ] if ; : insert-newline "\n" swap user-input ; @@ -408,7 +430,7 @@ editor "caret-motion" f { editor "selection" f { { T{ button-down f { S+ } } extend-selection } - { T{ drag } start-selection } + { T{ drag } drag-selection } { T{ gain-focus } focus-editor } { T{ lose-focus } unfocus-editor } { T{ delete-action } remove-selection } diff --git a/extra/ui/gestures/gestures.factor b/extra/ui/gestures/gestures.factor index 756ddfbf00..3d1e7baf7f 100755 --- a/extra/ui/gestures/gestures.factor +++ b/extra/ui/gestures/gestures.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs kernel math models namespaces sequences words strings system hashtables math.parser -math.vectors tuples classes ui.gadgets timers combinators ; +math.vectors tuples classes ui.gadgets timers combinators.lib ; IN: ui.gestures : set-gestures ( class hash -- ) "gestures" set-word-prop ; @@ -187,12 +187,11 @@ drag-timer construct-empty drag-timer set-global : multi-click? ( button -- ? ) { - { [ multi-click-timeout? not ] [ f ] } - { [ multi-click-button? not ] [ f ] } - { [ multi-click-position? not ] [ f ] } - { [ multi-click-position? not ] [ f ] } - { [ t ] [ t ] } - } cond nip ; + [ multi-click-timeout? ] + [ multi-click-button? ] + [ multi-click-position? ] + [ multi-click-position? ] + } && nip ; : update-click# ( button -- ) global [ diff --git a/extra/ui/windows/windows.factor b/extra/ui/windows/windows.factor index 3ce745970d..290e4ef311 100755 --- a/extra/ui/windows/windows.factor +++ b/extra/ui/windows/windows.factor @@ -397,8 +397,10 @@ M: windows-ui-backend (close-window) GetDoubleClickTime double-click-timeout set-global ; : cleanup-win32-ui ( -- ) - class-name-ptr get-global f UnregisterClass drop - class-name-ptr get-global [ free ] when* + class-name-ptr get-global [ + dup f UnregisterClass drop + free + ] when* f class-name-ptr set-global ; : setup-pixel-format ( hdc -- ) From 937446c53b96d5faacf84d056d7bac25a0af1d8c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 23 Nov 2007 16:24:57 -0500 Subject: [PATCH 6/6] Editors tweaks --- extra/tools/test/ui/ui.factor | 2 +- extra/ui/gadgets/editors/editors-tests.factor | 2 +- extra/ui/gadgets/gadgets-tests.factor | 2 +- extra/ui/gadgets/scrollers/scrollers-tests.factor | 2 +- extra/ui/tools/browser/browser-tests.factor | 2 +- extra/ui/tools/listener/listener-tests.factor | 2 +- extra/ui/tools/search/search-tests.factor | 2 +- extra/ui/tools/tools-tests.factor | 2 +- extra/ui/tools/walker/walker-tests.factor | 2 +- extra/ui/ui.factor | 10 +--------- 10 files changed, 10 insertions(+), 18 deletions(-) diff --git a/extra/tools/test/ui/ui.factor b/extra/tools/test/ui/ui.factor index 6dcf9da4b5..0376e7f4c7 100755 --- a/extra/tools/test/ui/ui.factor +++ b/extra/tools/test/ui/ui.factor @@ -1,5 +1,5 @@ USING: dlists ui.gadgets kernel ui namespaces io.streams.string -io ui.private ; +io ; IN: tools.test.ui ! We can't print to stdio here because that might be a pane diff --git a/extra/ui/gadgets/editors/editors-tests.factor b/extra/ui/gadgets/editors/editors-tests.factor index 6966e9639f..6be0423e95 100755 --- a/extra/ui/gadgets/editors/editors-tests.factor +++ b/extra/ui/gadgets/editors/editors-tests.factor @@ -1,5 +1,5 @@ USING: ui.gadgets.editors tools.test kernel io io.streams.plain -definitions namespaces ui.gadgets ui.private +definitions namespaces ui.gadgets ui.gadgets.grids prettyprint documents ui.gestures tools.test.inference tools.test.ui models ; diff --git a/extra/ui/gadgets/gadgets-tests.factor b/extra/ui/gadgets/gadgets-tests.factor index 6c651fa248..48bb3718cb 100755 --- a/extra/ui/gadgets/gadgets-tests.factor +++ b/extra/ui/gadgets/gadgets-tests.factor @@ -2,7 +2,7 @@ IN: temporary USING: ui.gadgets ui.gadgets.packs ui.gadgets.worlds tools.test namespaces models kernel tools.test.inference dlists math math.parser ui sequences hashtables assocs io arrays -prettyprint io.streams.string ui.private ; +prettyprint io.streams.string ; [ T{ rect f { 10 10 } { 20 20 } } ] [ diff --git a/extra/ui/gadgets/scrollers/scrollers-tests.factor b/extra/ui/gadgets/scrollers/scrollers-tests.factor index 7d0dd0158f..a53cf1fb0e 100755 --- a/extra/ui/gadgets/scrollers/scrollers-tests.factor +++ b/extra/ui/gadgets/scrollers/scrollers-tests.factor @@ -1,5 +1,5 @@ IN: temporary -USING: ui.gadgets ui.gadgets.scrollers ui.private +USING: ui.gadgets ui.gadgets.scrollers namespaces tools.test kernel models ui.gadgets.viewports ui.gadgets.labels ui.gadgets.grids ui.gadgets.frames ui.gadgets.sliders math math.vectors arrays sequences diff --git a/extra/ui/tools/browser/browser-tests.factor b/extra/ui/tools/browser/browser-tests.factor index 00c8e5489c..5a343919e7 100755 --- a/extra/ui/tools/browser/browser-tests.factor +++ b/extra/ui/tools/browser/browser-tests.factor @@ -1,6 +1,6 @@ IN: temporary USING: tools.test tools.test.ui ui.tools.browser -tools.test.inference ui.private ; +tools.test.inference ; { 0 1 } [ ] unit-test-effect [ ] [ [ ] with-grafted-gadget ] unit-test diff --git a/extra/ui/tools/listener/listener-tests.factor b/extra/ui/tools/listener/listener-tests.factor index 62bd350e71..4e59fd63ee 100755 --- a/extra/ui/tools/listener/listener-tests.factor +++ b/extra/ui/tools/listener/listener-tests.factor @@ -1,7 +1,7 @@ USING: continuations documents ui.tools.interactor ui.tools.listener hashtables kernel namespaces parser sequences timers tools.test ui.commands ui.gadgets ui.gadgets.editors -ui.gadgets.panes vocabs words tools.test.ui ui.private ; +ui.gadgets.panes vocabs words tools.test.ui ; IN: temporary timers [ init-timers ] unless diff --git a/extra/ui/tools/search/search-tests.factor b/extra/ui/tools/search/search-tests.factor index ed110e19d6..47ae786f59 100755 --- a/extra/ui/tools/search/search-tests.factor +++ b/extra/ui/tools/search/search-tests.factor @@ -1,6 +1,6 @@ USING: assocs ui.tools.search help.topics io.files io.styles kernel namespaces sequences source-files threads timers -tools.test ui.gadgets ui.gestures ui.private vocabs +tools.test ui.gadgets ui.gestures vocabs vocabs.loader words tools.test.ui debugger ; IN: temporary diff --git a/extra/ui/tools/tools-tests.factor b/extra/ui/tools/tools-tests.factor index eb30b198d6..919d1705af 100755 --- a/extra/ui/tools/tools-tests.factor +++ b/extra/ui/tools/tools-tests.factor @@ -2,7 +2,7 @@ USING: ui.tools ui.tools.interactor ui.tools.listener ui.tools.search ui.tools.workspace kernel models namespaces sequences timers tools.test ui.gadgets ui.gadgets.buttons ui.gadgets.labelled ui.gadgets.presentations -ui.gadgets.scrollers vocabs tools.test.ui ui ui.private ; +ui.gadgets.scrollers vocabs tools.test.ui ui ; IN: temporary [ diff --git a/extra/ui/tools/walker/walker-tests.factor b/extra/ui/tools/walker/walker-tests.factor index b37c38c6ed..eea6d78f22 100755 --- a/extra/ui/tools/walker/walker-tests.factor +++ b/extra/ui/tools/walker/walker-tests.factor @@ -1,6 +1,6 @@ USING: arrays continuations ui.tools.listener ui.tools.walker ui.tools.workspace inspector kernel namespaces sequences threads -listener tools.test ui ui.gadgets ui.gadgets.worlds ui.private +listener tools.test ui ui.gadgets ui.gadgets.worlds ui.gadgets.packs vectors ui.tools tools.interpreter tools.interpreter.debug tools.test.inference tools.test.ui ; IN: temporary diff --git a/extra/ui/ui.factor b/extra/ui/ui.factor index 0e1b82ab9b..0c3b3e7867 100755 --- a/extra/ui/ui.factor +++ b/extra/ui/ui.factor @@ -28,8 +28,6 @@ SYMBOL: windows : unregister-window ( handle -- ) windows global [ [ first = not ] curry* subset ] change-at ; - - : open-world-window ( world -- ) dup pref-dim over set-gadget-dim dup relayout graft ; @@ -90,8 +86,6 @@ SYMBOL: ui-hook \ layout-queue set-global V{ } clone windows set-global ; - - : ui-step ( -- ) [ do-timers