Clean up contrib/vim and contrib/process

slava 2006-10-21 05:54:24 +00:00
parent 618a680556
commit f0bfc94261
9 changed files with 37 additions and 25 deletions

View File

@ -37,7 +37,7 @@ Available libraries:
- math -- extended math library (Doug Coleman, Slava Pestov)
- parser-combinators -- Haskell-style parser combinators (Chris Double)
- postgresql -- PostgreSQL binding (Doug Coleman)
- process -- Run external programs (Slava Pestov)
- process -- Run external programs (Slava Pestov, Doug Coleman)
- random-tester -- Random compiler tester (Doug Coleman)
- rss -- Code to retrieve and parse an RSS2 file (Chris Double)
- sequences -- Non-core sequence words (Eduardo Cavazos)

View File

@ -3,5 +3,4 @@ USING: kernel ;
PROVIDE: contrib/process {
{ "os-unix.factor" [ unix? ] }
{ "os-windows.factor" [ windows? ] }
"process.factor"
} ;

View File

@ -1,5 +1,6 @@
IN: process
USING: compiler io io-internals kernel parser generic ;
USING: compiler io io-internals kernel parser generic
sequences ;
LIBRARY: libc
FUNCTION: int system ( char* command ) ;
@ -9,6 +10,8 @@ FUNCTION: int pclose ( void* file ) ;
: run-process ( string -- ) system io-error ;
: run-detached ( string -- ) " &" append run-process ;
! Help me implement the equivalent feature on Windows, please...
TUPLE: process-stream pipe ;
C: process-stream ( command mode -- stream )

View File

@ -1,13 +1,15 @@
IN: process
USING: alien compiler io io-internals kernel math parser generic win32-api ;
USING: alien compiler io io-internals kernel math parser generic
win32-api ;
: (run-process) ( string flag -- )
>r f swap
f f 0 r> f f
"STARTUPINFO" <c-object> "STARTUPINFO" c-size over set-STARTUPINFO-cb
"PROCESS_INFORMATION" <c-object> CreateProcess zero? [ win32-error ] when ;
>r f swap f f 0 r> f f
"STARTUPINFO" <c-object>
"STARTUPINFO" c-size over set-STARTUPINFO-cb
"PROCESS_INFORMATION" <c-object> CreateProcess
win32-error=0 ;
: run-process
: run-process ( string -- )
0 (run-process) ;
: run-detached ( string -- )

View File

@ -1,3 +0,0 @@
IN: process
USING: compiler io io-internals kernel parser generic ;

View File

@ -0,0 +1,10 @@
! Generate a new factor.vim file for syntax highlighting
REQUIRES: contrib/httpd ;
IN: vim
USING: embedded io ;
"contrib/vim/factor.vim.fgen" resource-path
"contrib/vim/factor.vim" resource-path
embedded-convert

View File

@ -1,4 +1,4 @@
REQUIRES: contrib/httpd contrib/process ;
REQUIRES: contrib/process ;
PROVIDE: contrib/vim {
"vim.factor"
"vim.facts"

View File

@ -1,8 +1,9 @@
IN: vim
USING: definitions embedded io kernel namespaces parser prettyprint process
sequences ;
USING: definitions io kernel namespaces parser prettyprint
process sequences ;
SYMBOL: vim-path
SYMBOL: vim-detach
"vim" vim-path set-global
@ -10,15 +11,11 @@ SYMBOL: vim-path
[ "\"" % vim-path get % "\" \"" % swap % "\" +" % # ] "" make ;
: vim-location ( file line -- )
vim-command run-process ;
vim-command
vim-detach get-global
[ run-detached ] [ run-process ] if ;
: vim ( spec -- )
#! Edit the file in vim. Rerun the file if the timestamp is changed.
where first2 vim-location ;
[ vim-location ] edit-hook set-global
: vim-syntax
#! Generate a new factor.vim file for syntax highlighting
"contrib/vim/factor.vim.fgen" "factor.vim" embedded-convert ;

View File

@ -2,12 +2,16 @@ IN: vim
USING: definitions help io words ;
ARTICLE: { "vim" "vim" } "Vim support"
"This module makes the " { $link edit } " word work with Vim. The "
{ $link vim-path } " variable contains the name of the vim executable. The default " { $link vim-path } " is \"vim\". For Windows, place the following example .factor-boot-rc in the directory returned by " { $link home } ":"
"This module makes the " { $link edit } " word work with Vim by setting the " { $link edit-hook } " global variable to call " { $link vim-location } ". The " { $link vim-path } " variable contains the name of the vim executable. The default " { $link vim-path } " is " { $snippet "\"vim\"" } "."
$terpri
"If you intend to use this module regularly, it helps to have it load during stage 2 bootstrap. On Windows, place the following example " { $snippet ".factor-boot-rc" } " in the directory returned by " { $link home } ":"
{ $code
"USING: modules namespaces ;"
"REQUIRES: contrib/vim ;"
"USE: vim"
"\"d:\\program files\\vim\\vim70\\gvim\" vim-path set-global"
} ;
}
"On Unix, you may omit the last line if " { $snippet "\"vim\"" } " is in your " { $snippet "$PATH" } "."
$terpri
"If you are running the terminal version of Vim, you want it to block Factor until exiting, but for GVim the opposite is desired, so that one can work in Factor and GVim concurrently. The " { $link vim-detach } " global variable can be set to " { $link t } " to detach the Vim process. The default is " { $link f } "." ;