Browse Source

Cleanups.

Mark Sibly 9 years ago
parent
commit
bd0f6e5970

+ 5 - 17
src/ted2/buildactions.monkey2

@@ -46,17 +46,6 @@ Class BuildActions
 
 			If doc=_locked _locked=Null
 		End
-	
-#If __TARGET__="macos"
-		_mx2cc="bin/mx2cc_macos"
-#Else If __TARGET__="windows"
-		_mx2cc="bin/mx2cc_windows.exe"
-#Else If __TARGET__="raspbian"
-		_mx2cc="bin/mx2cc_raspbian"
-#Else
-		_mx2cc="bin/mx2cc_linux"
-#Endif
-		_mx2cc=RealPath( _mx2cc )
 		
 		buildAndRun=New Action( "Build and run" )
 		buildAndRun.Triggered=OnBuildAndRun
@@ -221,6 +210,7 @@ Class BuildActions
 			Endif
 			
 		Endif
+		
 	End
 	
 	Method Update()
@@ -245,8 +235,6 @@ Class BuildActions
 	Field _docs:DocumentManager
 	Field _console:Console
 	Field _debugView:DebugView
-
-	Field _mx2cc:String
 	
 	Field _locked:Monkey2Document
 	
@@ -384,7 +372,7 @@ Class BuildActions
 		
 			Local cfg:=(config ? "debug" Else "release")
 			
-			Local cmd:=_mx2cc+" makemods -target="+target
+			Local cmd:=MainWindow.Mx2ccPath+" makemods -target="+target
 			If clean cmd+=" -clean"
 			cmd+=" -config="+cfg
 			
@@ -433,7 +421,7 @@ Class BuildActions
 	
 	Method MakeDocs:Bool()
 	
-		Return BuildMx2( _mx2cc+" makedocs","Rebuilding documentation..." )
+		Return BuildMx2( MainWindow.Mx2ccPath+" makedocs","Rebuilding documentation..." )
 	End
 	
 	Method BuildApp:Bool( config:String,target:String,run:bool )
@@ -452,7 +440,7 @@ Class BuildActions
 			target="desktop"
 		End
 
-		Local cmd:=_mx2cc+" makeapp -build "+opts
+		Local cmd:=MainWindow.Mx2ccPath+" makeapp -build "+opts
 		cmd+=" -apptype="+appType+" "
 		cmd+=" -config="+config
 		cmd+=" -target="+target
@@ -542,7 +530,7 @@ Class BuildActions
 	
 	Method OnModuleManager()
 	
-		Local modman:=New ModuleManager( _mx2cc,_console )
+		Local modman:=New ModuleManager( _console )
 		
 		modman.Open()
 	End

+ 3 - 80
src/ted2/jsondocument.monkey2

@@ -1,83 +1,6 @@
 
 Namespace ted2
 
-Class JsonTree Extends TreeView
-
-	Class Node Extends TreeView.Node
-	
-		Method New( jval:JsonValue,parent:TreeView.Node,prefix:String="" )
-			Super.New( "",parent )
-		
-			If Not jval
-				Text=prefix+"null"
-				Return
-			Endif
-		
-			Local jobj:=Cast<JsonObject>( jval )
-			If jobj
-				Local obj:=jval.ToObject()
-				Text=prefix+"{"+obj.Count()+"}"
-				For Local it:=Eachin obj
-					New Node( it.Value,Self,it.Key+":" )
-				Next
-				Return
-			Endif
-			
-			Local jarr:=Cast<JsonArray>( jval )
-			If jarr
-				Local arr:=jarr.ToArray()
-				Text=prefix+"["+arr.Length+"]"
-				For Local i:=0 Until arr.Length
-					New Node( arr[i],Self,String( i )+":" )
-				Next
-				Return
-			Endif
-			
-			Local jstr:=Cast<JsonString>( jval )
-			If jstr
-				Text=prefix+"~q"+jstr.ToString()+"~q"
-				Return
-			End
-			
-			Local jnum:=Cast<JsonNumber>( jval )
-			If jnum
-				Text=prefix+String( jnum.ToNumber() )
-				Return
-			Endif
-			
-			Local jbool:=Cast<JsonBool>( jval )
-			If jbool
-				Text=prefix+( jbool.ToBool() ? "true" Else "false" )
-				Return
-			Endif
-			
-			Text="?????"
-		End
-		
-	End
-	
-	Method New()
-		RootNodeVisible=False
-		RootNode.Expanded=True
-	End
-	
-	Property Value:JsonValue()
-	
-		Return _value
-	
-	Setter( jval:JsonValue )
-	
-		RootNode.RemoveAllChildren()
-		
-		New Node( jval,RootNode )
-	End
-	
-	Private
-	
-	Field _value:JsonValue
-	
-End
-
 Class JsonDocumentView Extends DockingView
 
 	Method New( doc:TextDocument )
