From b28ea890b7245eafa2c594f326dec0d78d249482 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 24 Jan 2006 02:03:22 +0000 Subject: [PATCH] AJAX outliners --- TODO.FACTOR.txt | 232 ++++----------------- contrib/cont-responder/js/liveUpdater.js | 1 - contrib/cont-responder/live-updater.factor | 166 --------------- contrib/cont-responder/load.factor | 1 - contrib/httpd/browser-responder.factor | 8 +- contrib/httpd/cont-responder.factor | 3 +- contrib/httpd/html-tags.factor | 8 +- contrib/httpd/html.factor | 11 +- contrib/httpd/live-updater.factor | 61 ++---- doc/handbook/objects.facts | 2 +- library/help/markup.factor | 2 +- library/inference/known-words.factor | 4 + library/math/random.facts | 2 +- library/syntax/parse-syntax.factor | 2 +- library/tools/debugger.factor | 6 +- library/tools/inspector.factor | 6 + library/ui/commands.factor | 1 + library/ui/layouts.factor | 18 +- 18 files changed, 98 insertions(+), 436 deletions(-) delete mode 100644 contrib/cont-responder/js/liveUpdater.js delete mode 100644 contrib/cont-responder/live-updater.factor diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index b691464400..53e584fe5d 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -1,197 +1,35 @@ -- need line and paragraph spacing -- update HTML stream -- help cross-referencing -- UI browser pane needs 'back' button -- if cell is rebound, and we allocate c objects, bang -- runtime primitives like fopen: check for null input -- -with combinators are awkward -- amd64 to do: - - alien calls - - port ffi to win64 -- intrinsic char-slot set-char-slot for x86 -- fix up the min thumb size hack -- the invalid recursion form case needs to be fixed, for inlines too -- code walker & exceptions -- signal handler should not lose stack pointers -- FIELD: char key_vector[32]; -- FIELD: union { char b[20]; short s[10]; long l[5]; } data; -- MEMBER: long pad[24]; -- C structs, enums, unions: use new-style string mode parsing -- ffi unicode strings: null char security hole -- utf16 string boxing -- [ [ dup call ] dup call ] infer hangs -- slice: if sequence or seq start is changed, abstraction violation -- out of memory error when printing global namespace -- delegating generic words with a non-standard picker -- code gc -- stream server can hang because of exception handler limitations -- better i/o scheduler -- if two tasks write to a unix stream, the buffer can overflow -- font problem: http://iarc1.ece.utexas.edu/~erg/font-bug.JPG -- implement 3.3 floor 4.7 ceiling 4.5 truncate -- make 3.4 bits>double cause an error like 3.4 bits>float does -- float>bits bits>double etc fail in gcc 4.0.3 with -fschedule-insns -- C{ 0/0. 0/0. } C{ 0/0. 0/0. } = . -> f when -ffast-math is not used on x86 -- can't type C{ nan.0 nan.0 } or C{ nan nan } at the repl -- "contrib/math/prime.factor" run-file is too slow (~100 seconds) -- test-2integer>x-throws causes an infinite loop in bignum_multiply_unsigned() -- add some tests below to the unit tests - -ALL TESTS BELOW FAIL ON x86 linux 32bit -- 10 [ tan tan tan ] compile-1 ! runs out of memory - -- float not commutative bug (?) - : a 237241607 1516.925984289192 3036109462846 913470293/554864 - max min * 994.5872660892654 306803761/112249 -216866846 + - - max 6073750751093 364.7737275664338 3629914314951 + max max - 9630706289317 6275800738949 179761544 + + + 88005566/945 - 2358.939297157175 1365.124822588899 max max - 61906796 - 388692629/82301 342893943/210229 * min * 381.5493627025407 - 10548296/49539 996.7264162840083 * + - ; - -- min/max inline bug - : math-dummy - 1507049 1812.446640674088 2682190027553 7662348747253 max - max max 175956841558 9163603105116 100680937 max min min - 67305963/106562 78534496 63.25709285387058 max + min - 116934358/596083 124000630 27821944/48045 - + max - 357331489/880112 1760057/587415 7297976710833 - * max - -113698191 1404.610575779506 51191522 * * - - 1977.861343144055 -50892488 947579163/437404 * min * ; - -- compiled vs interpreted output differs! - : math-dummy 692476975489 >fixnum ; - : math-dummy -248461184 float>bits ; FAILS - ----RATIO--- -Compiles VERY SLOWLY -: math-dummy - 292025505/568715131 587196182/778552531 cos neg - 133163510/474434699 >bignum 57689734/429093367 tan cos - 585585439/262485063 neg ; - -Compile fails -: math-dummy 41614997/15884070 392881821/294492125 + sin sin sin tan sin 830428019/886540270 * neg ; - ----FLOAT--- -Compile fails: -: math-dummy - 0.5589927916549555 tan 2.261878253481278 + tan sin ; - -SLOW compile -: math-dummy - 1.550108042325469 3.888423982091886 - tan tan ; - -Compile fails: -: math-dummy - 2.522378181825594 tan 7.825249292551574 - cos - 0.2875868408644093 + sin >bignum cos >float sin ; - - -x86 problems below -Compile failes: -[ 0.0 cos coth cot neg ] -[ C{ -740108126/802208755 246440723/614809409 } coth sin cot -22338167 - ] - - - - -[ 101637844 ] -Compiling G:374994 -101637844 -32579884 - -[ -235345183 ] -Compiling G:359656 --235345183 33090273 - -[ 0 bits>float ] -Compiling G:455019 -4.203895392974451e-45 110.8125 - -[ -1 float>bits ] -Compiling G:455338 -1099286058 4 - -[ -15766735 double>bits ] -Compiling G:455023 -4702233936300867587 4777205847159578624 - -[ -23841331 bits>double ] -Compiling G:455027 -5.127236739868035e-270 5.097526873523571e-270 - -[ -251924354 1+ ] -Compiling G:455128 --251924353 16511103 - -[ -258114108 1- ] -Compiling G:455920 --258114109 10321347 - -[ 259957324 bitnot ] -Compiling G:455227 --259957325 8478131 - -[ -268435456 quadrant ] -Compiling G:455335 -1 0 - -[ 620858855246776348355165240843829248 >fixnum ] -Compiling G:457023 --268435456 0 - -[ 268435455 neg ] -Compiling G:457031 --268435455 1 - -[ -60976708 next-power-of-2 ] -Compiling G:457308 -1 8388608 - -[ -132458581 real ] -Compiling G:459251 --132458581 1759147 - -[ -200388566 floor ] -Compiling G:461226 --200388566 938026 - - -2 ARGUEMENT INTEGER WORDS -[ 252475730 -1 * ] -Compiling G:452424 --252475730 15959726 - -[ -268435456 209630756 min ] -Compiling G:452492 --268435456 0 - -[ -258355397 -181752298 max ] -Compiling G:452699 --181752298 19574294 - -[ -14282409 -22156592 + ] -Compiling G:452838 --36439001 30669863 - -[ -48101335 0 - ] -Compiling G:454874 --48101335 19007529 - -[ -48174218 0 bitxor ] -Compiling G:561725 --48174218 18934646 - -[ -57534898 -1 bitand ] -Compiling G:562430 --57534898 9573966 - -[ 75915195 -268435456 bitor ] -Compiling G:563342 --192520261 8806331 - -[ -264174045 66395852 align ] -Compiling G:564824 --201187292 139300 - - +- need line and paragraph spacing +- update HTML stream +- help cross-referencing +- UI browser pane needs 'back' button +- if cell is rebound, and we allocate c objects, bang +- runtime primitives like fopen: check for null input +- -with combinators are awkward +- amd64 to do: + - alien calls + - port ffi to win64 +- intrinsic char-slot set-char-slot for x86 +- fix up the min thumb size hack +- the invalid recursion form case needs to be fixed, for inlines too +- code walker & exceptions +- signal handler should not lose stack pointers +- FIELD: char key_vector[32]; +- FIELD: union { char b[20]; short s[10]; long l[5]; } data; +- MEMBER: long pad[24]; +- C structs, enums, unions: use new-style string mode parsing +- ffi unicode strings: null char security hole +- utf16 string boxing +- [ [ dup call ] dup call ] infer hangs +- slice: if sequence or seq start is changed, abstraction violation +- out of memory error when printing global namespace +- delegating generic words with a non-standard picker +- code gc +- stream server can hang because of exception handler limitations +- better i/o scheduler +- if two tasks write to a unix stream, the buffer can overflow +- font problem: http://iarc1.ece.utexas.edu/~erg/font-bug.JPG +- implement 3.3 floor 4.7 ceiling 4.5 truncate +- make 3.4 bits>double an error +- float>bits bits>double etc fail in gcc 4.0.3 with -fschedule-insns +- C{ 0/0. 0/0. } C{ 0/0. 0/0. } = . -> f when -ffast-math is not used on x86 +- can't type C{ nan.0 nan.0 } or C{ nan nan } at the repl diff --git a/contrib/cont-responder/js/liveUpdater.js b/contrib/cont-responder/js/liveUpdater.js deleted file mode 100644 index 14c0ac8628..0000000000 --- a/contrib/cont-responder/js/liveUpdater.js +++ /dev/null @@ -1 +0,0 @@ -/* liveUpdater.js originally written by Avi Bryant, author of Seaside (http://www.beta4.com/seaside2) Modifed by Chris Double to add LiveUpdaterPost and use ' instead of " for the id. */ function liveUpdaterUri(uri) { return liveUpdater(function() { return uri; }); } function liveUpdater(uriFunc) { var request = false; var regex = /<(\w+).*?id='(\w+)'.*?>((.|\n)*)<\/\1>/; if (window.XMLHttpRequest) { request = new XMLHttpRequest(); } function update() { if(request && request.readyState < 4) request.abort(); if(!window.XMLHttpRequest) request = new ActiveXObject("Microsoft.XMLHTTP"); request.onreadystatechange = processRequestChange; request.open("GET", uriFunc()); request.send(null); return false; } function processRequestChange() { if(request.readyState == 4) { var results = regex.exec(request.responseText); if(results) document.getElementById(results[2]).innerHTML = results[3]; } } return update; } function liveUpdaterPost(uriFunc) { var request = false; var regex = /<(\w+).*?id='(\w+)'.*?>((.|\n)*)<\/\1>/; if (window.XMLHttpRequest) { request = new XMLHttpRequest(); } function update(data) { if(request && request.readyState < 4) request.abort(); if(!window.XMLHttpRequest) request = new ActiveXObject("Microsoft.XMLHTTP"); request.onreadystatechange = processRequestChange; request.open("POST", uriFunc()); request.send(data); return false; } function processRequestChange() { if(request.readyState == 4) { var results = regex.exec(request.responseText); if(results) document.getElementById(results[2]).innerHTML = results[3]; } } return update; } function liveSearch(id, uri) { var updater = liveUpdaterPost((function() { return uri; })); var last = ""; var timeout = false; function update() { if (last != document.getElementById(id).value) updater("s=" + escape(document.getElementById(id).value)); } function start() { if (timeout) window.clearTimeout(timeout); timeout = window.setTimeout(update, 300); } if (navigator.userAgent.indexOf("Safari") > 0) document.getElementById(id).addEventListener("keydown",start,false); else if (navigator.product == "Gecko") document.getElementById(id).addEventListener("keypress",start,false); else document.getElementById(id).attachEvent("onkeydown",start); } \ No newline at end of file diff --git a/contrib/cont-responder/live-updater.factor b/contrib/cont-responder/live-updater.factor deleted file mode 100644 index 7819c3e4bc..0000000000 --- a/contrib/cont-responder/live-updater.factor +++ /dev/null @@ -1,166 +0,0 @@ -! Copyright (C) 2004 Chris Double. -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, -! this list of conditions and the following disclaimer. -! -! 2. Redistributions in binary form must reproduce the above copyright notice, -! this list of conditions and the following disclaimer in the documentation -! and/or other materials provided with the distribution. -! -! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -! -! cont-responder code for display forms and anchors that use XMLHttpRequest -! and the 'liveUpdater.js' code. -IN: live-updater -USE: kernel -USE: io -USE: strings -USE: html -USE: cont-responder -USE: namespaces -USE: lists - -: get-live-updater-js* ( stream -- string ) - #! Read all lines from the stream, creating a string of the result. - dup stream-readln dup [ % "\n" % get-live-updater-js* ] [ drop stream-close ] if ; - -: get-live-updater-js ( filename -- string ) - #! Return the liveUpdater javascript code as a string. - [ get-live-updater-js* ] "" make ; - -: live-updater-url ( -- url ) - #! Generate an URL to the liveUpdater.js code. - t [ - [ - "js/liveUpdater.js" get-live-updater-js write - ] show - ] register-continuation id>url ; - -: include-live-updater-js ( -- ) - #! Write out the HTML script to include the live updater - #! javascript code. - ; - -: write-live-anchor-tag ( text -- id ) - #! Write out the HTML for the clickable anchor. This - #! will have no actionable HREF assigned to it. Instead - #! an onclick is set via DHTML later to make it run a - #! quotation on the server. The randomly generated id - #! for the anchor is returned. - - swap write - ; - -: register-live-anchor-quot ( div-id div-quot -- kid ) - #! Register the 'quot' with the cont-responder so - #! that when it is run it will produce an HTML - #! fragment which is the output generated by calling - #! 'quot'. That HTML fragment will be wrapped in a - #! 'div' with the given id. - [ - "div-quot" set - "div-id" set - ] make-hash [ - [ - t "disable-initial-redirect?" set - [ -
"div-quot" get call
- ] show - ] bind - ] cons t swap register-continuation ; - -: write-live-anchor-script ( div-id div-quot anchor-id -- ) - #! Write the javascript that will attach the onclick - #! event handler to the anchor with the 'anchor-id'. The - #! onclick, when clicked, will retrieve from the server - #! the HTML generated by the output of 'div-quot' wrapped - #! in a 'div' tag with the 'div-id'. That 'div' tag will - #! replace whatever HTML DOM object currently has that same - #! id. - ; - -: live-anchor ( id quot text -- ) - #! Write out the HTML for an anchor that when clicked - #! will replace the DOM object on the current page with - #! the given 'id' with the result of the output of calling - #! 'quot'. - write-live-anchor-tag - write-live-anchor-script ; - -: write-live-search-tag ( -- id ) - #! Write out the HTML for the input box. This - #! will have no actionable keydown assigned to it. Instead - #! a keydown is set via DHTML later to make it run a - #! quotation on the server. The randomly generated id - #! for the input box is returned. - ; - -: register-live-search-quot ( div-id div-quot -- kid ) - #! Register the 'quot' with the cont-responder so - #! that when it is run it will produce an HTML - #! fragment which is the output generated by calling - #! 'quot'. That HTML fragment will be wrapped in a - #! 'div' with the given id. The 'quot' is called with - #! a string on top of the stack. This is the input string - #! entered in the live search input box. - [ - "div-quot" set - "div-id" set - ] make-hash [ - [ - t "disable-initial-redirect?" set - #! Retrieve the search query value from the POST parameters. - [ "s" get ] bind - [ - #! Don't need the URL as the 'show' won't be resumed. - drop -
"div-quot" get call
- ] show - ] bind - ] cons t swap register-continuation ; - -: write-live-search-script ( div-id div-quot id-id -- ) - #! Write the javascript that will attach the keydown handler - #! to the input box with the give id. Whenever a keydown is - #! received the 'div-quot' will be executed on the server, - #! with the input boxes text on top of the stack. The - #! output of the quot will be an HTML fragment, it is wrapped in - #! a 'div' with the id 'div-id' and will - #! replace whatever HTML DOM object currently has that same - #! id. - ; - -: live-search ( div-id div-quot -- ) - #! Write an input text field. The keydown of this - #! text field will run 'div-quot' on the server with - #! the value of the text field on the stack. The output - #! of div-quot will replace the HTML DOM object with the - #! given id. - write-live-search-tag - write-live-search-script ; diff --git a/contrib/cont-responder/load.factor b/contrib/cont-responder/load.factor index 4874692675..cac30af70c 100644 --- a/contrib/cont-responder/load.factor +++ b/contrib/cont-responder/load.factor @@ -9,7 +9,6 @@ USING: words kernel parser sequences io compiler ; "cont-numbers-game" "todo" "todo-example" - "live-updater" "eval-responder" "live-updater-responder" "cont-testing" diff --git a/contrib/httpd/browser-responder.factor b/contrib/httpd/browser-responder.factor index 36fd08c2c0..1b92beab72 100644 --- a/contrib/httpd/browser-responder.factor +++ b/contrib/httpd/browser-responder.factor @@ -42,14 +42,14 @@ memory namespaces prettyprint sequences words xml ; : vocab-list ( vocab -- ) #! Write out the HTML for the list of vocabularies. Make the currently #! selected vocab be 'vocab'. - vocabs [ over swap option ] each drop ; : word-list ( vocab word -- ) #! Write out the HTML for the list of words in a vocabulary. Make the 'word' item #! the currently selected option. - swap words natural-sort [ word-name over swap option ] each drop ; @@ -67,8 +67,8 @@ memory namespaces prettyprint sequences words xml ; "Documentation" write - over vocab-list - 2dup word-list + over vocab-list + 2dup word-list word-source ; diff --git a/contrib/httpd/cont-responder.factor b/contrib/httpd/cont-responder.factor index 0106b3d0cd..65abd165d6 100644 --- a/contrib/httpd/cont-responder.factor +++ b/contrib/httpd/cont-responder.factor @@ -40,8 +40,7 @@ SYMBOL: post-refresh-get? : get-random-id ( -- id ) #! Generate a random id to use for continuation URL's - [ 32 [ 9 random-int CHAR: 0 + , ] times ] "" make - string>number 36 >base ; + [ "ID" % 32 [ 9 random-int CHAR: 0 + , ] times ] "" make ; SYMBOL: table diff --git a/contrib/httpd/html-tags.factor b/contrib/httpd/html-tags.factor index 60dd90c905..4285e8282c 100644 --- a/contrib/httpd/html-tags.factor +++ b/contrib/httpd/html-tags.factor @@ -114,6 +114,8 @@ SYMBOL: html : do-foo> write-attributes n> drop ">" write-html ; +: do-foo/> write-attributes n> drop "/>" write-html ; + : def-for-html-word-foo> ( name -- ) #! Return the name and code for the foo> patterned #! word. @@ -128,17 +130,19 @@ SYMBOL: html : [ "<" % % "/>" % ] "" make ; +: do- write-html ; + : def-for-html-word- ( name -- ) #! Return the name and code for the patterned #! word. - dup swap [ do- ] cons html-word drop ; + dup swap [ do- ] cons html-word drop ; : foo/> "/>" append ; : def-for-html-word-foo/> ( name -- ) #! Return the name and code for the foo/> patterned #! word. - foo/> [ do-foo> ] html-word define-close ; + foo/> [ do-foo/> ] html-word define-close ; : define-closed-html-word ( name -- ) #! Given an HTML tag name, define the words for diff --git a/contrib/httpd/html.factor b/contrib/httpd/html.factor index 9a279c13b8..8d30134926 100644 --- a/contrib/httpd/html.factor +++ b/contrib/httpd/html.factor @@ -153,8 +153,8 @@ M: html-stream stream-format ( str style stream -- ) -
- "replaceme" swap [ - [ with-html-stream ] show-final + get-random-id dup >r swap [ + with-html-stream ] curry "+" live-anchor @@ -163,7 +163,7 @@ M: html-stream stream-format ( str style stream -- )
+
=id td>
; @@ -194,7 +194,12 @@ M: html-stream stream-terpri [
] with-stream* ; "A:hover, A:hover { text-decoration: none; color: black; }" print ; +: xhtml-preamble + "" print + "" print ; + : html-document ( title quot -- ) + xhtml-preamble swap chars>entities dup diff --git a/contrib/httpd/live-updater.factor b/contrib/httpd/live-updater.factor index eae2a24bdb..768ed969f1 100644 --- a/contrib/httpd/live-updater.factor +++ b/contrib/httpd/live-updater.factor @@ -1,50 +1,21 @@ ! Copyright (C) 2004 Chris Double. -! -! Redistribution and use in source and binary forms, with or without -! modification, are permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, -! this list of conditions and the following disclaimer. -! -! 2. Redistributions in binary form must reproduce the above copyright notice, -! this list of conditions and the following disclaimer in the documentation -! and/or other materials provided with the distribution. -! -! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +! See http://factorcode.org/license.txt for BSD license. ! -! cont-responder code for display forms and anchors that use XMLHttpRequest -! and the 'liveUpdater.js' code. +! cont-responder code for display forms and anchors that use +! XMLHttpRequest and the 'liveUpdater.js' code. IN: live-updater -USING: kernel io strings html cont-responder namespaces lists ; - -: get-live-updater-js* ( stream -- string ) - #! Read all lines from the stream, creating a string of the result. - dup stream-readln dup [ % "\n" % get-live-updater-js* ] [ drop stream-close ] if ; +USING: cont-responder html io kernel lists namespaces strings +xml ; : get-live-updater-js ( filename -- string ) #! Return the liveUpdater javascript code as a string. "/contrib/httpd/liveUpdater.js" contents ; -: live-updater-url ( -- url ) - #! Generate an URL to the liveUpdater.js code. - t [ - [ get-live-updater-js write ] show - ] register-continuation id>url ; - : include-live-updater-js ( -- ) #! Write out the HTML script to include the live updater #! javascript code. - ; : write-live-anchor-tag ( text -- id ) @@ -53,9 +24,7 @@ USING: kernel io strings html cont-responder namespaces lists ; #! an onclick is set via DHTML later to make it run a #! quotation on the server. The randomly generated id #! for the anchor is returned. - - swap write - ; + swap write ; : register-live-anchor-quot ( div-id div-quot -- kid ) #! Register the 'quot' with the cont-responder so @@ -68,7 +37,7 @@ USING: kernel io strings html cont-responder namespaces lists ; "div-id" set ] make-hash [ [ - t "disable-initial-redirect?" set + "disable-initial-redirect?" on [
"div-quot" get call
] show @@ -84,11 +53,11 @@ USING: kernel io strings html cont-responder namespaces lists ; #! replace whatever HTML DOM object currently has that same #! id. ; : live-anchor ( id quot text -- ) @@ -120,7 +89,7 @@ USING: kernel io strings html cont-responder namespaces lists ; "div-id" set ] make-hash [ [ - t "disable-initial-redirect?" set + "disable-initial-redirect?" on #! Retrieve the search query value from the POST parameters. [ "s" get ] bind [ diff --git a/doc/handbook/objects.facts b/doc/handbook/objects.facts index 57df6fa24c..e9149b67ad 100644 --- a/doc/handbook/objects.facts +++ b/doc/handbook/objects.facts @@ -61,7 +61,7 @@ ARTICLE: "method-combination" "Method combination" "which stack item(s) the generic word dispatches upon," "which methods out of the set of applicable methods are called" } -"The " { $link POSTPONE: GENERIC: } " parsing word creates a generic word using the " { $emphasis "simple method combination." } ". Most generic words that come up in practice use this method combination:" +"The " { $link POSTPONE: GENERIC: } " parsing word creates a generic word using the " { $emphasis "simple method combination" } ". Most generic words that come up in practice use this method combination:" { $subsection simple-combination } "The " { $link POSTPONE: G: } " parsing word allows a different method combination to be specified:" { $subsection POSTPONE: G: } diff --git a/library/help/markup.factor b/library/help/markup.factor index c207ea3a93..a1e3a7949c 100644 --- a/library/help/markup.factor +++ b/library/help/markup.factor @@ -29,7 +29,7 @@ M: word print-element { } swap execute ; last-block off [ print-element ] with-style ; : ($block) ( quot -- ) - last-block [ [ terpri ] unless f ] change + last-block [ [ terpri ] unless t ] change call terpri last-block on ; inline diff --git a/library/inference/known-words.factor b/library/inference/known-words.factor index dc582cc43b..832c996b4d 100644 --- a/library/inference/known-words.factor +++ b/library/inference/known-words.factor @@ -434,6 +434,10 @@ sequences strings vectors words prettyprint ; \ alien-float t "flushable" set-word-prop \ set-alien-float [ [ float c-ptr integer ] [ ] ] "infer-effect" set-word-prop +\ alien-float [ [ c-ptr integer ] [ float ] ] "infer-effect" set-word-prop +\ alien-float t "flushable" set-word-prop + +\ set-alien-double [ [ float c-ptr integer ] [ ] ] "infer-effect" set-word-prop \ alien-double [ [ c-ptr integer ] [ float ] ] "infer-effect" set-word-prop \ alien-double t "flushable" set-word-prop diff --git a/library/math/random.facts b/library/math/random.facts index 23fcf1431c..77a66b1c0c 100644 --- a/library/math/random.facts +++ b/library/math/random.facts @@ -6,5 +6,5 @@ HELP: (random-int) "( -- rand )" HELP: random-int "( n -- rand )" { $values { "rand" "an integer between 0 and n" } } -{ $description "Outputs a pseudo-random integer in the interval " { $snippet "[0,n]" } "." } +{ $description "Outputs a pseudo-random integer in the interval " { $snippet "[0,n)" } "." } { $notes "As per the closed interval notation, the end-points are included in the interval." } ; diff --git a/library/syntax/parse-syntax.factor b/library/syntax/parse-syntax.factor index e27e0dd86b..8983d3e0c2 100644 --- a/library/syntax/parse-syntax.factor +++ b/library/syntax/parse-syntax.factor @@ -66,4 +66,4 @@ DEFER: PRIMITIVE: parsing scan-word [ create-constructor ] keep [ define-constructor ] [ ] ; parsing -: FORGET: scan use get hash-stack [ forget ] when* ; parsing +: FORGET: scan use get hash [ forget ] when* ; parsing diff --git a/library/tools/debugger.factor b/library/tools/debugger.factor index cfaee5657d..064a148603 100644 --- a/library/tools/debugger.factor +++ b/library/tools/debugger.factor @@ -100,8 +100,10 @@ M: object error. ( error -- ) . ; error-continuation get continuation-name hash-stack ; : debug-help ( -- ) - ":s :r show stacks at time of error." print - ":get ( var -- value ) inspects the error namestack." print + ":s :r show stacks at time of error" print + ":get ( var -- value ) accesses variables at time of error" print + ":error starts the inspector with the error" print + ":cc starts the inspector with the error continuation" print flush ; : flush-error-handler ( -- ) diff --git a/library/tools/inspector.factor b/library/tools/inspector.factor index e4aa93ef63..b74e04bf17 100644 --- a/library/tools/inspector.factor +++ b/library/tools/inspector.factor @@ -44,3 +44,9 @@ SYMBOL: inspector-stack : go ( n -- ) inspector-slots get nth (inspect) ; : up ( -- ) inspector-stack get dup pop* pop (inspect) ; + +! Another feature. +IN: errors + +: :error ( -- ) error get inspect ; +: :cc ( -- ) error-continuation get inspect ; diff --git a/library/ui/commands.factor b/library/ui/commands.factor index 409e4eaf6b..3f80677cc9 100644 --- a/library/ui/commands.factor +++ b/library/ui/commands.factor @@ -67,6 +67,7 @@ M: command-button gadget-help ( button -- string ) command-button-object dup word? [ synopsis ] [ summary ] if ; "Describe object" [ drop t ] [ describe ] \ in-browser define-default-command +"Inspect object" [ drop t ] [ inspect ] \ in-listener define-command "Describe commands" [ drop t ] [ applicable describe ] \ in-browser define-command "Prettyprint" [ drop t ] [ . ] \ in-listener define-command "Push on data stack" [ drop t ] [ ] \ in-listener define-command diff --git a/library/ui/layouts.factor b/library/ui/layouts.factor index e1831fcc9d..66f77142d9 100644 --- a/library/ui/layouts.factor +++ b/library/ui/layouts.factor @@ -60,8 +60,7 @@ DEFER: layout TUPLE: pack align fill gap ; -: pref-dims ( gadget -- list ) - gadget-children [ pref-dim ] map ; +: pref-dims ( gadget -- list ) [ pref-dim ] map ; : orient ( gadget seq1 seq2 -- seq ) >r >r gadget-orientation r> r> [ pick set-axis ] 2map nip ; @@ -105,15 +104,18 @@ C: pack ( vector -- pack ) : ( -- pack ) { 1 0 0 } ; -M: pack pref-dim ( pack -- dim ) +: pack-pref-dim ( children gadget -- dim ) [ - [ - pref-dims [ max-dim ] keep - [ { 0 0 0 } [ v+ ] reduce ] keep length 1 - 0 max - ] keep pack-gap n*v v+ + >r [ max-dim ] keep + [ { 0 0 0 } [ v+ ] reduce ] keep length 1 - 0 max + r> pack-gap n*v v+ ] keep gadget-orientation set-axis ; -M: pack layout* ( pack -- ) dup pref-dims packed-layout ; +M: pack pref-dim ( pack -- dim ) + [ gadget-children pref-dims ] keep pack-pref-dim ; + +M: pack layout* ( pack -- ) + dup gadget-children pref-dims packed-layout ; : fast-children-on ( dim axis gadgets -- i ) swapd [ rect-loc origin get v+ v- over v. ] binsearch nip ;