-\r
FFI:\r
\r
- add a socket timeout\r
USE: lists
USE: logic
USE: namespaces
+USE: presentation
USE: stack
USE: stdio
USE: strings
+: file-actions ( -- list )
+ [
+ [ "Push" | "" ]
+ [ "Run file" | "run-file" ]
+ [ "List directory" | "directory." ]
+ [ "Change directory" | "cd" ]
+ ] ;
+
: set-mime-types ( assoc -- )
"mime-types" global set* ;
directory? dir-icon file-icon ? write-icon ;
: file-link. ( dir name -- )
- tuck "/" swap cat3 "file-link" swons unit write-attr ;
+ tuck "/" swap cat3 dup "file-link" swons swap
+ file-actions <actions> "actions" swons
+ t "underline" swons
+ 3list write-attr ;
: file. ( dir name -- )
#! If "doc-root" set, create links relative to it.
USE: stdio
USE: streams
USE: strings
-USE: styles
+USE: presentation
! The purpose of this library is to allow CFactor to be embedded
! inside the Java Factor listener in jEdit.
USE: stack
USE: stdio
USE: strings
-USE: styles
+USE: presentation
USE: words
USE: prettyprint
USE: unparser
#! Print a list of defined variables.
vars [ print ] each ;
+: object-actions ( -- alist )
+ [
+ [ "Describe" | "describe-path" ]
+ [ "Push" | "lookup" ]
+ ] ;
+
: link-style ( path -- style )
relative>absolute-object-path
- "object-link" default-style acons ;
+ dup "object-link" swons swap
+ object-actions <actions> "actions" swons
+ t "underline" swons
+ 3list
+ default-style append ;
: var. ( [ name | value ] -- )
uncons unparse swap link-style write-attr ;
: var-name. ( max name -- )
- tuck pad-string write dup link-style write-attr ;
+ tuck unparse pad-string write dup link-style
+ swap unparse swap write-attr ;
: value. ( max name value -- )
>r var-name. ": " write r> . ;
-: alist-keys>str ( alist -- alist )
- [ unswons unparse swons ] map ;
-
: name-padding ( alist -- col )
- [ car ] map max-str-length ;
+ [ car unparse ] map max-str-length ;
: describe-assoc ( alist -- )
dup name-padding swap
[ dupd uncons value. ] each drop ;
: alist-sort ( list -- list )
- [ swap car swap car str-lexi> ] sort ;
-
-: describe-assoc* ( alist -- )
- #! Used to describe alists made from hashtables and
- #! namespaces.
- alist-keys>str alist-sort describe-assoc ;
+ [ swap car unparse swap car unparse str-lexi> ] sort ;
: describe-namespace ( namespace -- )
- [ vars-values ] bind describe-assoc* ;
+ [ vars-values ] bind alist-sort describe-assoc ;
: describe-hashtable ( hashtables -- )
- hash>alist describe-assoc* ;
+ hash>alist alist-sort describe-assoc ;
: describe ( obj -- )
[
USE: stack
USE: stdio
USE: strings
-USE: styles
+USE: presentation
USE: words
USE: unparser
USE: vectors
"Type ``exit'' to exit, ``help'' for help." print ;
: print-prompt ( -- )
- "ok" "prompt" get-style write-attr
+ "ok" "prompt" style write-attr
! Print the space without a style, to workaround a bug in
! the GUI listener where the style from the prompt carries
! over to the input
USE: namespaces
USE: stack
USE: stdio
-USE: styles
+USE: presentation
USE: streams
USE: strings
USE: unparser
"console.Console"
] "console.Console$EvalAction" jnew ;
-: <action-menu-item> ( path pair -- action )
- uncons swapd " " swap cat3 <eval-action> ;
-
: >action-array ( list -- array )
[ "javax.swing.Action" ] coerce ;
-: <actions-menu> ( path actions -- array )
- [ dupd <action-menu-item> ] map nip >action-array ;
-
-: object-actions ( -- list )
- [
- [ "Describe" | "describe-path" ]
- [ "Push" | "lookup" ]
- [ "Execute" | "lookup execute" ]
- [ "jEdit" | "lookup jedit" ]
- [ "Usages" | "lookup usages." ]
- ] ;
-
-: <object-actions-menu> ( path -- alist )
- unparse object-actions <actions-menu> ;
-
-: file-actions ( -- list )
- [
- [ "Push" | "" ]
- [ "Run file" | "run-file" ]
- [ "List directory" | "directory." ]
- [ "Change directory" | "cd" ]
- ] ;
-
-: <file-actions-menu> ( path -- alist )
- unparse file-actions <actions-menu> ;
+: <actions-menu> ( actions -- array )
+ [ uncons <eval-action> ] map >action-array ;
: underline-attribute ( attribute-set -- )
t "Underline" swing-attribute+ ;
-: object-link-attribute ( attribute-set target -- )
- over underline-attribute
- <object-actions-menu> actions-key attribute+ ;
-
-: file-link-attribute ( attribute-set target -- )
- over underline-attribute
- <file-actions-menu> actions-key attribute+ ;
+: actions-attribute ( attribute-set actions -- )
+ <actions-menu> actions-key attribute+ ;
: icon-attribute ( string style value -- )
dupd <icon> set-icon-style
#! We need the string, since outputting an icon changes the
#! string to " ".
<attribute-set> swap [
- [ "object-link" dupd object-link-attribute ]
- [ "file-link" dupd file-link-attribute ]
+ [ "actions" dupd actions-attribute ]
[ "bold" drop dup t "Bold" swing-attribute+ ]
[ "italics" drop dup t "Italic" swing-attribute+ ]
[ "underline" drop dup t "Underline" swing-attribute+ ]
"/library/extend-stream.factor" run-resource ! streams
"/library/platform/jvm/unparser.factor" run-resource ! unparser
"/library/platform/jvm/parser.factor" run-resource ! parser
-"/library/styles.factor" run-resource ! styles
+"/library/presentation.factor" run-resource ! presentation
"/library/platform/jvm/threads.factor" run-resource ! threads
"/library/logging.factor" run-resource ! logging
USE: stdio
USE: streams
USE: strings
-USE: styles
+USE: presentation
USE: words
: stdin ( -- stdin )
USE: random
USE: stack
USE: streams
-USE: styles
+USE: presentation
USE: words
: cli-args ( -- args ) 10 getenv ;
--- /dev/null
+! :folding=indent:collapseFolds=1:
+
+! $Id$
+!
+! Copyright (C) 2004 Slava Pestov.
+!
+! 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.
+
+IN: presentation
+USE: combinators
+USE: kernel
+USE: lists
+USE: namespaces
+USE: stack
+USE: strings
+USE: unparser
+
+: <actions> ( path alist -- alist )
+ #! For each element of the alist, change the value to
+ #! path " " value
+ >r unparse r>
+ [ uncons >r over " " r> cat3 cons ] map nip ;
+
+! A style is an alist whose key/value pairs hold
+! significance to the 'fwrite-attr' word when applied to a
+! stream that supports attributed string output.
+
+: (style) ( name -- style ) "styles" get get* ;
+: default-style ( -- style ) "default" (style) ;
+: style ( name -- style )
+ (style) [ default-style ] unless* ;
+: set-style ( style name -- ) "styles" get set* ;
+
+<namespace> "styles" set
+
+[
+ [ "font" | "Monospaced" ]
+] "default" set-style
+
+[
+ [ "bold" | t ]
+] default-style append "prompt" set-style
+
+[
+ [ "ansi-fg" | "0" ]
+ [ "ansi-bg" | "2" ]
+ [ "fg" | [ 255 0 0 ] ]
+] default-style append "comments" set-style
USE: stack
USE: stdio
USE: strings
-USE: styles
+USE: presentation
USE: unparser
USE: vectors
USE: words
dup ends-with-newline? dup [ nip ] [ drop ] ifte ;
: prettyprint-comment ( comment -- )
- trim-newline "comments" get-style write-attr ;
+ trim-newline "comments" style write-attr ;
: word-link ( word -- link )
<%
word-name %
%> ;
+: word-actions ( -- list )
+ [
+ [ "Describe" | "describe-path" ]
+ [ "Push" | "lookup" ]
+ [ "Execute" | "lookup execute" ]
+ [ "jEdit" | "lookup jedit" ]
+ [ "Usages" | "lookup usages." ]
+ ] ;
+
: word-attrs ( word -- attrs )
dup defined? [
- dup >r word-link "object-link" r> word-style acons
+ dup >r
+ word-link dup >r "object-link" swons r>
+ word-actions <actions> "actions" swons
+ t "underline" swons
+ 3list
+ r>
] [
- word-style
- ] ifte ;
+ [ ] swap
+ ] ifte word-style append ;
: prettyprint-word ( word -- )
dup word-name swap word-attrs write-attr ;
+++ /dev/null
-! :folding=indent:collapseFolds=1:
-
-! $Id$
-!
-! Copyright (C) 2004 Slava Pestov.
-!
-! 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.
-
-IN: styles
-USE: combinators
-USE: kernel
-USE: lists
-USE: namespaces
-USE: stack
-
-! A style is an alist whose key/value pairs hold
-! significance to the 'fwrite-attr' word when applied to a
-! stream that supports attributed string output.
-
-: (get-style) ( name -- style ) "styles" get get* ;
-: default-style ( -- style ) "default" (get-style) ;
-: get-style ( name -- style )
- (get-style) [ default-style ] unless* ;
-: set-style ( style name -- ) "styles" get set* ;
-
-<namespace> "styles" set
-
-[
- [ "font" | "Monospaced" ]
-] "default" set-style
-
-[
- [ "bold" | t ]
-] default-style append "prompt" set-style
-
-[
- [ "ansi-fg" | "0" ]
- [ "ansi-bg" | "2" ]
- [ "fg" | [ 255 0 0 ] ]
-] default-style append "comments" set-style
IN: scratchpad
USE: lists
USE: kernel
-USE: styles
+USE: presentation
USE: test
[ t ] [ default-style assoc? ] unit-test
[ t ] [
- f "fooquux" set-style "fooquux" get-style default-style =
+ f "fooquux" set-style "fooquux" style default-style =
] unit-test
[ "Sans-Serif" ] [
[
[ "font" | "Sans-Serif" ]
] "fooquux" set-style
- "font" "fooquux" get-style assoc
+ "font" "fooquux" style assoc
] unit-test
f "fooquux" set-style
USE: kernel
USE: namespaces
USE: stack
-USE: styles
+USE: presentation
: vocab-style ( vocab -- style )
#! Each vocab has a style object specifying how words are
#! to be printed.
- "vocabularies" get-style get* ;
+ "vocabularies" style get* ;
: set-vocab-style ( style vocab -- )
- >r default-style append r> "vocabularies" get-style set* ;
+ >r default-style append r> "vocabularies" style set* ;
: word-style ( word -- style )
word-vocabulary [ vocab-style ] [ default-style ] ifte* ;