Improve no-edit-hook error, make it restartable
parent
a342542bc5
commit
efde1afc2f
|
@ -1,21 +1,36 @@
|
|||
! Copyright (C) 2005, 2007 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: parser kernel namespaces sequences definitions io.files
|
||||
inspector continuations tuples tools.crossref io prettyprint
|
||||
source-files ;
|
||||
inspector continuations tuples tools.crossref tools.browser
|
||||
io prettyprint source-files assocs vocabs vocabs.loader ;
|
||||
IN: editors
|
||||
|
||||
TUPLE: no-edit-hook ;
|
||||
|
||||
M: no-edit-hook summary drop "No edit hook is set" ;
|
||||
M: no-edit-hook summary
|
||||
drop "You must load one of the below vocabularies before using editor integration:" ;
|
||||
|
||||
SYMBOL: edit-hook
|
||||
|
||||
: available-editors ( -- seq )
|
||||
"editors" all-child-vocabs
|
||||
values concat [ vocab-name ] map ;
|
||||
|
||||
: editor-restarts ( -- alist )
|
||||
available-editors
|
||||
[ "Load " over append swap ] { } map>assoc ;
|
||||
|
||||
: no-edit-hook ( -- )
|
||||
\ no-edit-hook construct-empty
|
||||
editor-restarts throw-restarts
|
||||
require ;
|
||||
|
||||
: edit-location ( file line -- )
|
||||
>r ?resource-path r>
|
||||
edit-hook get dup [
|
||||
\ no-edit-hook construct-empty throw
|
||||
] if ;
|
||||
edit-hook get [
|
||||
>r >r ?resource-path r> r> call
|
||||
] [
|
||||
no-edit-hook edit-location
|
||||
] if* ;
|
||||
|
||||
: edit ( defspec -- )
|
||||
where [ first2 edit-location ] when* ;
|
||||
|
|
|
@ -64,6 +64,7 @@ V{ } clone operations set-global
|
|||
{ +keyboard+ T{ key-down f { C+ } "E" } }
|
||||
{ +primary+ t }
|
||||
{ +secondary+ t }
|
||||
{ +listener+ t }
|
||||
} define-operation
|
||||
|
||||
UNION: definition word method-spec link ;
|
||||
|
@ -72,6 +73,7 @@ UNION: editable-definition definition vocab vocab-link ;
|
|||
|
||||
[ editable-definition? ] \ edit H{
|
||||
{ +keyboard+ T{ key-down f { C+ } "E" } }
|
||||
{ +listener+ t }
|
||||
} define-operation
|
||||
|
||||
UNION: reloadable-definition definition pathname ;
|
||||
|
|
Loading…
Reference in New Issue