| 
									
										
										
										
											2013-04-06 17:23:06 -04:00
										 |  |  | ! Copyright (C) 2013 Doug Coleman. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2015-06-01 18:34:11 -04:00
										 |  |  | USING: combinators.short-circuit editors io.pathnames | 
					
						
							|  |  |  | io.standard-paths kernel make math.parser namespaces sequences | 
					
						
							|  |  |  | system ;
 | 
					
						
							| 
									
										
										
										
											2013-04-06 17:23:06 -04:00
										 |  |  | IN: editors.sublime | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | SINGLETON: sublime | 
					
						
							|  |  |  | sublime editor-class set-global
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HOOK: find-sublime-path os ( -- path )
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-01 17:39:30 -04:00
										 |  |  | M: object find-sublime-path f ;
 | 
					
						
							| 
									
										
										
										
											2013-04-06 17:23:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | M: macosx find-sublime-path | 
					
						
							| 
									
										
										
										
											2014-10-30 22:41:59 -04:00
										 |  |  |     { "com.sublimetext.3" "com.sublimetext.2" } [ find-native-bundle ] map-find drop [ | 
					
						
							| 
									
										
										
										
											2013-04-06 17:23:06 -04:00
										 |  |  |         "Contents/SharedSupport/bin/subl" append-path | 
					
						
							|  |  |  |     ] [ | 
					
						
							|  |  |  |         f
 | 
					
						
							|  |  |  |     ] if* ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-01 17:39:30 -04:00
										 |  |  | M: windows find-sublime-path | 
					
						
							| 
									
										
										
										
											2015-06-01 18:34:11 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         [ { "Sublime Text 3" } "subl.exe" find-in-applications ] | 
					
						
							|  |  |  |         [ { "Sublime Text 2" } "sublime_text.exe" find-in-applications ] | 
					
						
							|  |  |  |         [ "subl.exe" ] | 
					
						
							|  |  |  |     } 0|| ;
 | 
					
						
							| 
									
										
										
										
											2013-04-06 17:23:06 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : sublime-path  ( -- path )
 | 
					
						
							| 
									
										
										
										
											2015-06-01 17:39:30 -04:00
										 |  |  |     \ sublime-path get [ | 
					
						
							|  |  |  |         find-sublime-path [ "subl" ?find-in-path ] unless*
 | 
					
						
							| 
									
										
										
										
											2013-04-06 17:23:06 -04:00
										 |  |  |     ] unless* ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: sublime editor-command ( file line -- command )
 | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         sublime-path , "-a" , number>string ":" glue , | 
					
						
							|  |  |  |     ] { } make ;
 |