@@ -89,7 +12,7 @@ Class JsonDocumentView Extends DockingView
 			_jsonTree.Value=JsonValue.Parse( _textView.Text )
 		End
 
-		_jsonTree=New JsonTree
+		_jsonTree=New JsonTreeView
 				
 		AddView( _jsonTree,"right",300,True )
 		
@@ -101,7 +24,7 @@ Class JsonDocumentView Extends DockingView
 		Return _textView
 	End
 	
-	Property JsonTree:JsonTree()
+	Property JsonTree:JsonTreeView()
 	
 		Return _jsonTree
 	End
@@ -109,7 +32,7 @@ Class JsonDocumentView Extends DockingView
 	Private
 	
 	Field _textView:TextView
-	Field _jsonTree:JsonTree
+	Field _jsonTree:JsonTreeView
 
 End
 

+ 89 - 0
src/ted2/jsontreeview.monkey2

@@ -0,0 +1,89 @@
+
+Namespace ted2
+
+Class JsonTreeView Extends TreeView
+
+	Class Node Extends TreeView.Node
+	
+		Method New( jval:JsonValue,parent:TreeView.Node,prefix:String="" )
+			Super.New( "",parent )
+		
+			If Not jval
+				Text=prefix+"null"
+				Return
+			Endif
+		
+			Local jobj:=Cast<JsonObject>( jval )
+			If jobj
+				Local obj:=jval.ToObject()
+				Text=prefix+"{"+obj.Count()+"}"
+				For Local it:=Eachin obj
+					New Node( it.Value,Self,it.Key+":" )
+				Next
+				Return
+			Endif
+			
+			Local jarr:=Cast<JsonArray>( jval )
+			If jarr
+				Local arr:=jarr.ToArray()
+				Text=prefix+"["+arr.Length+"]"
+				For Local i:=0 Until arr.Length
+					New Node( arr[i],Self,String( i )+":" )
+				Next
+				Return
+			Endif
+			
+			Local jstr:=Cast<JsonString>( jval )
+			If jstr
+				Text=prefix+"~q"+jstr.ToString()+"~q"
+				Return
+			End
+			
+			Local jnum:=Cast<JsonNumber>( jval )
+			If jnum
+				Text=prefix+String( jnum.ToNumber() )
+				Return
+			Endif
+			
+			Local jbool:=Cast<JsonBool>( jval )
+			If jbool
+				Text=prefix+( jbool.ToBool() ? "true" Else "false" )
+				Return
+			Endif
+			
+			Text="?????"
+		End
+		
+	End
+	
+	Method New()
+	
+		RootNodeVisible=False
+		
+		RootNode.Expanded=True
+	End
+	
+	Method New( value:JsonValue )
+		Self.New()
+		
+		Value=value
+	End
+	
+	Property Value:JsonValue()
+	
+		Return _value
+	
+	Setter( value:JsonValue )
+	
+		RootNode.RemoveAllChildren()
+		
+		If Not value Return
+		
+		New Node( value,RootNode )
+	End
+	
+	Private
+	
+	Field _value:JsonValue
+	
+End

+ 30 - 2
src/ted2/mainwindow.monkey2

@@ -16,6 +16,19 @@ Class MainWindowInstance Extends Window
 		
 		MainWindow=Self
 		
+		_tmp=RealPath( "tmp/" )
+		
+#If __TARGET__="macos"
+		_mx2cc="bin/mx2cc_macos"
+#Else If __TARGET__="windows"
+		_mx2cc="bin/mx2cc_windows.exe"
+#Else If __TARGET__="raspbian"
+		_mx2cc="bin/mx2cc_raspbian"
+#Else
+		_mx2cc="bin/mx2cc_linux"
+#Endif
+		_mx2cc=RealPath( _mx2cc )
+		
 		_docsTabView=New TabView( TabViewFlags.DraggableTabs|TabViewFlags.ClosableTabs )
 		_browsersTabView=New TabView( TabViewFlags.DraggableTabs )
 		_consolesTabView=New TabView( TabViewFlags.DraggableTabs )
@@ -86,7 +99,6 @@ Class MainWindowInstance Extends Window
 			_fileActions.close.Trigger()
 		End
 
-		_tmp=RealPath( "tmp/" )
 		
 		'File menu
 		'
@@ -229,6 +241,11 @@ Class MainWindowInstance Extends Window
 		If GetFileType( "bin/ted2.state.json" )=FileType.None _helpActions.about.Trigger()
 	End
 	
+	Property Mx2ccPath:String()
+	
+		Return _mx2cc
+	End
+	
 	Method Terminate()
 	
 		SaveState()
@@ -364,6 +381,8 @@ Class MainWindowInstance Extends Window
 		
 		jobj["themeScale"]=New JsonNumber( App.Theme.Scale.y )
 		
