Improve no-edit-hook error, make it restartable
parent
a342542bc5
commit
efde1afc2f
|
@ -1,21 +1,36 @@
|
||||||
! Copyright (C) 2005, 2007 Slava Pestov.
|
! Copyright (C) 2005, 2007 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: parser kernel namespaces sequences definitions io.files
|
USING: parser kernel namespaces sequences definitions io.files
|
||||||
inspector continuations tuples tools.crossref io prettyprint
|
inspector continuations tuples tools.crossref tools.browser
|
||||||
source-files ;
|
io prettyprint source-files assocs vocabs vocabs.loader ;
|
||||||
IN: editors
|
IN: editors
|
||||||
|
|
||||||
TUPLE: no-edit-hook ;
|
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
|
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 -- )
|
: edit-location ( file line -- )
|
||||||
>r ?resource-path r>
|
edit-hook get [
|
||||||
edit-hook get dup [
|
>r >r ?resource-path r> r> call
|
||||||
\ no-edit-hook construct-empty throw
|
] [
|
||||||
] if ;
|
no-edit-hook edit-location
|
||||||
|
] if* ;
|
||||||
|
|
||||||
: edit ( defspec -- )
|
: edit ( defspec -- )
|
||||||
where [ first2 edit-location ] when* ;
|
where [ first2 edit-location ] when* ;
|
||||||
|
|
|
@ -64,6 +64,7 @@ V{ } clone operations set-global
|
||||||
{ +keyboard+ T{ key-down f { C+ } "E" } }
|
{ +keyboard+ T{ key-down f { C+ } "E" } }
|
||||||
{ +primary+ t }
|
{ +primary+ t }
|
||||||
{ +secondary+ t }
|
{ +secondary+ t }
|
||||||
|
{ +listener+ t }
|
||||||
} define-operation
|
} define-operation
|
||||||
|
|
||||||
UNION: definition word method-spec link ;
|
UNION: definition word method-spec link ;
|
||||||
|
@ -72,6 +73,7 @@ UNION: editable-definition definition vocab vocab-link ;
|
||||||
|
|
||||||
[ editable-definition? ] \ edit H{
|
[ editable-definition? ] \ edit H{
|
||||||
{ +keyboard+ T{ key-down f { C+ } "E" } }
|
{ +keyboard+ T{ key-down f { C+ } "E" } }
|
||||||
|
{ +listener+ t }
|
||||||
} define-operation
|
} define-operation
|
||||||
|
|
||||||
UNION: reloadable-definition definition pathname ;
|
UNION: reloadable-definition definition pathname ;
|
||||||
|
|
Loading…
Reference in New Issue