Paste: .factor-rc

Author: Dave Carlton
Mode: factor
Date: Wed, 10 Aug 2022 17:39:37
Plain Text |
USING: accessors assocs debugger io io.encodings.utf8 io.files
io.styles kernel math prettyprint sequences strings
system ui.tools.listener vectors vocabs.loader listener namespaces ;

t handle-ctrl-break set-global

USE: extensions
USE: tools.scaffold
USE: io.servers
USE: sets
USE: parser

<< os macosx? [
   USE: editors.aquamacs
] when >>

IN: namespaces
SYMBOL: factor-history-path
factor-history-path [ "~/.factor-history" ] initialize
"Dave Carlton" developer-name set-global

IN: init
: start-fuel ( -- )
    ! stop all running listeners
    running-servers get  members
    [ dup insecure>> port>> 9000 =
      [ stop-server ]
      [ drop ]
      if
    ] each

    ! start fuel
    "fuel.remote" run
    ;

: set-history ( -- )
    factor-history-path get utf8
    file-lines
    [ dequote input boa ] map >vector
    get-listener input>> history>> over >>elements
    swap length 1 + >>index
    drop
    ;

: startup-banner ( -- )
    {    "To rebuild factor enter in terminal:" 
         "make"
         "factor -i=boot.unix-x86.64.image"
         "To Startup factor UI"
         "\"unix-x86.64\" make-image"
    } [ print ] each ;

: my-startup ( -- )
    [
        start-fuel
        scaffold-emacs
        set-history
        startup-banner
    ] try
;

[ my-startup ] "my-startup" add-startup-hook

: save-history ( -- )
    factor-history-path get utf8
    [ get-listener input>> history>> elements>>
      [ string>> . ] each
    ] with-file-appender
    ;

: my-shutdown ( -- )
    [
        save-history
    ] try
;

[ my-shutdown ] "my-shutdown" add-shutdown-hook

New Annotation

Summary:
Author:
Mode:
Body: