]> gitweb.factorcode.org Git - factor.git/commitdiff
editors.lite-xl: fix for windows/mac, maybe linux
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 5 Jan 2023 18:37:50 +0000 (12:37 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 5 Jan 2023 18:38:23 +0000 (12:38 -0600)
basis/editors/lite-xl/lite-xl.factor

index 3d193176b0bf6bbd11b5fb7624841a278a2626a8..e94c2dd37ff6967b292d259aeba0a2000396288f 100644 (file)
@@ -1,10 +1,26 @@
-USING: editors kernel make namespaces ;
+USING: combinators.short-circuit editors io.pathnames
+io.standard-paths kernel make namespaces strings system ;
 IN: editors.lite-xl
 
 SINGLETON: lite-xl
 
 editor-class [ lite-xl ] initialize
 
+SYMBOL: lite-xl-editor-path
+
+HOOK: find-lite-xl-editor-path os ( -- path )
+
+M: unix find-lite-xl-editor-path "xl" ?find-in-path ;
+
+M: macosx find-lite-xl-editor-path { "open" "-a" "Lite XL" } ;
+
+M: windows find-lite-xl-editor-path
+    { "lite-xl" } "xl.exe" find-in-applications
+    [ "xl.exe" ] unless* ;
+
 M: lite-xl editor-command
-    drop
-    [ "open" , "-a" , "Lite XL" , , ] { } make ;
+    [
+        lite-xl-editor-path get [ find-lite-xl-editor-path ] unless*
+        dup { [ string? ] [ pathname? ] } 1|| [ , ] [ % ] if
+        [ , ] [ drop ] bi*
+    ] { } make ;