+		If _mx2ccDir jobj["mx2ccDir"]=New JsonString( _mx2ccDir )
+		
 		_docsManager.SaveState( jobj )
 		_buildActions.SaveState( jobj )
 		_projectView.SaveState( jobj )
@@ -394,6 +413,12 @@ Class MainWindowInstance Extends Window
 			App.Theme.Scale=New Vec2f( _themeScale,_themeScale )
 		Endif
 		
+		If jobj.Contains( "mx2ccDir" )
+			_mx2ccDir=jobj.GetString( "mx2ccDir" )
+			If Not _mx2ccDir.EndsWith( "/" ) _mx2ccDir+="/"
+			_mx2cc=_mx2ccDir+StripDir( _mx2cc )
+		Endif
+		
 		_docsManager.LoadState( jobj )
 		_buildActions.LoadState( jobj )
 		_projectView.LoadState( jobj )
@@ -440,6 +465,10 @@ Class MainWindowInstance Extends Window
 	End
 	
 	Private
+
+	Field _tmp:String
+	Field _mx2cc:String
+	Field _mx2ccDir:String
 	
 	Field _docsManager:DocumentManager
 	Field _fileActions:FileActions
@@ -460,7 +489,6 @@ Class MainWindowInstance Extends Window
 	Field _consolesTabView:TabView
 	Field _browsersTabView:TabView
 	
-	Field _tmp:String
 	Field _forceStop:Action
 
 	Field _tabMenu:Menu

+ 3 - 5
src/ted2/modulemanager.monkey2

@@ -17,10 +17,9 @@ Public
 
 Class ModuleManager Extends Dialog
 
-	Method New( mx2cc:String,console:Console )
+	Method New( console:Console )
 		Super.New( "Module Manager" )
 		
-		_mx2cc=mx2cc
 		_console=console
 		
 		_table=New TableView
@@ -102,7 +101,6 @@ Class ModuleManager Extends Dialog
 	Const downloadDir:="modules/module-manager/downloads/"
 	Const backupDir:="modules/module-manager/backups/"
 	
-	Field _mx2cc:String
 	Field _console:Console
 	Field _docker:DockingView
 	Field _modules:=New StringMap<Module>
@@ -253,7 +251,7 @@ Class ModuleManager Extends Dialog
 	
 		For Local config:=0 Until 2
 			
-			Local cmd:=_mx2cc+" makemods -config="+(config ? "debug" Else "release")
+			Local cmd:=MainWindow.Mx2ccPath+" makemods -config="+(config ? "debug" Else "release")
 				
 			If Not _console.Run( cmd ) Return False
 			
@@ -264,7 +262,7 @@ Class ModuleManager Extends Dialog
 			
 		Next
 		
-		Local cmd:=_mx2cc+" makedocs"
+		Local cmd:=MainWindow.Mx2ccPath+" makedocs"
 		
 		For Local module:=Eachin _procmods
 			cmd+=" "+module.name

+ 24 - 0
src/ted2/monkey2document.monkey2

@@ -358,6 +358,30 @@ Class Monkey2DocumentView Extends Ted2TextView
 				
 				If ident MainWindow.ShowQuickHelp( ident )
 				
+			Case Key.F2
+			
+				New Fiber( Lambda()
+				
+					Local cmd:="~q"+MainWindow.Mx2ccPath+"~q makeapp -parse -geninfo ~q"+_doc.Path+"~q"
+					
+					Local str:=LoadString( "process::"+cmd )
+					Local i:=str.Find( "{" )
+					If i=-1 Return
+					str=str.Slice( i )
+					
+					Local jobj:=JsonObject.Parse( str )
+					If Not jobj Return
+					
+					Local jsonTree:=New JsonTreeView( jobj )
+					
+					Local dialog:=New Dialog( "ParseInfo",jsonTree )
+					dialog.AddAction( "Close" ).Triggered=dialog.Close
+					dialog.MinSize=New Vec2i( 512,600 )
+					
+					dialog.Open()
+				
+				End )
+				
 			Case Key.Tab,Key.Enter
 			
 				If _typing Capitalize( False )

+ 1 - 0
src/ted2/ted2.monkey2

@@ -21,6 +21,7 @@
 #import "helptree"
 #Import "modulemanager"
 #import "ted2textview"
+#Import "jsontreeview"
 #Import "gutterview"
 
 #import "plugin"

+ 4 - 1
src/ted2/ted2textview.monkey2

@@ -5,7 +5,10 @@ Class Ted2TextView Extends TextView
 
 	Method New()
 
-		CursorBlinkRate=2.5
+#If __TARGET__<>"raspbian"
+		CursorBlinkRate=2.5	'crashing on Pi?
+#Endif
+
 	End
 
 	Protected