| 
									
										
										
										
											2015-04-30 21:20:16 -04:00
										 |  |  | ! Copyright (C) 2015 Doug Coleman. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2016-05-11 14:52:40 -04:00
										 |  |  | USING: combinators.extras combinators.short-circuit editors | 
					
						
							|  |  |  | generalizations io.files io.pathnames io.standard-paths kernel | 
					
						
							|  |  |  | make math.parser memoize namespaces sequences system tools.which ;
 | 
					
						
							| 
									
										
										
										
											2015-04-30 21:20:16 -04:00
										 |  |  | IN: editors.visual-studio-code | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 16:23:24 -05:00
										 |  |  | ! Command line arguments | 
					
						
							|  |  |  | ! https://code.visualstudio.com/docs/editor/codebasics#_additional-command-line-arguments | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-30 21:20:16 -04:00
										 |  |  | SINGLETON: visual-studio-code | 
					
						
							|  |  |  | visual-studio-code editor-class set-global
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-12 10:06:50 -05:00
										 |  |  | HOOK: find-visual-studio-code-invocation os ( -- array )
 | 
					
						
							| 
									
										
										
										
											2015-05-01 01:55:19 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-12 10:06:50 -05:00
										 |  |  | MEMO: visual-studio-code-invocation ( -- array )
 | 
					
						
							| 
									
										
										
										
											2016-05-11 14:52:40 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         [ \ visual-studio-code-invocation get ] | 
					
						
							|  |  |  |         [ find-visual-studio-code-invocation ] | 
					
						
							|  |  |  |         [ "code" ] | 
					
						
							|  |  |  |     } 0|| ;
 | 
					
						
							| 
									
										
										
										
											2015-04-30 21:20:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-12 10:06:50 -05:00
										 |  |  | M: macosx find-visual-studio-code-invocation | 
					
						
							| 
									
										
										
										
											2016-03-28 19:56:07 -04:00
										 |  |  |     "com.microsoft.VSCode" find-native-bundle [ | 
					
						
							|  |  |  |         "Contents/MacOS/Electron" append-path | 
					
						
							|  |  |  |     ] [ | 
					
						
							|  |  |  |         f
 | 
					
						
							|  |  |  |     ] if* ;
 | 
					
						
							| 
									
										
										
										
											2016-02-12 10:06:50 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-23 21:45:25 -05:00
										 |  |  | ERROR: can't-find-visual-studio-code ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: linux find-visual-studio-code-invocation | 
					
						
							| 
									
										
										
										
											2016-05-11 14:52:40 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         [ "code" which ] | 
					
						
							|  |  |  |         [ "Code" which ] | 
					
						
							|  |  |  |         [ home "VSCode-linux-x64/Code" append-path ] | 
					
						
							|  |  |  |         [ "/usr/share/code/code" ] | 
					
						
							|  |  |  |     } [ [ exists? ] ?1arg ] map-compose 0|| ;
 | 
					
						
							| 
									
										
										
										
											2016-02-23 21:45:25 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-07 16:23:24 -05:00
										 |  |  | M: windows find-visual-studio-code-invocation | 
					
						
							| 
									
										
										
										
											2016-05-11 14:52:40 -04:00
										 |  |  |     { | 
					
						
							|  |  |  |         [ { "Microsoft VS Code" } "code.exe" find-in-applications ] | 
					
						
							|  |  |  |     } 0|| ;
 | 
					
						
							| 
									
										
										
										
											2016-03-07 16:23:24 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-30 21:20:16 -04:00
										 |  |  | M: visual-studio-code editor-command ( file line -- command )
 | 
					
						
							|  |  |  |     [ | 
					
						
							| 
									
										
										
										
											2016-03-28 19:56:07 -04:00
										 |  |  |         visual-studio-code-invocation | 
					
						
							|  |  |  |         [ , ] [ can't-find-visual-studio-code ] if*
 | 
					
						
							|  |  |  |         "-g" , "-r" , | 
					
						
							| 
									
										
										
										
											2016-02-15 15:42:31 -05:00
										 |  |  |         number>string ":" glue , | 
					
						
							| 
									
										
										
										
											2015-04-30 21:20:16 -04:00
										 |  |  |     ] { } make ;
 |