]> gitweb.factorcode.org Git - factor.git/blob - basis/editors/sublime/sublime.factor
editors: allow them to be loaded in the load-all image
[factor.git] / basis / editors / sublime / sublime.factor
1 ! Copyright (C) 2013 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators.short-circuit editors io.pathnames
4 io.standard-paths kernel make math.parser namespaces sequences
5 system ;
6 IN: editors.sublime
7
8 SINGLETON: sublime
9
10 editor-class [ sublime ] initialize
11
12 HOOK: find-sublime-path os ( -- path )
13
14 M: object find-sublime-path f ;
15
16 M: macosx find-sublime-path
17     { "com.sublimetext.3" "com.sublimetext.2" } [ find-native-bundle ] map-find drop [
18         "Contents/SharedSupport/bin/subl" append-path
19     ] [
20         f
21     ] if* ;
22
23 M: windows find-sublime-path
24     {
25         [ { "Sublime Text 3" } "subl.exe" find-in-applications ]
26         [ { "Sublime Text 2" } "sublime_text.exe" find-in-applications ]
27         [ "subl.exe" ]
28     } 0|| ;
29
30 : sublime-path  ( -- path )
31     \ sublime-path get [
32         find-sublime-path [ "subl" ?find-in-path ] unless*
33     ] unless* ;
34
35 M: sublime editor-command
36     [
37         sublime-path , "-a" , number>string ":" glue ,
38     ] { } make ;