Browse Source

Removed old ted2 src and renamed rebuildallgo.* scripts to rebuildall.*

Mark Sibly 6 years ago
parent
commit
207b4a9cc1
60 changed files with 5 additions and 7509 deletions
  1. 3 0
      scripts/package-lock.json
  2. 1 1
      scripts/rebuildall.bat
  3. 1 1
      scripts/rebuildall.sh
  4. 0 14
      scripts/rebuildall2go.bat
  5. 0 5
      scripts/rebuildall2go.sh
  6. 0 26
      scripts/updateted2.bat
  7. BIN
      src/ted2/assets/fonts/verdana.ttf
  8. BIN
      src/ted2/assets/fonts/verdanab.ttf
  9. 0 54
      src/ted2/assets/newfiles/Letterboxed_Mojo_App.monkey2
  10. 0 12
      src/ted2/assets/newfiles/Simple_Console_App.monkey2
  11. 0 33
      src/ted2/assets/newfiles/Simple_Mojo_App.monkey2
  12. 0 26
      src/ted2/assets/newfiles/Simple_Mojox_Gui_App.monkey2
  13. BIN
      src/ted2/assets/themes/debug_icons.png
  14. BIN
      src/ted2/assets/themes/smooth_assets/button_skin.png
  15. BIN
      src/ted2/assets/themes/smooth_assets/checkbox_icons.png
  16. BIN
      src/ted2/assets/themes/smooth_assets/dialog_skin.png
  17. BIN
      src/ted2/assets/themes/smooth_assets/progressbar_icons.png
  18. BIN
      src/ted2/assets/themes/smooth_assets/tabbutton_skin.png
  19. BIN
      src/ted2/assets/themes/smooth_assets/tabclose_icons.png
  20. BIN
      src/ted2/assets/themes/smooth_assets/treeview_icons.png
  21. 0 23
      src/ted2/assets/themes/ted2-default.json
  22. 0 39
      src/ted2/assets/themes/theme-Basic-Blue.json
  23. 0 32
      src/ted2/assets/themes/theme-blitzed.json
  24. 0 32
      src/ted2/assets/themes/theme-classic-dark.json
  25. 0 41
      src/ted2/assets/themes/theme-monkey1.json
  26. 0 32
      src/ted2/assets/themes/theme-overcast.json
  27. 0 271
      src/ted2/assets/themes/theme-smooth.json
  28. 0 8
      src/ted2/assets/themes/themes.json
  29. 0 185
      src/ted2/audiodocument.monkey2
  30. BIN
      src/ted2/bin/wget.exe
  31. 0 562
      src/ted2/buildactions.monkey2
  32. 0 581
      src/ted2/buildproduct.monkey2
  33. 0 464
      src/ted2/debugview.monkey2
  34. 0 365
      src/ted2/documentmanager.monkey2
  35. 0 138
      src/ted2/editactions.monkey2
  36. 0 130
      src/ted2/editproductdialog.monkey2
  37. 0 273
      src/ted2/fileactions.monkey2
  38. 0 180
      src/ted2/findactions.monkey2
  39. 0 81
      src/ted2/finddialog.monkey2
  40. 0 59
      src/ted2/gutterview.monkey2
  41. 0 51
      src/ted2/helpactions.monkey2
  42. 0 258
      src/ted2/helptree.monkey2
  43. 0 161
      src/ted2/imagedocument.monkey2
  44. 0 85
      src/ted2/jsondocument.monkey2
  45. 0 93
      src/ted2/jsontreeview.monkey2
  46. 0 665
      src/ted2/mainwindow.monkey2
  47. 0 628
      src/ted2/modulemanager.monkey2
  48. 0 550
      src/ted2/monkey2document.monkey2
  49. 0 59
      src/ted2/monkey2treeview.monkey2
  50. 0 157
      src/ted2/mx2ccenv.monkey2
  51. 0 98
      src/ted2/plaintextdocument.monkey2
  52. 0 52
      src/ted2/plugin.monkey2
  53. 0 211
      src/ted2/projectview.monkey2
  54. 0 208
      src/ted2/scenedocument.monkey2
  55. 0 106
      src/ted2/ted2.monkey2
  56. 0 207
      src/ted2/ted2document.monkey2
  57. 0 27
      src/ted2/ted2textview.monkey2
  58. 0 64
      src/ted2/textviewkeyeventfilter.monkey2
  59. 0 83
      src/ted2/xmldocument.monkey2
  60. 0 78
      src/ted2/xmltreeview.monkey2

+ 3 - 0
scripts/package-lock.json

@@ -0,0 +1,3 @@
+{
+  "lockfileVersion": 1
+}

+ 1 - 1
scripts/rebuildall.bat

@@ -7,7 +7,7 @@ if %errorlevel% neq 0 exit /b %errorlevel%
 call rebuildmods
 call rebuildmods
 if %errorlevel% neq 0 exit /b %errorlevel%
 if %errorlevel% neq 0 exit /b %errorlevel%
 
 
-call rebuildted2
+call rebuildted2go
 if %errorlevel% neq 0 exit /b %errorlevel%
 if %errorlevel% neq 0 exit /b %errorlevel%
 
 
 call makedocs
 call makedocs

+ 1 - 1
scripts/rebuildall.sh

@@ -1,5 +1,5 @@
 
 
 ./rebuildmx2cc.sh
 ./rebuildmx2cc.sh
 ./rebuildmods.sh
 ./rebuildmods.sh
-./rebuildted2.sh
+./rebuildted2go.sh
 ./makedocs.sh
 ./makedocs.sh

+ 0 - 14
scripts/rebuildall2go.bat

@@ -1,14 +0,0 @@
-
-echo off
-
-call rebuildmx2cc
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-call rebuildmods
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-call rebuildted2go
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-call makedocs
-if %errorlevel% neq 0 exit /b %errorlevel%

+ 0 - 5
scripts/rebuildall2go.sh

@@ -1,5 +0,0 @@
-
-./rebuildmx2cc.sh
-./rebuildmods.sh
-./rebuildted2go.sh
-./makedocs.sh

+ 0 - 26
scripts/updateted2.bat

@@ -1,26 +0,0 @@
-
-echo off
-
-call common.bat
-
-echo.
-echo ***** Updating ted2 *****
-echo.
-
-%mx2cc% makeapp -apptype=gui -build -config=release -product=scripts/ted2.products/windows/ted2.exe ../src/ted2/ted2.monkey2
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-xcopy ted2.products\windows\assets ..\bin\ted2_windows\assets /Q /I /S /Y
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-xcopy ted2.products\windows\*.dll ..\bin\ted2_windows /Q /I /S /Y
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-xcopy ted2.products\windows\*.exe ..\bin\ted2_windows /Q /I /S /Y
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-%mx2cc% makeapp -apptype=gui -build -config=release -product=scripts/launcher.products/launcher_windows.exe ../src/launcher/launcher.monkey2
-if %errorlevel% neq 0 exit /b %errorlevel%
-
-copy launcher.products\launcher_windows.exe "..\Monkey2 (Windows).exe"
-if %errorlevel% neq 0 exit /b %errorlevel%

BIN
src/ted2/assets/fonts/verdana.ttf


BIN
src/ted2/assets/fonts/verdanab.ttf


+ 0 - 54
src/ted2/assets/newfiles/Letterboxed_Mojo_App.monkey2

@@ -1,54 +0,0 @@
-
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-
-Using std..
-Using mojo..
-
-Const Size:=New Vec2i( 640,360 )
-
-Class MyWindow Extends Window
-
-	Method New()
-		Super.New( "My Window",640,480,WindowFlags.Resizable )
-	
-		Layout="letterbox"
-	
-	End
-
-	Method OnRender( canvas:Canvas ) Override
-	
-		App.RequestRender()
-	
-		canvas.DrawText( "Hello World",Width/2,Height/2,.5,.5 )
-	
-	End
-	
-	Method OnKeyEvent( event:KeyEvent ) Override
-	
-		If event.Type=EventType.KeyDown And event.Key=Key.Enter And event.Modifiers & Modifier.Alt
-		
-			Fullscreen=Not Fullscreen
-			
-		Endif
-	
-	End
-	
-	Method OnMeasure:Vec2i() Override
-	
-		Return Size
-		
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 12
src/ted2/assets/newfiles/Simple_Console_App.monkey2

@@ -1,12 +0,0 @@
-
-Namespace myapp
-
-#Import "<std>"
-
-Using std..
-
-Function Main()
-
-	Print "Hello World"
-	
-End

+ 0 - 33
src/ted2/assets/newfiles/Simple_Mojo_App.monkey2

@@ -1,33 +0,0 @@
-
-Namespace myapp
-
-#Import "<std>"
-#Import "<mojo>"
-
-Using std..
-Using mojo..
-
-Class MyWindow Extends Window
-
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )
-
-		Super.New( title,width,height,flags )
-	End
-
-	Method OnRender( canvas:Canvas ) Override
-	
-		App.RequestRender()
-	
-		canvas.DrawText( "Hello World!",Width/2,Height/2,.5,.5 )
-	End
-	
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End

+ 0 - 26
src/ted2/assets/newfiles/Simple_Mojox_Gui_App.monkey2

@@ -1,26 +0,0 @@
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojox>"
-
-Using std..
-Using mojo..
-Using mojox..
-
-Class MyWindow Extends Window
-
-	Method New()
-		Super.New( "Simple Mojo Gui App",640,480,WindowFlags.Resizable )
-	End
-
-End
-
-Function Main()
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-End
-

BIN
src/ted2/assets/themes/debug_icons.png


BIN
src/ted2/assets/themes/smooth_assets/button_skin.png


BIN
src/ted2/assets/themes/smooth_assets/checkbox_icons.png


BIN
src/ted2/assets/themes/smooth_assets/dialog_skin.png


BIN
src/ted2/assets/themes/smooth_assets/progressbar_icons.png


BIN
src/ted2/assets/themes/smooth_assets/tabbutton_skin.png


BIN
src/ted2/assets/themes/smooth_assets/tabclose_icons.png


BIN
src/ted2/assets/themes/smooth_assets/treeview_icons.png


+ 0 - 23
src/ted2/assets/themes/ted2-default.json

@@ -1,23 +0,0 @@
-{
-	"extends":"default",
-	
-	"styles":{
-	
-		"GutterView":{
-			"extends":"TextView",
-			"textColor":"text-disabled"
-		},
-		
-		"DebugToolBar":{
-			"extends":"ToolBar",
-			"border":[ 4 ],
-			"borderColor":"content",
-			"icons":"debug_icons.png"
-		},
-		
-		"HelpTextField":{
-			"extends":"TextField",
-			"skinColor":"panel"
-		}
-	}
-}

+ 0 - 39
src/ted2/assets/themes/theme-Basic-Blue.json

@@ -1,39 +0,0 @@
-{
-	"extends":"ted2-default",
-	
-	"colors":{
-
-		"content": "#005",
-		"clear": "#000",
-		"panel": "#00b",
-		"gutter": "#000",
-		
-		"knob": "#009",
-		"hover": "#09f",
-		"active" : "#009",
-
-		"text-default": "#fff",
-		"text-highlight": "#09f",
-		"text-disabled":  "#888",
-		"text-background": "#09f",
-		
-		"textview-cursor":"#fff",
-		"textview-selection":"#222",
-		
-		"textview-color0": "#0000",
-		"textview-color1": "#07e",	//identifiers
-		"textview-color2": "#ff0",	//keywords
-		"textview-color3": "#e0e",	//strings
-		"textview-color4": "#0f0",	//numbers
-		"textview-color5": "#fff",	//comment
-		"textview-color6": "#d82",	//preproc
-		"textview-color7": "#222"	//default
-	},
-	
-	"fonts":{
-	
-		"normal":"Verdana.ttf,16",
-		"fixedWidth":"Verdana.ttf,16",
-		"small":"Verdana.ttf,14"
-	}
-}

+ 0 - 32
src/ted2/assets/themes/theme-blitzed.json

@@ -1,32 +0,0 @@
-{
-	"extends":"ted2-default",
-	
-	"colors":{
-
-		"content": "#345",
-		"clear": "#123",
-		"panel": "#456",
-		"gutter": "#234",
-		
-		"knob": "#567",
-		"hover": "#678",
-		"active" : "#789",
-		
-		"text-default": "#fff",
-		"text-highlight": "#ff0",
-		"text-disabled": "#89a",
-		"text-background": "#89a",
-		
-		"textview-cursor":"#08f",
-		"textview-selection":"#888",
-		
-		"textview-color0":"#0000",
-		"textview-color1":"#fff",
-		"textview-color2":"#ff0",
-		"textview-color3":"#0f8",
-		"textview-color4":"#0f8",
-		"textview-color5":"#0ff",
-		"textview-color6":"#fc0",
-		"textview-color7":"#fff"
-	}
-}

+ 0 - 32
src/ted2/assets/themes/theme-classic-dark.json

@@ -1,32 +0,0 @@
-{
-	"extends":"ted2-default",
-
-	"colors":{
-
-		"clear": "#181818",
-		"gutter": "#262626",
-		"content": "#323232",
-		"panel": "#4c4c4c",
-		
-		"knob": "#666666",
-		"hover": "#888888",
-		"active" : "#989898",
-		
-		"text-default": "#fff",
-		"text-highlight": "#ff0",
-		"text-disabled": "#888",
-		"text-background": "#888",
-		
-		"textview-cursor":"#08f",
-		"textview-selection":"#888",
-		
-		"textview-color0":"#0000",
-		"textview-color1":"#fff",
-		"textview-color2":"#ff0",
-		"textview-color3":"#0f8",
-		"textview-color4":"#0f8",
-		"textview-color5":"#0ff",
-		"textview-color6":"#fc0",
-		"textview-color7":"#fff"
-	}
-}

+ 0 - 41
src/ted2/assets/themes/theme-monkey1.json

@@ -1,41 +0,0 @@
-{
-	"extends":"ted2-default",
-
-	"colors":{
-
-		"content": "#ffffff",
-		"clear": "#e0e0e0",
-		"panel": "#e8e8e8",
-		"gutter": "#f0f0f0",
-		
-		"knob": "#cdcdcd",
-		"hover": "#a6a6a6",
-		"active" : "#606060",
-		
-		"text-default": "#222",
-		"text-highlight": "#484",
-		"text-disabled":  "#888",
-		"text-background": "#888",
-		
-		"textview-cursor":"#08f",
-		"textview-selection":"#888",
-		
-		"textview-color0": "#0000",
-		"textview-color1": "#222",	//identifiers
-		"textview-color2": "#26f",	//keywords
-		"textview-color3": "#282",	//strings
-		"textview-color4": "#228",	//numbers
-		"textview-color5": "#288",	//comment
-		"textview-color6": "#828",	//preproc
-		"textview-color7": "#222"	//default
-	},
-
-	"styles":{
-	
-		"TreeView":{
-			"backgroundColor":"content",
-			"icons":"treeview_icons.png",
-			"iconColor":"#aaa"
-		}
-	}
-}

+ 0 - 32
src/ted2/assets/themes/theme-overcast.json

@@ -1,32 +0,0 @@
-{
-	"extends":"ted2-default",
-	
-	"colors":{
-
-		"clear": "#989898",
-		"content": "#c8c8c8",
-		"panel": "#e8e8e8",
-		"gutter": "#a8a8a8",
-		
-		"knob": "#909090",
-		"hover": "#808080",
-		"active" : "#707070",
-		
-		"text-default": "#000",
-		"text-highlight": "#08f",
-		"text-disabled": "#444",
-		"text-background": "#444",
-		
-		"textview-cursor":"#08f",
-		"textview-selection":"#888",
-
-		"textview-color0":"#0000",
-		"textview-color1":"#000",
-		"textview-color2":"#008",
-		"textview-color3":"#080",
-		"textview-color4":"#080",
-		"textview-color5":"#808",
-		"textview-color6":"#840",
-		"textview-color7":"#000"
-	}
-}

+ 0 - 271
src/ted2/assets/themes/theme-smooth.json

@@ -1,271 +0,0 @@
-//Theme by Hezkore
-
-{
-	"extends":"ted2-default",
-
-	"styles":{
-
-		"ToolButton":{
-			"iconColor":"#FFF",
-			"skinColor":"panel",
-			"extends":"Button",
-			"padding":[2,0],
-			"margin":[3,0],
-
-			"states":{
-				"hover":{
-					"skinColor":"#9EBEFF"
-				},
-				"active":{
-					"skinColor":"#BED3FF"
-				},
-				"selected":{
-					"skinColor":"#9EBEFF"
-				}
-			}
-		},
-
-		"MainToolBar":{
-			"extends":"ToolBar",
-			"padding":[ 0 ],
-			"backgroundColor":"content",
-			"border":[ 0,1,0,1 ],
-			"borderColor":"border"
-		},
-
-		"EditorToolBar":{
-			"extends":"ToolBar",
-			"padding":[ 0 ],
-			"backgroundColor":"content",
-			"border":[1,0,1,1],
-			"borderColor":"border"
-		},
-
-		"MenuSeparator":{
-			"padding":[ 0,0,0,1 ],
-			"backgroundColor":"content",
-			"border":[ 8,8,7,7 ]
-		},
-
-		"Hint":{
-			"textColor":"text-highlight",
-			"skin":"smooth_assets/button_skin.png",
-			"skinColor":"#9EBEFF"
-		},
-
-		"TextView":{
-			"border":[1,0,1,1],
-			"borderColor":"border",
-			"font":"fixedWidth",
-			"backgroundColor":"content"
-		},
-
-		"GutterView":{
-			"border":[0],
-			"extends":"TextView",
-			"textColor":"text-disabled"
-		},
-
-		"TextViewContent":{
-			"padding":[4]
-		},
-
-		"Console":{
-			"border":[1,0,1,1],
-			"borderColor":"border",
-			"font":"small",
-			"backgroundColor":"content"
-		},
-
-		"ProgressBar":{
-			"icons":"smooth_assets/progressbar_icons.png"
-		},
-
-		"Button":{
-			"font":"small",
-			"extends":"Label",
-			"padding":[4,2],
-			"skin":"smooth_assets/button_skin.png",
-			"skinColor":"panel",
-
-			"states":{
-				"hover":{
-					"skinColor":"active"
-				},
-				"active":{
-					"skinColor":"knob"
-				},
-				"selected":{
-					"skinColor":"clear"
-				}
-			}
-		},
-
-		"Dialog":{
-			"skin":"smooth_assets/dialog_skin.png",
-			"skinColor":"panel"
-		},
-
-		"DialogTitle":{
-			"extends":"Label",
-			"backgroundColor":"knob"
-		},
-
-		"TreeView":{
-			"border":[1,0,1,0],
-			"borderColor":"border",
-			"backgroundColor":"content",
-			"icons":"smooth_assets/treeview_icons.png",
-			"iconColor":"#9DA5B4"
-		},
-
-		"TreeViewContent":{
-			"border":[0],
-			"padding":[4]
-		},
-
-		"TreeViewNode":{
-			"border":[0],
-			"padding":[3],
-			"font":"small",
-			"states":{
-				"hover":{
-					"backgroundColor":"#3F3F3F"
-				},
-				"selected":{
-					"backgroundColor":"#3F3F3F",
-					"textColor":"text-highlight"
-				}
-			}
-		},
-
-		"CheckBox":{
-			"icons":"smooth_assets/checkbox_icons.png",
-			"margin":[8,0,0,0]
-		},
-
-		"DockKnob":{
-			"padding":[2],
-			"backgroundColor":"gutter",
-			"states":{
-				"hover":{
-					"backgroundColor":"hover"
-				},
-				"active":{
-					"backgroundColor":"active"
-				}
-			}
-		},
-
-		"ScrollBar":{
-			"backgroundColor":"content"
-		},
-
-		"ScrollKnob":{
-			"border":[2],
-			"padding":[1],
-			"margin":[3],
-			"skin":"button_skin.png",
-			"skinColor":"knob",
-			"states":{
-				"hover":{
-					"skinColor":"knob",
-					"margin":[1]
-				},
-				"active":{
-					"skinColor":"active",
-					"margin":[0]
-				}
-			}
-		},
-
-		"ToolBar":{
-			"padding":[2,2,0,2],
-			"backgroundColor":"panel"
-		},
-
-		"TabBar":{
-			"border":[0,0,0,1],
-			"borderColor":"border",
-			"extends":"ToolBar",
-			"padding":[ 0,2,4,0 ],
-			"backgroundColor":"clear"
-		},
-
-		"TabButton":{
-			"extends":"Button",
-			"font":"small",
-			"padding":[16,5,16,5],
-			"margin":[1,0],
-			"backgroundColor":"#0000",
-			"skin":"smooth_assets/tabbutton_skin.png",
-			"skinColor":"gutter",
-			"textColor":"text-background",
-			"states":{
-				"hover":{
-					"skinColor":"gutter"
-				},
-				"active":{
-					"skinColor":"content"
-				},
-				"selected":{
-					"border":[2,0,0,0],
-					"borderColor":"#507FDF",
-					"skinColor":"content",
-					"textColor":"text-default"
-				}
-			}
-		},
-
-		"TabClose":{
-			"margin":[4,0,0,0],
-			"icons":"smooth_assets/tabclose_icons.png",
-			"iconColor":"#373737",
-			"states":{
-				"hover":{
-					"iconColor":"#D7DAE0"
-				},
-				"active":{
-					"iconColor":"#D7DAE0"
-				}
-			}
-		}
-
-	},
-
-	"colors":{
-		"border": "#171A1E",
-		"clear": "#21252B",
-		"gutter": "#21252B",
-		"content": "#282C34",
-		"panel": "#444B59",
-
-		"knob": "#575F6F",
-		"hover": "#444B59",
-		"active" : "#636C7F",
-
-		"text-default": "#C1CFD1",
-		"text-highlight": "#fff",
-		"text-disabled": "#4B5262",
-		"text-background": "#737883",
-
-		"textview-cursor":"#7BA4F8",
-		"textview-selection":"#3E4451",
-
-		//FF0000
-		"textview-color0":"#C358F5",
-		"textview-color1": "#6EA4F5",	//identifiers
-		"textview-color2": "#CF84EB",	//keywords
-		"textview-color3": "#7FE37F",	//strings
-		"textview-color4": "#FFB254",	//numbers
-		"textview-color5": "#6E7480",	//comment
-		"textview-color6": "#E06C72",	//preproc
-		"textview-color7": "#C358F5"	//default
-	},
-
-	"fonts":{
-		"normal":"DejaVuSans.ttf,16",
-		"fixedWidth":"DejaVuSans.ttf,15",
-		"small":"DejaVuSans.ttf,15"
-	}
-}

+ 0 - 8
src/ted2/assets/themes/themes.json

@@ -1,8 +0,0 @@
-{
-	"Classic dark":"theme-classic-dark",
-	"Overcast":"theme-overcast",
-	"Monkey 1":"theme-monkey1",
-	"Blitzed":"theme-blitzed",
-	"Basic Blue":"theme-Basic-Blue",
-	"Smooth":"theme-smooth"
-}

+ 0 - 185
src/ted2/audiodocument.monkey2

@@ -1,185 +0,0 @@
-
-Namespace ted2
-
-Private
-
-Class AudioDocumentView Extends View
-
-	Method New( doc:AudioDocument )
-		_doc=doc
-
-		Layout="fill"
-		
-		Style.BackgroundColor=App.Theme.GetColor( "content" )
-		
-		If Not _chan _chan=New Channel
-		
-		_toolBar=New ToolBar
-		_toolBar.Layout="float"
-		_toolBar.Gravity=New Vec2f( .5,1 )
-		
-		_toolBar.AddAction( "Play" ).Triggered=Lambda()
-			_chan.Play( _doc.Sound )
-		End
-		
-		_toolBar.AddAction( "Loop" ).Triggered=Lambda()
-			_chan.Play( _doc.Sound,True )
-		End
-		
-		_toolBar.AddAction( "Stop" ).Triggered=Lambda()
-			_chan.Stop()
-		End
-		
-		Local volbar:=New ScrollBar( Axis.X )
-		volbar.MinSize=New Vec2i( 64,0 )
-		volbar.Minimum=0
-		volbar.Maximum=100
-		volbar.PageSize=10
-		volbar.Value=_chan.Volume*100
-		volbar.ValueChanged+=Lambda( value:int )
-			_chan.Volume=value/100.0
-		End
-		Local vol:=New Label( "Volume " )
-		vol.AddView( volbar )
-		_toolBar.AddView( vol )
-		
-		Local panbar:=New ScrollBar( Axis.X )
-		panbar.MinSize=New Vec2i( 64,0 )
-		panbar.Minimum=-100
-		panbar.Maximum=+100
-		panbar.PageSize=10
-		panbar.Value=_chan.Pan*100
-		panbar.ValueChanged+=Lambda( value:Int )
-			_chan.Pan=value/100.0
-		End
-		Local pan:=New Label( "Pan " )
-		pan.AddView( panbar )
-		_toolBar.AddView( pan )
-		
-		AddChildView( _toolBar )
-	End
-	
-	Protected
-	
-	Method OnLayout() Override
-	
-		_toolBar.Frame=Rect
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-	
-		Local data:=_doc.Data
-		
-		canvas.BlendMode=BlendMode.Additive
-		
-		For Local chan:=0 Until 2
-		
-			canvas.Color=chan ? Color.Red else Color.Green
-		
-			Local last:=0.0
-		
-			For Local x:=0 Until Width
-			
-				Local sample:=data.GetSample( Float(x)/Width*data.Length,chan )
-				
-				Local p:=Height/2+(Height/4*sample)
-				
-				If x canvas.DrawLine( x-1,last,x,p )
-				
-				last=p
-			Next
-		
-		Next
-		
-	End
-	
-	Private
-	
-	Global _chan:Channel
-	
-	Global _volume:Int
-
-	Field _doc:AudioDocument
-	
-	Field _toolBar:ToolBar
-End
-
-Class AudioDocument Extends Ted2Document
-
-	Method New( path:String )
-		Super.New( path )
-		
-		_view=New AudioDocumentView( Self )
-	End
-	
-	Property Data:AudioData()
-	
-		Return _data
-	End
-	
-	Property Sound:Sound()
-	
-		If Not _sound _sound=New Sound( _data )
-		
-		Return _sound
-	End
-	
-	Protected
-	
-	Method OnLoad:Bool() Override
-	
-		_data=AudioData.Load( Path )
-		If Not _data Return False
-		
-		Return True
-	End
-	
-	Method OnSave:Bool() Override
-
-		Return False
-	End
-	
-	Method OnClose() Override
-	
-		If _sound _sound.Discard()
-		If _data _data.Discard()
-		
-		_sound=Null
-		_data=Null
-	End
-	
-	Method OnCreateView:AudioDocumentView() Override
-	
-		Return _view
-	End
-	
-	Private
-
-	Field _view:AudioDocumentView
-	
-	Field _data:AudioData
-	
-	Field _sound:Sound
-	
-End
-
-Class AudioDocumentType Extends Ted2DocumentType
-
-	Protected
-	
-	Method New()
-		AddPlugin( Self )
-		
-		Extensions=New String[]( ".wav",".ogg" )
-	End
-	
-	Method OnCreateDocument:Ted2Document( path:String ) Override
-	
-		Return New AudioDocument( path )
-	End
-	
-	Private
-	
-	Global _instance:=New AudioDocumentType
-	
-End

BIN
src/ted2/bin/wget.exe


+ 0 - 562
src/ted2/buildactions.monkey2

@@ -1,562 +0,0 @@
-
-Namespace ted2
-
-Class BuildError
-
-	Field path:String
-	Field line:Int
-	Field msg:String
-	Field removed:Bool
-	
-	Method New( path:String,line:Int,msg:String )
-		Self.path=path
-		Self.line=line
-		Self.msg=msg
-	End
-
-	Operator<=>:Int( err:BuildError )
-		If line<err.line Return -1
-		If line>err.line Return 1
-		Return 0
-	End
-	
-End
-
-Class BuildActions
-
-	Field buildAndRun:Action
-	Field build:Action
-	Field semant:Action
-	Field buildSettings:Action
-	Field nextError:Action
-	Field lockBuildFile:Action
-	Field updateModules:Action
-	Field rebuildModules:Action
-	Field moduleManager:Action
-	Field rebuildHelp:Action
-	
-	Field targetMenu:Menu
-	
-	Method New( docs:DocumentManager,console:Console,debugView:DebugView )
-	
-		_docs=docs
-		_console=console
-		_debugView=debugView
-		
-		_docs.DocumentRemoved+=Lambda( doc:Ted2Document )
-
-			If doc=_locked _locked=Null
-		End
-		
-		buildAndRun=New Action( "Build and run" )
-		buildAndRun.Triggered=OnBuildAndRun
-		buildAndRun.HotKey=Key.F5
-
-		build=New Action( "Build only" )
-		build.Triggered=OnBuild
-		build.HotKey=Key.F6
-		
-		semant=New Action( "Check app" )
-		semant.Triggered=OnSemant
-		semant.HotKey=Key.F7
-		
-		buildSettings=New Action( "Target settings" )
-		buildSettings.Triggered=OnBuildFileSettings
-		
-		nextError=New Action( "Next build error" )
-		nextError.Triggered=OnNextError
-		nextError.HotKey=Key.F4
-		
-		lockBuildFile=New Action( "Lock build file" )
-		lockBuildFile.Triggered=OnLockBuildFile
-		lockBuildFile.HotKey=Key.L
-		lockBuildFile.HotKeyModifiers=Modifier.Menu
-		
-		updateModules=New Action( "Update modules" )
-		updateModules.Triggered=OnUpdateModules
-		updateModules.HotKey=Key.U
-		updateModules.HotKeyModifiers=Modifier.Menu
-		
-		rebuildModules=New Action( "Rebuild modules" )
-		rebuildModules.Triggered=OnRebuildModules
-		rebuildModules.HotKey=Key.U
-		rebuildModules.HotKeyModifiers=Modifier.Menu|Modifier.Shift
-		
-		moduleManager=New Action( "Module manager" )
-		moduleManager.Triggered=OnModuleManager
-		
-		rebuildHelp=New Action( "Rebuild documentation" )
-		rebuildHelp.Triggered=OnRebuildHelp
-		
-		local group:=New CheckGroup
-		_debugConfig=New CheckButton( "Debug",,group )
-		_debugConfig.Layout="fill-x"
-		_releaseConfig=New CheckButton( "Release",,group )
-		_releaseConfig.Layout="fill-x"
-		_debugConfig.Clicked+=Lambda()
-			_buildConfig="debug"
-		End
-		_releaseConfig.Clicked+=Lambda()
-			_buildConfig="release"
-		End
-		_buildConfig="debug"
-
-		group=New CheckGroup
-
-		_desktopTarget=New CheckButton( "Desktop",,group )
-		_desktopTarget.Layout="fill-x"
-		
-		_emscriptenTarget=New CheckButton( "Emscripten",,group )
-		_emscriptenTarget.Layout="fill-x"
-		
-		_androidTarget=New CheckButton( "Android",,group )
-		_androidTarget.Layout="fill-x"
-		
-		_iosTarget=New CheckButton( "iOS",,group )
-		_iosTarget.Layout="fill-x"
-		
-		targetMenu=New Menu( "Build target..." )
-		targetMenu.AddView( _debugConfig )
-		targetMenu.AddView( _releaseConfig )
-		targetMenu.AddSeparator()
-		targetMenu.AddView( _desktopTarget )
-		targetMenu.AddView( _emscriptenTarget )
-		targetMenu.AddView( _androidTarget )
-		targetMenu.AddView( _iosTarget )
-		targetMenu.AddSeparator()
-		targetMenu.AddAction( buildSettings )
-		
-		'check valid targets...WIP...
-		
-		_validTargets=EnumValidTargets( _console )
-		
-		If _validTargets _buildTarget=_validTargets[0].ToLower()
-		
-		If _validTargets.Contains( "desktop" )
-			_desktopTarget.Clicked+=Lambda()
-				_buildTarget="desktop"
-			End
-		Else
-			_desktopTarget.Enabled=False
-		Endif
-		
-		If _validTargets.Contains( "emscripten" )
-			_emscriptenTarget.Clicked+=Lambda()
-				_buildTarget="emscripten"
-			End
-		Else
-			_emscriptenTarget.Enabled=False
-		Endif
-
-		If _validTargets.Contains( "android" )
-			_androidTarget.Clicked+=Lambda()
-				_buildTarget="android"
-			End
-		Else
-			_androidTarget.Enabled=False
-		Endif
-
-		If _validTargets.Contains( "ios" )
-			_iosTarget.Clicked+=Lambda()
-				_buildTarget="ios"
-			End
-		Else
-			_iosTarget.Enabled=False
-		Endif
-	End
-	
-	Method SaveState( jobj:JsonObject )
-		
-		If _locked jobj["lockedDocument"]=New JsonString( _locked.Path )
-		
-		jobj["buildConfig"]=New JsonString( _buildConfig )
-		
-		jobj["buildTarget"]=New JsonString( _buildTarget )
-	End
-		
-	Method LoadState( jobj:JsonObject )
-	
-		If jobj.Contains( "lockedDocument" )
-			Local path:=jobj["lockedDocument"].ToString()
-			_locked=Cast<Monkey2Document>( _docs.FindDocument( path ) )
-			If _locked _locked.State="+"
-		Endif
-		
-		If jobj.Contains( "buildConfig" )
-			_buildConfig=jobj["buildConfig"].ToString()
-			Select _buildConfig
-			Case "release"
-				_releaseConfig.Checked=True
-			Default
-				_debugConfig.Checked=True
-				_buildConfig="debug"
-			End
-		Endif
-		
-		If jobj.Contains( "buildTarget" )
-					
-			local target:=jobj["buildTarget"].ToString()
-
-			If _validTargets.Contains( target )
-			
-				 _buildTarget=target
-				
-				Select _buildTarget
-				Case "desktop"
-					_desktopTarget.Checked=True
-				Case "emscripten"
-					_emscriptenTarget.Checked=True
-				Case "android"
-					_androidTarget.Checked=True
-				Case "ios"
-					_iosTarget.Checked=True
-				End
-			
-			Endif
-			
-		Endif
-		
-	End
-	
-	Method Update()
-	
-		While Not _errors.Empty And _errors.First.removed
-			_errors.RemoveFirst()
-		Wend
-	
-		Local idle:=Not _console.Running
-		Local canbuild:=idle And BuildDoc()<>Null And _buildTarget
-		
-		build.Enabled=canbuild
-		buildAndRun.Enabled=canbuild
-		nextError.Enabled=Not _errors.Empty
-		updateModules.Enabled=idle
-		rebuildModules.Enabled=idle
-		rebuildHelp.Enabled=idle
-		moduleManager.Enabled=idle
-	End
-
-	Private
-	
-	Field _docs:DocumentManager
-	Field _console:Console
-	Field _debugView:DebugView
-	
-	Field _locked:Monkey2Document
-	
-	Field _errors:=New List<BuildError>
-	
-	Field _buildConfig:String
-	Field _buildTarget:String
-	
-	Field _debugConfig:CheckButton
-	Field _releaseConfig:CheckButton
-	Field _desktopTarget:CheckButton
-	Field _emscriptenTarget:CheckButton
-	Field _androidTarget:CheckButton
-	Field _iosTarget:CheckButton
-	
-	Field _validTargets:StringStack
-	
-	Method BuildDoc:Monkey2Document()
-		
-		If Not _locked Return Cast<Monkey2Document>( _docs.CurrentDocument )
-		
-		Return _locked
-	End
-	
-	Method SaveAll:Bool()
-	
-		For Local doc:=Eachin _docs.OpenDocuments
-			If Not doc.Save() Return False
-		Next
-		
-		Return True
-	End
-	
-	Method ClearErrors()
-	
-		_errors.Clear()
-	
-		For Local doc:=Eachin _docs.OpenDocuments
-			Local mx2Doc:=Cast<Monkey2Document>( doc )
-			If mx2Doc mx2Doc.Errors.Clear()
-		Next
-
-	End
-
-	Method GotoError( err:BuildError )
-	
-		Local doc:=Cast<Monkey2Document>( _docs.OpenDocument( err.path,True ) )
-		If Not doc Return
-		
-		Local tv:=Cast<TextView>( doc.View )
-		If Not tv Return
-		
-		MainWindow.UpdateWindow( False )
-		
-		tv.GotoLine( err.line )
-	End
-	
-	Method BuildMx2:Bool( cmd:String,progressText:String )
-	
-		ClearErrors()
-		
-		_console.Clear()
-		
-		MainWindow.ShowBuildConsole( False )
-		
-		If Not SaveAll() Return False
-
-		If Not _console.Start( cmd )
-			Alert( "Failed to start process: '"+cmd+"'" )
-			Return False
-		Endif
-		
-		Local progress:=New ProgressDialog( "Building",progressText )
-		
-		progress.MinSize=New Vec2i( 320,0 )
-		
-		Local cancel:=progress.AddAction( "Cancel" )
-		
-		cancel.Triggered=Lambda()
-			_console.Terminate()
-		End
-		
-		progress.Open()
-		
-		Repeat
-		
-			Local stdout:=_console.ReadStdout()
-			If Not stdout Exit
-			
-			If stdout.StartsWith( "Application built:" )
-
-'				_appFile=stdout.Slice( stdout.Find( ":" )+1 ).Trim()
-			Else
-			
-				Local i:=stdout.Find( "] : Error : " )
-				If i<>-1
-					Local j:=stdout.Find( " [" )
-					If j<>-1
-						Local path:=stdout.Slice( 0,j )
-						Local line:=Int( stdout.Slice( j+2,i ) )-1
-						Local msg:=stdout.Slice( i+12 )
-						
-						Local err:=New BuildError( path,line,msg )
-						Local doc:=Cast<Monkey2Document>( _docs.OpenDocument( path,False ) )
-						
-						If doc
-							doc.Errors.Add( err )
-							If _errors.Empty 
-								MainWindow.ShowBuildConsole( True )
-								GotoError( err )
-							Endif
-							_errors.Add( err )
-						Endif
-						
-					Endif
-				Endif
-			Endif
-			
-			_console.Write( stdout )
-		
-		Forever
-		
-		progress.Close()
-		
-		Return _console.ExitCode=0
-	End
-
-	Method BuildModules:Bool( clean:Bool,target:String )
-	
-		Local msg:=(clean ? "Rebuilding " Else "Updating ")+target
-		
-		For Local config:=0 Until 2
-		
-			Local cfg:=(config ? "debug" Else "release")
-			
-			Local cmd:=MainWindow.Mx2ccPath+" makemods -target="+target
-			If clean cmd+=" -clean"
-			cmd+=" -config="+cfg
-			
-			If Not BuildMx2( cmd,msg+" "+cfg+" modules..." ) Return False
-		Next
-		
-		Return True
-	End
-	
-	Method BuildModules:Bool( clean:Bool )
-	
-		Local targets:=New StringStack
-		
-		For Local target:=Eachin _validTargets
-			targets.Push( target="ios" ? "iOS" Else target.Capitalize() )
-		Next
-
-		targets.Push( "All!" )
-		targets.Push( "Cancel" )
-		
-		Local i:=TextDialog.Run( "Build Modules","Select target..",targets.ToArray(),0,targets.Length-1 )
-		
-		Local result:=True
-		
-		Select i
-		Case targets.Length-1	'Cancel
-			Return False
-		Case targets.Length-2	'All!
-			For Local i:=0 Until targets.Length-2
-				If BuildModules( clean,targets[i] ) Continue
-				result=False
-				Exit
-			Next
-		Default
-			result=BuildModules( clean,targets[i] )
-		End
-		
-		If result
-			_console.Write( "~nBuild modules completed successfully!~n" )
-		Else
-			_console.Write( "~nBuild modules failed.~n" )
-		Endif
-		
-		Return result
-	End
-	
-	Method MakeDocs:Bool()
-	
-		Return BuildMx2( MainWindow.Mx2ccPath+" makedocs","Rebuilding documentation..." )
-	End
-	
-	Method BuildApp:Bool( config:String,target:String,action:String )
-
-		If _console.Running Return False
-
-		_debugView.KillApp()
-	
-		Local buildDoc:=BuildDoc()
-		If Not buildDoc Return False
-		
-		Local product:=BuildProduct.GetBuildProduct( buildDoc.Path,target,False )
-		If Not product Return False
-		
-		Local opts:=product.GetMx2ccOpts()
-		
-		Local run:=(action="run")
-		If run action="build"
-
-		Local cmd:=MainWindow.Mx2ccPath+" makeapp -"+action+" "+opts
-		cmd+=" -config="+config
-		cmd+=" -target="+target
-		cmd+=" ~q"+buildDoc.Path+"~q"
-		
-		Local msg:="Building "+StripDir( buildDoc.Path )+" for "+target+" "+config
-		
-		If Not BuildMx2( cmd,msg ) Return False
-		
-		If Not run Return True
-		
-		Local exeFile:=product.GetExecutable()
-		If Not exeFile Return True
-		
-		Select target
-		Case "desktop"
-
-			_debugView.DebugApp( exeFile,config )
-
-		Case "emscripten"
-		
-			Local mserver:=GetEnv( "MX2_MSERVER" )
-			If mserver _console.Run( mserver+" ~q"+exeFile+"~q" )
-		
-		End
-		
-		Return True
-	End
-	
-	Method OnBuildAndRun()
-
-		BuildApp( _buildConfig,_buildTarget,"run" )
-	End
-	
-	Method OnBuild()
-	
-		BuildApp( _buildConfig,_buildTarget,"build" )
-	End
-	
-	Method OnSemant()
-	
-		BuildApp( _buildConfig,_buildTarget,"semant" )
-	End
-	
-	Method OnNextError()
-	
-		While Not _errors.Empty And _errors.First.removed
-			_errors.RemoveFirst()
-		Wend
-		
-		If _errors.Empty Return
-		
-		_errors.AddLast( _errors.RemoveFirst() )
-			
-		GotoError( _errors.First )
-	End
-	
-	Method OnLockBuildFile()
-	
-		Local doc:=Cast<Monkey2Document>( _docs.CurrentDocument )
-		If Not doc Return
-		
-		If _locked _locked.State=""
-		
-		If doc=_locked
-			_locked=Null
-			Return
-		Endif
-		
-		_locked=doc
-		_locked.State="+"
-		
-	End
-	
-	Method OnBuildFileSettings()
-
-		Local buildDoc:=BuildDoc()
-		If Not buildDoc Return
-		
-		local product:=BuildProduct.GetBuildProduct( buildDoc.Path,_buildTarget,True )
-	End
-	
-	Method OnUpdateModules()
-	
-		If _console.Running Return
-	
-		BuildModules( False )
-	End
-	
-	Method OnRebuildModules()
-	
-		If _console.Running Return
-	
-		BuildModules( True )
-	End
-	
-	Method OnModuleManager()
-	
-		If _console.Running Return
-	
-		Local modman:=New ModuleManager( _console )
-		
-		modman.Open()
-	End
-	
-	Method OnRebuildHelp()
-	
-		If _console.Running Return
-	
-		MakeDocs()
-		
-		MainWindow.UpdateHelpTree()
-	End
-	
-End

+ 0 - 581
src/ted2/buildproduct.monkey2

@@ -1,581 +0,0 @@
-
-Namespace ted2
-
-Class BuildProduct
-
-	Property AppName:String()
-	
-		Return _appName
-	End
-
-	Property ProductDir:String()
-
-		Return _productDir
-	End
-
-	Method GetMx2ccOpts:String()
-	
-		Return OnGetMx2ccOpts()
-	End
-	
-	Method GetExecutable:String()
-	
-		Return OnGetExecutable()
-	End
-	
-	Function GetBuildProduct:BuildProduct( srcPath:String,target:String,edit:Bool )
-	
-		Local product:BuildProduct
-		
-		Select target
-		Case "desktop"
-#if __TARGET__="windows"
-			product=New WindowsProduct( srcPath )
-#else if __TARGET__="macos"
-			product=New MacosProduct( srcPath )
-#else if __TARGET__="linux" Or __TARGET__="raspbian"
-			product=New LinuxProduct( srcPath )
-#endif
-		Case "emscripten"
-			product=New EmscriptenProduct( srcPath )
-		Case "android"
-			product=New AndroidProduct( srcPath )
-		Case "ios"
-			product=New IosProduct( srcPath )
-		End
-		
-		If Not product Return Null
-		
-		product.LoadVars()
-
-		If GetFileType( product.ProductDir )=FileType.Directory
-		
-			If edit And Not product.EditVars() Return Null
-			
-		Else
-
-			If Not product.EditVars() Return Null
-			
-		Endif
-		
-		If GetFileType( product.ProductDir )<>FileType.Directory
-		
-			If Not CreateDir( product.ProductDir )
-				Alert( "Failed to create product directory '"+product.ProductDir+"'" )
-				Return Null
-			Endif
-			
-			product.OnCreateProduct()
-
-		Endif
-		
-		Return product
-	End
-
-	Protected
-	
-	Method New( srcPath:String,target:String )
-	
-		_srcPath=srcPath
-		_target=target
-		_appName=StripDir( StripExt( srcPath ) ).Capitalize()
-		_productsDir=StripExt( _srcPath )+".products/"
-		_productDir=_productsDir+(target="ios" ? "iOS" Else target.Capitalize())+"/"
-		
-		AddVar( "Application Name",_appName )
-	End
-	
-	Method OnCreateProduct() Virtual
-	End
-	
-	Method OnGetMx2ccOpts:String() Virtual
-		Return ""
-	End
-	
-	Method OnGetExecutable:String() Virtual
-		Return ""
-	End
-	
-	Method AddExts( exts:String[] )
-	
-		For Local ext:=Eachin exts
-			_exts[ext]=True
-		Next
-	End
-	
-	Method AddVar( name:String,value:String,type:String="string" )
-	
-		_pvars.Push( New ProductVar( name,value,type ) )
-	End
-	
-	Method GetVar:String( name:String )
-	
-		Return _vars[name]
-	End
-	
-	Method ReplaceVars:String( src:String )
-	
-		Local i0:=0
-		
-		Repeat
-			Local i1:=src.Find( "${",i0 )
-			If i1=-1 Exit
-			
-			Local i2:=src.Find( "}",i1+2 )
-			If i2=-1 Exit
-			
-			Local id:=src.Slice( i1+2,i2 )
-			If Not _vars.Contains( id )
-				i0=i2+1
-				Continue
-			Endif
-			
-			Local r:=_vars[id]
-			src=src.Slice( 0,i1 )+r+src.Slice( i2+1 )
-			i0=i1+r.Length
-		Forever
-
-		Return src
-		
-	End
-	
-	Method CopyTemplate:Bool( src:String,dst:String )
-
-		Select GetFileType( src )
-		
-		Case FileType.File
-		
-			If _exts.Contains( ExtractExt( src ).ToLower() )
-			
-				Local tmp:=LoadString( src )
-				
-				tmp=ReplaceVars( tmp )
-				
-				If Not SaveString( tmp,dst ) Return False
-			
-			Else
-			
-				If Not CopyFile( src,dst ) Return False
-		
-			Endif
-			
-		Case FileType.Directory
-		
-			If Not CreateDir( dst ) Return False
-		
-			For Local f:=Eachin LoadDir( src )
-			
-				If Not CopyTemplate( src+"/"+f,dst+"/"+f ) Return False
-
-			Next
-				
-		End
-		
-		Return true
-	End
-
-	Private
-
-	Field _srcPath:String
-	Field _target:String
-	Field _appName:String
-	Field _productDir:String
-	Field _productsDir:String
-	Field _exts:=New StringMap<Bool>
-	Field _vars:=New StringMap<String>
-	Field _pvars:=New Stack<ProductVar>
-	
-	Method EditVars:Bool()
-	
-		Local save:=New StringMap<String>
-		
-		For Local pvar:=Eachin _pvars
-			save[pvar.name]=pvar.value
-		End
-	
-		Local opts:=New EditProductDialog( "Build settings for "+StripDir( _srcPath )+" for "+_target.Capitalize()+" target ",_pvars )
-		
-		If Not opts.Run()
-			For Local pvar:=Eachin _pvars
-				pvar.value=save[pvar.name]
-			Next
-			Return False
-		Endif
-		
-		UpdateVars()
-		
-		Local changed:Bool
-		For Local pvar:=Eachin _pvars
-			If pvar.value=save[pvar.name] Continue
-			changed=True
-			Exit
-		Next
-		
-		Local fail:=False
-		
-		If changed And GetFileType( ProductDir )=FileType.Directory
-			Select TextDialog.Run( "Edit Build Settings","Directory at '"+ProductDir+"' already exists.",New String[]( "Overwrite","Cancel" ) )
-			Case 0
-				If Not DeleteDir( ProductDir,True )
-					Alert( "Failed to delete directory '"+ProductDir+"'" )
-					fail=True
-				Endif
-			Case 1
-				fail=True
-			End
-		Endif
-		
-		If fail
-			For Local pvar:=Eachin _pvars
-				pvar.value=save[pvar.name]
-			Next
-			UpdateVars()
-			Return False
-		Endif
-		
-		SaveVars()
-		Return True
-	End
-
-	Method FindVar:ProductVar( name:String )
-	
-		For Local pvar:=Eachin _pvars
-			If pvar.name=name Return pvar
-		Next
-		
-		Return Null
-	End
-	
-	Method SaveVars( jobj:JsonObject )
-	
-		For Local pvar:=Eachin _pvars
-			jobj[pvar.name]=New JsonString( pvar.value )
-		Next
-
-	End
-	
-	Method LoadVars( jobj:JsonObject )
-	
-		For Local it:=Eachin jobj.ToObject()
-			Local pvar:=FindVar( it.Key )
-			If pvar pvar.value=it.Value.ToString()
-		Next
-
-		UpdateVars()
-	End
-	
-	Method UpdateVars()
-
-		_vars.Clear()
-
-		For Local pvar:=Eachin _pvars
-			Local id:=pvar.name.ToUpper().Replace( " ","_" )
-			_vars[id]=pvar.value
-		Next
-		
-		_appName=GetVar( "APPLICATION_NAME" )
-	End
-	
-	Method SaveVars()
-	
-		Local jprods:=JsonObject.Load( _productsDir+"products.json" )
-		If Not jprods jprods=New JsonObject
-		
-		Local jvars:=New JsonObject
-		SaveVars( jvars )
-		
-		jprods[_target]=jvars
-		
-		CreateDir( _productsDir )
-		SaveString( jprods.ToJson(),_productsDir+"products.json" )
-	End
-	
-	Method LoadVars()
-		
-		Local jprods:=JsonObject.Load( _productsDir+"products.json" )
-		If Not jprods Return
-		
-		Local jvars:=Cast<JsonObject>( jprods[_target] )
-		If jvars LoadVars( jvars )
-	End
-	
-End
-
-Class DesktopProduct Extends BuildProduct
-
-	Method New( srcPath:String,target:String )
-		Super.New( srcPath,target )
-		
-		AddVar( "Application Type","gui","options:gui|console" )
-	End
-	
-	Protected
-
-	Method OnCreateProduct() Override
-	
-		CreateDir( ProductDir+"assets" )
-	End
-	
-	Method OnGetMx2ccOpts:String() Override
-
-		Local appType:=GetVar( "APPLICATION_TYPE" )
-		
-		Local opts:=""
-		opts+=" ~q-product="+ProductDir+AppName+"~q"
-		opts+=" -apptype="+appType
-		
-		Return opts
-	End
-	
-End
-
-Class WindowsProduct Extends DesktopProduct
-
-	Method New( srcPath:String )
-		Super.New( srcPath,"windows" )
-	End
-
-	Method OnGetMx2ccOpts:String() Override
-
-		Local appType:=GetVar( "APPLICATION_TYPE" )
-		
-		Local opts:=""
-		opts+=" ~q-product="+ProductDir+AppName+"~q"
-		opts+=" -apptype="+appType
-		
-		Return opts
-	End
-	
-	Method OnGetExecutable:String() Override
-
-		Return ProductDir+AppName+".exe"
-	End
-
-End
-
-Class MacosProduct Extends DesktopProduct
-
-	Method New( srcPath:String )
-
-		Super.New( srcPath,"macos" )
-	End
-	
-	Protected
-	
-	Method OnCreateProduct() Override
-	
-		Local appType:=GetVar( "APPLICATION_TYPE" )
-		
-		If appType<>"gui"
-			CreateDir( ProductDir+"assets" )
-			Return
-		Endif
-
-		Local appDir:=ProductDir+AppName+".app/"
-
-		CreateDir( appDir )
-		CreateDir( appDir+"Contents" )
-		CreateDir( appDir+"Contents/MacOS" )
-		CreateDir( appDir+"Contents/Resources" )
-					
-		Local plist:=""
-		plist+="<?xml version=~q1.0~q encoding=~qUTF-8~q?>~n"
-		plist+="<!DOCTYPE plist PUBLIC ~q-//Apple Computer//DTD PLIST 1.0//EN~q ~qhttp://www.apple.com/DTDs/PropertyList-1.0.dtd~q>~n"
-		plist+="<plist version=~q1.0~q>~n"
-		plist+="<dict>~n"
-		plist+="~t<key>CFBundleExecutable</key>~n"
-		plist+="~t<string>"+AppName+"</string>~n"
-		plist+="~t<key>CFBundleIconFile</key>~n"
-		plist+="~t<string>"+AppName+"</string>~n"
-		plist+="~t<key>CFBundlePackageType</key>~n"
-		plist+="~t<string>APPL</string>~n"
-		plist+="~t<key>NSHighResolutionCapable</key> <true/>~n"
-		plist+="</dict>~n"
-		plist+="</plist>~n"
-					
-		SaveString( plist,appDir+"Contents/Info.plist" )
-	End
-	
-	Method OnGetExecutable:String() Override
-
-		Local appType:=GetVar( "APPLICATION_TYPE" )
-		
-		If appType<>"gui" Return ProductDir+AppName
-
-		Return ProductDir+AppName+".app/Contents/MacOS/"+AppName
-	End
-
-End
-
-Class LinuxProduct Extends DesktopProduct
-
-	Method New( srcPath:String )
-#if __TARGET__="linux"
-		Super.New( srcPath,"linux" )
-#Else
-		Super.New( srcPath,"raspbian" )
-#Endif
-	End
-
-	Protected
-	
-	Method OnGetExecutable:String() Override
-
-		Return ProductDir+AppName
-	End
-	
-End
-
-Class EmscriptenProduct Extends BuildProduct
-
-	Method New( srcPath:String )
-		Super.New( srcPath,"emscripten" )
-
-		AddExts( New String[]( ".html" ) )
-		
-		AddVar( "Application Type","wasm","options:wasm|wasm+asmjs|asmjs" )
-	End
-	
-	Protected
-	
-	Method OnCreateProduct() Override
-
-		CopyTemplate( "products/emscripten",StripSlashes( ProductDir ) )
-		
-		CreateDir( ProductDir+"assets" )
-		
-		If AppName<>"Monkey2Game"
-		
-			CopyFile( ProductDir+"Monkey2Game.html",ProductDir+AppName+".html" )
-		
-			DeleteFile( ProductDir+"Monkey2Game.html" )
-		Endif
-	End
-	
-	Method OnGetMx2ccOpts:String() Override
-
-		Local appType:=GetVar( "APPLICATION_TYPE" )
-
-		Local opts:=""
-		
-		opts+=" ~q-product="+ProductDir+AppName+".js~q"
-		opts+=" -apptype="+appType
-
-		Return opts
-	End
-
-	Method OnGetExecutable:String() Override
-
-		Return ProductDir+AppName+".html"
-	
-	End
-End
-
-#rem
-Class WasmProduct Extends BuildProduct
-
-	Method New( srcPath:String )
-		Super.New( srcPath,"wasm" )
-
-		AddExts( New String[]( ".html" ) )
-	End
-	
-	Protected
-	
-	Method OnCreateProduct() Override
-
-		CopyTemplate( "products/wasm",StripSlashes( ProductDir ) )
-		
-		CreateDir( ProductDir+"assets" )
-		
-		If AppName<>"Monkey2Game"
-		
-			CopyFile( ProductDir+"Monkey2Game.html",ProductDir+AppName+".html" )
-		
-			DeleteFile( ProductDir+"Monkey2Game.html" )
-		Endif
-	End
-	
-	Method OnGetMx2ccOpts:String() Override
-
-		Local opts:=""
-		
-		opts+=" ~q-product="+ProductDir+AppName+".js~q"
-		
-		Return opts
-	End
-
-	Method OnGetExecutable:String() Override
-
-		Return ProductDir+AppName+".html"
-	
-	End
-End
-#end
-
-Class AndroidProduct Extends BuildProduct
-
-	Method New( srcPath:String )
-		Super.New( srcPath,"android" )
-		
-		AddExts( New String[]( ".xml",".java",".gradle" ) )
-		
-		AddVar( "Package Name","com.monkey2.monkey2game" )
-		AddVar( "Activity Name","Monkey2Game" )
-	End
-
-	Protected
-	
-	Method OnCreateProduct() Override
-
-		Local packageName:=GetVar( "PACKAGE_NAME" )
-		Local activityName:=GetVar( "ACTIVITY_NAME" )
-		
-		Local mainDir:=ProductDir+"app/src/main/"
-		Local packageDir:=mainDir+"java/"+packageName.Replace( ".","/" )+"/"
-		
-		CopyTemplate( "products/android/Monkey2Game",StripSlashes( ProductDir ) )
-
-		CreateDir( packageDir )
-		CopyFile( mainDir+"Monkey2Game.java",packageDir+activityName+".java" )
-		DeleteFile( mainDir+"Monkey2Game.java" )
-	
-	End
-	
-	Method OnGetMx2ccOpts:String() Override
-
-		Local opts:=""
-		opts+=" ~q-product="+ProductDir+"~q"
-		
-		Return opts
-	End
-	
-End
-
-Class IosProduct Extends BuildProduct
-
-	Method New( srcPath:String )
-		Super.New( srcPath,"ios" )
-		
-		AddExts( New String[]( ".pbxproj" ) )
-	End
-	
-	Method OnCreateProduct() Override
-
-		CopyTemplate( "products/ios",StripSlashes( ProductDir ) )
-		
-		If AppName<>"Monkey2Game"
-			libc.rename( ProductDir+"Monkey2Game.xcodeproj",ProductDir+AppName+".xcodeproj" )
-		Endif
-	End
-	
-	Method OnGetMx2ccOpts:String() Override
-	
-		Local opts:=""
-		opts+=" ~q-product="+ProductDir+"~q"
-		
-		Return opts
-	End
-	
-
-End

+ 0 - 464
src/ted2/debugview.monkey2

@@ -1,464 +0,0 @@
-
-Namespace ted2
-
-Class DebugView Extends DockingView
-
-	Method New( docs:DocumentManager,console:Console )
-	
-		_docs=docs
-		_console=console
-		
-		'FIXME: this will never get removed...
-		_console.Finished+=Lambda( exitCode:Int )
-			If Not _debugging Return
-			
-			If _stopped Resume()
-		End
-
-		_toolBar=New ToolBar
-		_toolBar.Style=GetStyle( "DebugToolBar" )
-		Local icons:=_toolBar.Style.Icons
-		
-		'run/pause
-		_run=_toolBar.AddAction( "",icons[2] )
-		_run.Triggered=Lambda()
-			If Not _debugging Return
-		
-			If _stopped
-				_console.WriteStdin( "r~n" )
-				Resume()
-			Else
-				_console.Process.SendBreak()
-			Endif
-		
-		End
-
-		'step over		
-		_step=_toolBar.AddAction( "",icons[3] )
-		_step.Triggered=Lambda()
-			If Not _debugging Return
-			
-			If _stopped
-				_console.WriteStdin( "s~n" )
-				Resume()
-			Endif
-			
-		End
-		
-		'step into
-		_enter=_toolBar.AddAction( "",icons[4] )
-		_enter.Triggered=Lambda()
-			If Not _debugging Return
-		
-			If _stopped
-				_console.WriteStdin( "e~n" )
-				Resume()
-			Endif
-			
-		End
-
-		'step out
-		_leave=_toolBar.AddAction( "",icons[5] )
-		_leave.Triggered=Lambda()
-			If Not _debugging Return
-		
-			If _stopped
-				_console.WriteStdin( "l~n" )
-				Resume()
-			Endif
-			
-		End
-		
-		'kill
-		_kill=_toolBar.AddAction( "",icons[1] )
-		_kill.Triggered=Lambda()
-			If Not _debugging Return
-		
-			If _stopped
-				_console.WriteStdin( "q~n" )
-				Resume()
-			Else
-				_console.Process.SendBreak()
-				_killme=True
-			Endif
-		
-		End
-		
-		AddView( _toolBar,"top" )
-		
-		_tree=New TreeView
-		_tree.RootNodeVisible=False
-		_tree.RootNode.Expanded=True
-		
-		_tree.NodeClicked=Lambda( tnode:TreeView.Node )
-		
-			Local node:=Cast<Node>( tnode )
-			If Not node Return
-			
-			If node.srcFile
-			
-				Local doc:=Cast<Monkey2Document>( _docs.OpenDocument( node.srcFile,True ) )
-				If Not doc Return
-				
-				MainWindow.UpdateWindow( False )
-
-				doc.DebugLine=node.srcLine-1
-			Endif
-		
-		End
-		
-		_tree.NodeExpanded=Lambda( tnode:TreeView.Node )
-			If Not _stopped Return
-			
-			Local node:=Cast<Node>( tnode )
-			If Not node Or Not node.scope Return
-			
-			New Fiber( Lambda()
-				UpdateExpanded( node )
-			End )
-		End
-		
-		ContentView=New ScrollView( _tree )
-		
-		UpdateActions()
-	End
-	
-	Method DebugApp( appFile:String,config:String )
-	
-		If _console.Running Return
-
-		_console.Clear()
-			
-		MainWindow.ShowOutputConsole()
-	
-		Local cmd:="~q"+RealPath( appFile )+"~q"
-		
-		If config<>"debug"
-		
-			_console.Run( cmd )
-			
-			_console.Write( "~nFinished running app.~n" )
-			
-			MainWindow.UpdateKeyView()
-			
-			Return
-		End
-		
-		If Not _console.Start( cmd )
-			Alert( "Failed to start process: '"+cmd+"'" )
-			Return
-		Endif
-		
-		DebugBegin()
-		
-		Repeat
-			
-			Local stdout:=_console.ReadStdout()
-			If Not stdout Exit
-			
-			If stdout="{{!DEBUG!}}~n"
-				DebugStop()
-				Continue
-			End
-			
-			_console.Write( stdout )
-		
-		Forever
-		
-		DebugEnd()
-		
-		For Local doc:=Eachin _docs.OpenDocuments
-			Local mx2Doc:=Cast<Monkey2Document>( doc )
-			If mx2Doc mx2Doc.DebugLine=-1
-		Next
-			
-		_console.Write( "~nFinished debugging app.~n" )
-		
-		MainWindow.UpdateKeyView()
-	End
-	
-	Method KillApp()
-		
-		_kill.Trigger()
-	End
-
-	Private
-		
-	Class Node Extends TreeView.Node
-
-		Field srcFile:String
-		Field srcLine:Int
-		Field seq:Int
-		
-		Field name:String
-		Field type:String
-		Field value:String
-		Field scope:Bool
-	
-		Method New( label:String,parent:TreeView.Node=Null,seq:Int=0,index:Int=-1 )
-			Super.New( "",parent,index )
-			Self.seq=seq
-			
-			Update( label )
-		End
-		
-		Method Update( label:String )
-		
-			Local tname:=name
-			Local ttype:=type
-			Local tvalue:=value
-		
-			name=""
-			type=""
-			value=""
-			scope=False
-			
-			Local i0:=label.Find( ":" )
-			If i0<>-1
-				name=label.Slice( 0,i0 )
-				Local i1:=label.Find( "=",i0+1 )
-				If i1=-1
-					type=label.Slice( i0+1 )
-				Else
-					type=label.Slice( i0+1,i1 )
-					value=label.Slice( i1+1 )
-					
-					If value.StartsWith( "@" )
-					
-						label=name+":"+type
-						
-						If value.Contains( ":" )
-							scope=True
-						Else
-							Local p:ULong
-							If value.StartsWith( "@0x" )
-								p=StringToULong( value.Slice( 3 ),16 )
-							Else
-								p=StringToULong( value.Slice( 1 ),16 )
-							Endif
-							If p
-								label+="="+value
-								scope=True
-							Else
-								label+="=Null"
-							Endif
-						Endif
-					Endif					
-				Endif
-			Endif
-			
-			Text=label
-			
-			If name=tname And type=ttype And value=tvalue Return
-			
-			RemoveAllChildren()
-			
-			If scope New Node( "",Self )
-		End
-	
-	End
-	
-	Field _tree:TreeView
-	
-	Field _toolBar:ToolBar
-
-	Field _docs:DocumentManager	
-	Field _console:Console
-
-	Field _debugging:Bool
-	Field _stopped:Bool
-	Field _killme:Bool
-	Field _resume:Future<Bool>
-	
-	Field _run:Action
-	Field _step:Action
-	Field _enter:Action
-	Field _leave:Action
-	Field _kill:Action
-	
-	Method UpdateExpanded( node:Node )
-	
-		If Not node.scope Return
-
-		Local lines:=New StringStack
-		
-		_console.WriteStdin( node.value+"~n" )
-		
-		Repeat
-			Local line:=_console.ReadStdout().Trim()
-			If Not line Exit
-			
-			lines.Push( line )
-		Forever
-		
-		For Local i:=0 Until lines.Length
-		
-			Local line:=lines[i]
-			Local child:=Cast<Node>( node.GetChild( i ) )
-			
-			If child
-				child.Update( line )
-				If child.Expanded UpdateExpanded( child )
-			Else
-				New Node( line,node )
-			Endif
-		
-		Next
-		
-		node.RemoveChildren( lines.Length )
-		
-		RequestRender()
-	End
-	
-	Method UpdateTree()
-	
-		Local root:=_tree.RootNode
-		
-		Local funcIndex:=0
-		
-		Local func:Node
-		Local varIndex:=0
-		
-		Local first:Node
-		
-		Local expanded:=New Stack<Node>
-		
-		Repeat
-		
-			Local line:=_console.ReadStdout().Trim()
-			If Not line Exit
-			
-			If line.StartsWith( ">" )
-			
-				If func func.RemoveChildren( varIndex )
-			
-				Local bits:=line.Split( ";" )
-				Local label:=bits[0].Slice( 1 )
-				Local seq:=Int( bits[3] )
-
-				func=Null
-				For Local i:=funcIndex Until root.NumChildren
-					Local tfunc:=Cast<Node>( root.GetChild( i ) )
-					If Not tfunc Or tfunc.seq<>seq Continue
-					root.RemoveChildren( funcIndex,i )
-					func=tfunc
-					Exit
-				Next
-				
-				If func
-					func.Text=label
-					func.srcLine=Int( bits[2] )
-				Else
-					func=New Node( label+"*",root,seq,funcIndex )
-					func.srcFile=bits[1]
-					func.srcLine=Int( bits[2] )
-					func.seq=seq
-
-					If Not first func.Expanded=True
-				Endif
-				
-				If Not first
-					Local doc:=Cast<Monkey2Document>( _docs.OpenDocument( func.srcFile,True ) )
-					If doc
-						MainWindow.UpdateWindow( False )
-						doc.DebugLine=func.srcLine-1
-					Endif
-					first=func
-				Endif
-				
-				funcIndex+=1
-				
-				varIndex=0
-			
-				Continue
-				
-			Endif
-			
-			Local node:=Cast<Node>( func.GetChild( varIndex ) )
-			
-			If node
-				node.Update( line )
-				If node.Expanded expanded.Push( node )
-			Else
-				New Node( line,func )
-			Endif
-			
-			varIndex+=1
-
-		Forever
-		
-		For Local node:=Eachin expanded
-			UpdateExpanded( node )
-		Next
-		
-		If func func.RemoveChildren( varIndex )
-		
-		root.RemoveChildren( funcIndex )
-		
-		RequestRender()
-	End
-	
-	Method DebugBegin()
-	
-		Assert( Not _stopped )
-		
-		_tree.RootNode.RemoveAllChildren()
-		
-		_killme=False
-		_debugging=True
-
-		UpdateActions()
-	End
-	
-	Method DebugEnd()
-	
-		Assert( Not _stopped )
-		
-		_debugging=False
-		UpdateActions()
-	End
-	
-	Method DebugStop()
-	
-		Assert( Not _stopped )
-		
-		MainWindow.ShowDebugView()
-	
-		UpdateTree()
-		
-		If _killme
-			_console.WriteStdin( "q~n" )
-			Return
-		Endif
-		
-		_resume=New Future<Bool>
-		_stopped=True
-		
-		UpdateActions()
-		
-		_resume.Get()
-	End
-	
-	Method Resume()
-	
-		Assert( _stopped )
-		
-		_stopped=False
-		
-		UpdateActions()
-		
-		_resume.Set( True )
-		_resume=Null
-	End
-	
-	Method UpdateActions()
-		Local icons:=_toolBar.Style.Icons
-		_run.Icon=_stopped ? icons[0] Else icons[2]
-		_run.Enabled=_debugging
-		_step.Enabled=_stopped And _debugging
-		_enter.Enabled=_stopped And _debugging
-		_leave.Enabled=_stopped And _debugging
-		_kill.Enabled=_debugging
-	End
-	
-End

+ 0 - 365
src/ted2/documentmanager.monkey2

@@ -1,365 +0,0 @@
-
-Namespace ted2
-
-Class DocumentManager
-
-	Field nextDocument:Action
-	Field prevDocument:Action
-
-	Field CurrentDocumentChanged:Void()
-	
-	Field DocumentAdded:Void( doc:Ted2Document )
-	Field DocumentRemoved:Void( doc:Ted2Document )
-
-	Method New( tabView:TabView,browser:DockingView )
-	
-		_tabView=tabView
-		_browser=browser
-		
-		_tabView.CurrentChanged+=Lambda()
-			CurrentDocument=FindDocument( _tabView.CurrentView )
-		End
-		
-		_tabView.Dragged+=Lambda()
-			Local docs:=New Stack<Ted2Document>
-			For Local i:=0 Until _tabView.NumTabs
-				docs.Push( FindDocument( _tabView.TabView( i ) ) )
-			Next
-			_openDocs=docs
-		End
-		
-		nextDocument=New Action( "Next file" )
-		nextDocument.Triggered=OnNextDocument
-		nextDocument.HotKey=Key.Tab
-		nextDocument.HotKeyModifiers=Modifier.Control
-
-		prevDocument=New Action( "Previous file" )
-		prevDocument.Triggered=OnPrevDocument
-		prevDocument.HotKey=Key.Tab
-		prevDocument.HotKeyModifiers=Modifier.Control|Modifier.Shift
-		
-		App.Activated+=Lambda()
-			New Fiber( OnAppActivated )
-		End
-	End
-	
-	Property TabView:TabView()
-
-		Return _tabView
-	End
-
-	Property CurrentDocument:Ted2Document()
-	
-		Return _currentDoc
-		
-	Setter( doc:Ted2Document )
-	
-		If doc=_currentDoc Return
-		
-		_currentDoc=doc
-		
-		If _currentDoc
-			_tabView.CurrentView=CurrentView
-			_browser.ContentView=_currentDoc.BrowserView
-		Else
-			_browser.ContentView=Null
-		Endif
-		
-		'Can't change window title on a fiber on at least windows!
-		'
-		App.Idle+=Lambda()
-			If _currentDoc
-				MainWindow.Title="Ted2 - "+_currentDoc.Path
-			Else
-				MainWindow.Title="Ted2"
-			Endif
-		End
-		
-		CurrentDocumentChanged()
-	End
-	
-	Property CurrentTextView:TextView()
-		
-		If _currentDoc Return _currentDoc.TextView
-		
-		Return Null
-	End
-	
-	Property CurrentView:View()
-	
-		If _currentDoc Return _currentDoc.View
-		
-		Return Null
-	End
-	
-	Property OpenDocuments:Ted2Document[]()
-	
-		Return _openDocs.ToArray()
-	End
-	
-	Method OpenDocument:Ted2Document( path:String,makeCurrent:Bool=False )
-	
-		path=RealPath( path )
-		
-		Local doc:=FindDocument( path )
-		If doc 
-			If makeCurrent CurrentDocument=doc
-			Return doc
-		Endif
-		
-		If GetFileType( path )<>FileType.File Return Null
-		
-		Local docType:=Ted2DocumentType.ForExtension( ExtractExt( path ) )
-		If Not docType Return Null
-		
-		doc=docType.CreateDocument( path )
-		If Not doc.Load() Return Null
-
-		InitDoc( doc )
-	
-		_openDocs.Add( doc )
-		_tabView.AddTab( TabText( doc ),doc.View )
-		
-		DocumentAdded( doc )
-		
-		If makeCurrent CurrentDocument=doc
-		
-		Return doc
-	End
-	
-	'Currently also saves doc.
-	'
-	Method RenameDocument:Ted2Document( doc:Ted2Document,newPath:String )
-	
-		For Local i:=0 Until _openDocs.Length
-			If doc<>_openDocs[i] Continue
-			
-			Local newType:=Ted2DocumentType.ForExtension( ExtractExt( newPath ) )
-			If Not newType Return Null
-
-			Local oldPath:=doc.Path
-			doc.Rename( newPath )
-			If Not doc.Save()
-				doc.Rename( oldPath )
-				Return Null
-			Endif
-			
-			If newType=Ted2DocumentType.ForExtension( ExtractExt( oldPath ) ) Return doc
-			
-			Local newDoc:=newType.CreateDocument( newPath )
-			If Not newDoc.Load() Return Null
-			
-			InitDoc( newDoc )
-			
-			_openDocs[i]=newDoc
-			_tabView.SetTabText( i,TabText( newDoc ) )
-			_tabView.SetTabView( i,newDoc.View )
-			
-			doc.Close()
-			
-			DocumentRemoved( doc )
-			
-			DocumentAdded( newDoc )
-			
-			If doc=_currentDoc CurrentDocument=newDoc
-
-			Return newDoc
-		Next
-		
-		Return Null
-	End
-	
-	Method FindDocument:Ted2Document( path:String )
-	
-		For Local doc:=Eachin _openDocs
-			If doc.Path=path Return doc
-		Next
-		
-		Return Null
-	End
-	
-	Method FindDocument:Ted2Document( view:View )
-	
-		For Local doc:=Eachin _openDocs
-			If doc.View=view Return doc
-		Next
-		
-		Return Null
-	End
-	
-	Method SaveState( jobj:JsonObject )
-		
-		Local docs:=New JsonArray
-		For Local doc:=Eachin _openDocs
-			docs.Add( New JsonString( doc.Path ) )
-		Next
-		jobj["openDocuments"]=docs
-		
-		If _currentDoc jobj["currentDocument"]=New JsonString( _currentDoc.Path )
-	End
-		
-	Method LoadState( jobj:JsonObject )
-		
-		If Not jobj.Contains( "openDocuments" ) Return
-		
-		For Local doc:=Eachin jobj.GetArray( "openDocuments" )
-		
-			Local path:=doc.ToString()
-			If GetFileType( path )<>FileType.File Continue
-			
-			Local tdoc:=OpenDocument( doc.ToString() )
-			If tdoc And MainWindow.IsTmpPath( path ) tdoc.Dirty=True
-		Next
-		
-		Local path:=jobj.GetString( "currentDocument" )
-		If path
-			Local doc:=FindDocument( path )
-			If doc CurrentDocument=doc
-		Endif
-		
-		If Not _currentDoc And _openDocs.Length
-			CurrentDocument=_openDocs[0]
-		Endif
-		
-	End
-
-	Method Update()
-		nextDocument.Enabled=_openDocs.Length>1
-		prevDocument.Enabled=_openDocs.Length>1
-	End
-	
-	Private
-	
-	Field _tabView:TabView
-	Field _browser:DockingView
-	
-	Field _currentDoc:Ted2Document
-	
-	Field _openDocs:=New Stack<Ted2Document>
-	
-	Method InitDoc( doc:Ted2Document )
-	
-		doc.DirtyChanged+=Lambda()
-		
-			UpdateTabLabel( doc )
-		End
-		
-		doc.StateChanged+=Lambda()
-		
-			UpdateTabLabel( doc )
-		End
-
-		doc.Closed+=Lambda()
-		
-			Local index:=_tabView.TabIndex( doc.View )
-			If index=-1 Return	'in case doc already removed via Rename.
-
-			_tabView.RemoveTab( index )
-			_openDocs.Remove( doc )
-			
-			If doc=_currentDoc
-				If _tabView.NumTabs
-					If index=_tabView.NumTabs index-=1
-					CurrentDocument=FindDocument( _tabView.TabView( index ) )
-				Else
-					CurrentDocument=Null
-				Endif
-			Endif
-			
-			DocumentRemoved( doc )
-		End
-		
-	End
-	
-	Method TabText:String( doc:Ted2Document )
-	
-		Local label:=StripDir( doc.Path )
-		
-		If ExtractExt( doc.Path ).ToLower()=".monkey2"  label=StripExt( label )
-		
-		label=doc.State+label
-		
-		If doc.Dirty label+="*"
-		
-		Return label
-	End
-	
-	Method UpdateTabLabel( doc:Ted2Document )
-	
-		If doc _tabView.SetTabText( doc.View,TabText( doc ) )
-	End
-	
-	Method OnNextDocument()
-	
-		If _openDocs.Length<2 Return
-		
-		Local i:=_tabView.CurrentIndex+1
-		If i=_tabView.NumTabs i=0
-		
-		Local doc:=FindDocument( _tabView.TabView( i ) )
-		If Not doc Return
-		
-		CurrentDocument=doc
-	End
-	
-	Method OnPrevDocument()
-		
-		If _openDocs.Length<2 Return
-		
-		Local i:=_tabView.CurrentIndex-1
-		If i=-1 i=_tabView.NumTabs-1
-		
-		Local doc:=FindDocument( _tabView.TabView( i ) )
-		If Not doc Return
-		
-		CurrentDocument=doc
-	End
-	
-	Method OnAppActivated()
-	
-		Local docs:=_openDocs.ToArray()
-		
-		For Local doc:=Eachin docs
-		
-			Select GetFileType( doc.Path )
-			Case FileType.File
-			
-				If GetFileTime( doc.Path )>doc.ModTime
-				
-					doc.Dirty=True
-					
-					CurrentDocument=doc
-					
-					Select TextDialog.Run( "File modified","File '"+doc.Path+"' has been modified!~n~nReload new version?",New String[]( "Reload","Close document without saving","Ignore" ) )
-					Case 0 'Reload
-						doc.Load()
-					Case 1 'Close
-						doc.Close()
-					Case 2 'Ignore
-					End
-				
-				Endif
-				
-			Case FileType.Directory
-			
-				doc.Dirty=True
-				
-				CurrentDocument=doc
-				
-				Alert( "File '"+doc.Path+"' has mysteriously turned into a directory!" )
-			
-			Case FileType.None
-			
-				doc.Dirty=True
-
-				CurrentDocument=doc
-				
-				Alert( "File '"+doc.Path+"' has been deleted!" )
-				
-			End
-		
-		Next
-		
-	End
-	
-End

+ 0 - 138
src/ted2/editactions.monkey2

@@ -1,138 +0,0 @@
-
-Namespace ted2
-
-Class EditActions
-
-	Field undo:Action
-	Field redo:Action
-	Field cut:Action
-	Field copy:Action
-	Field paste:Action
-	Field selectAll:Action
-	Field wordWrap:Action
-	Field gotoLine:Action
-	
-	Method New( docs:DocumentManager )
-	
-		_docs=docs
-		
-		undo=New Action( "Undo" )
-		undo.Triggered=OnUndo
-		undo.HotKey=Key.Z
-		undo.HotKeyModifiers=Modifier.Menu|Modifier.Ignore
-
-		redo=New Action( "Redo" )
-		redo.Triggered=OnRedo
-		redo.HotKey=Key.Y
-		redo.HotKeyModifiers=Modifier.Menu|Modifier.Ignore
-
-		cut=New Action( "Cut" )
-		cut.Triggered=OnCut
-		cut.HotKey=Key.X
-		cut.HotKeyModifiers=Modifier.Menu|Modifier.Ignore
-
-		copy=New Action( "Copy" )
-		copy.Triggered=OnCopy
-		copy.HotKey=Key.C
-		copy.HotKeyModifiers=Modifier.Menu|Modifier.Ignore
-
-		paste=New Action( "Paste" )
-		paste.Triggered=OnPaste
-		paste.HotKey=Key.V
-		paste.HotKeyModifiers=Modifier.Menu|Modifier.Ignore
-
-		selectAll=New Action( "Select all" )
-		selectAll.Triggered=OnSelectAll
-		selectAll.HotKey=Key.A
-		selectAll.HotKeyModifiers=Modifier.Menu|Modifier.Ignore
-		
-		wordWrap=New Action( "Toggle word wrap" )
-		wordWrap.Triggered=OnWordWrap
-		wordWrap.HotKey=Key.W
-		wordWrap.HotKeyModifiers=Modifier.Menu
-		
-		gotoLine=New Action( "Goto line" )
-		gotoLine.Triggered=OnGotoLine
-		gotoLine.HotKey=Key.G
-		gotoLine.HotKeyModifiers=Modifier.Menu
-	End
-	
-	Method Update()
-	
-		Local tv:=Cast<TextView>( App.KeyView )
-		
-		undo.Enabled=tv And tv.CanUndo
-		redo.Enabled=tv And tv.CanRedo
-		cut.Enabled=tv And tv.CanCut
-		copy.Enabled=tv And tv.CanCopy
-		paste.Enabled=tv And tv.CanPaste
-		selectAll.Enabled=tv
-	End
-	
-	Private
-	
-	Field _docs:DocumentManager
-	
-	Method OnUndo()
-
-		Local tv:=Cast<TextView>( App.KeyView )
-		
-		If tv tv.Undo()
-	End
-	
-	Method OnRedo()
-	
-		Local tv:=Cast<TextView>( App.KeyView )
-		
-		If tv tv.Redo()
-	End
-	
-	Method OnCut()
-	
-		Local tv:=Cast<TextView>( App.KeyView )
-		
-		If tv tv.Cut()
-	End
-
-	Method OnCopy()
-
-		Local tv:=Cast<TextView>( App.KeyView )
-		
-		If tv tv.Copy()
-	End
-
-	Method OnPaste()		
-		
-		Local tv:=Cast<TextView>( App.KeyView )
-		
-		If tv tv.Paste()
-	End
-	
-	Method OnSelectAll()
-		
-		Local tv:=Cast<TextView>( App.KeyView )
-		
-		If tv tv.SelectAll()
-	End
-	
-	Method OnWordWrap()
-	
-		Local tv:=Cast<TextView>( App.KeyView )
-		
-		If tv tv.WordWrap=Not tv.WordWrap
-	End
-	
-	Method OnGotoLine()
-	
-		Local tv:=Cast<TextView>( App.KeyView )
-		If Not tv Return
-		
-		Local line:=RequestInt( "Goto line:","Goto line",tv.CursorLine+1,0,1,tv.Document.NumLines )
-		If Not line Return
-		
-		tv.GotoLine( line-1 )
-		
-		tv.MakeKeyView()
-	End
-
-End

+ 0 - 130
src/ted2/editproductdialog.monkey2

@@ -1,130 +0,0 @@
-
-Namespace ted2
-
-Class ProductVar
-
-	Field name:String
-	Field value:String
-	Field type:String
-		
-	Method New( name:String,value:String,type:String="string" )
-		Self.name=name
-		Self.value=value
-		Self.type=type
-	End
-	
-	Method CreateFieldView:View()
-	
-		Local fieldView:View
-		
-		Select type
-		Case "string"
-		
-			Local view:=New TextField( value )
-			
-			view.TextChanged+=Lambda()
-				value=view.Text
-			End
-			
-			fieldView=view
-			
-		Case "directory"
-		
-			Local view:=New FilePathField( value,FileType.Directory )
-			
-			view.FilePathChanged=Lambda()
-				value=view.FilePath
-			End
-			
-			fieldView=view
-			
-		Default
-		
-			If type.StartsWith( "options:" )
-
-				Local opts:=type.Slice( 8 ).Split( "|" )
-				
-				Local current:=0
-				For Local i:=0 Until opts.Length
-					If value<>opts[i] Continue
-					current=i
-					Exit
-				Next
-
-				Local view:=New OptionsField( opts,current )
-
-				view.CurrentChanged+=Lambda()
-
-					value=opts[view.Current]
-				End
-			
-				fieldView=view
-
-			Endif
-		End
-		
-		Return fieldView
-	End
-		
-End
-
-Class EditProductDialog Extends Dialog
-
-	Method New( title:String,vars:Stack<ProductVar> )
-	
-		Title=title
-		
-		_vars=vars
-		
-		_table=New TableView
-		_table.AddColumn( "Setting" )
-		_table.AddColumn( "Value" )
-		
-		_table.Rows+=_vars.Length
-		
-		For Local i:=0 Until _vars.Length
-			Local pvar:=_vars[i]
-			
-			_table[0,i]=New Label( pvar.name )
-			_table[1,i]=pvar.CreateFieldView()
-		End
-		
-		ContentView=_table
-		
-		Local okay:=AddAction( "Okay" )
-		okay.Triggered=Lambda()
-			_result.Set( True )
-		End
-		SetKeyAction( Key.Enter,okay )
-
-		Local cancel:=AddAction( "Cancel"  )
-		cancel.Triggered=lambda()
-			_result.Set( False )
-		End
-		SetKeyAction( Key.Escape,cancel )
-	End
-	
-	Method Run:Bool()
-	
-		Open()
-		
-		App.BeginModal( Self )
-		
-		Local result:=_result.Get()
-		
-		App.EndModal()
-		
-		Close()
-		
-		Return result
-	End
-	
-	Private
-	
-	Field _table:TableView
-	
-	Field _vars:Stack<ProductVar>
-	
-	Field _result:=New Future<Bool>
-
-End

+ 0 - 273
src/ted2/fileactions.monkey2

@@ -1,273 +0,0 @@
-
-Namespace ted2
-
-Class FileActions
-
-	Field new_:Action
-	Field open:Action
-	Field close:Action
-	Field closeOthers:Action
-	Field closeToRight:Action
-	Field closeAll:Action
-	Field save:Action
-	Field saveAs:Action
-	Field saveAll:Action
-	Field quit:Action
-	
-	Method New( docs:DocumentManager )
-	
-		_docs=docs
-		
-		new_=New Action( "New" )
-		new_.HotKey=Key.N
-		new_.HotKeyModifiers=Modifier.Menu
-		new_.Triggered=OnNew
-		
-		open=New Action( "Open" )
-		open.HotKey=Key.O
-		open.HotKeyModifiers=Modifier.Menu
-		open.Triggered=OnOpen
-		
-		close=New Action( "Close" )
-#if __HOSTOS__="macos"
-		close.HotKey=Key.W
-		close.HotKeyModifiers=Modifier.Menu
-#else
-		close.HotKey=Key.F4
-		close.HotKeyModifiers=Modifier.Menu
-#endif		
-		close.Triggered=OnClose
-		
-		closeOthers=New Action( "Close other tabs" )
-		closeOthers.Triggered=OnCloseOthers
-		
-		closeToRight=New Action( "Close tabs to the right" )
-		closeToRight.Triggered=OnCloseToRight
-		
-		closeAll=New Action( "Close all" )
-		closeAll.Triggered=OnCloseAll
-		
-		save=New Action( "Save" )
-		save.HotKey=Key.S
-		save.HotKeyModifiers=Modifier.Menu
-		save.Triggered=OnSave
-
-		saveAs=New Action( "Save as" )
-		saveAs.HotKey=Key.S
-		saveAs.HotKeyModifiers=Modifier.Menu|Modifier.Shift
-		saveAs.Triggered=OnSaveAs
-
-		saveAll=New Action( "Save all" )
-		saveAll.Triggered=OnSaveAll
-		
-		quit=New Action( "Quit" )
-		quit.Triggered=OnQuit
-		
-#If __TARGET__="windows"
-		quit.HotKey=Key.F4
-		quit.HotKeyModifiers=Modifier.Alt|Modifier.Ignore
-#Elseif __TARGET__="macos"
-		quit.HotKey=Key.Q
-		quit.HotKeyModifiers=Modifier.Menu|Modifier.Ignore
-#Elseif __TARGET__="linux"
-		quit.HotKey=Key.F4
-		quit.HotKeyModifiers=Modifier.Alt|Modifier.Ignore
-#endif		
-
-	End
-	
-	Method Update()
-	
-		Local docs:=_docs.OpenDocuments
-
-		Local n:=0
-		Local anyDirty:Bool
-		For Local doc:=Eachin docs
-			If doc.Dirty anyDirty=True
-			n+=1
-		Next
-	
-		Local doc:=_docs.CurrentDocument
-
-		close.Enabled=doc
-		closeOthers.Enabled=n>1
-		closeToRight.Enabled=doc And doc<>docs[docs.Length-1]
-		closeAll.Enabled=n>0
-		save.Enabled=doc And doc.Dirty
-		saveAs.Enabled=doc
-		saveAll.Enabled=anyDirty
-	End
-	
-	Private
-	
-	Field _docs:DocumentManager
-	
-	Method SaveAs:Ted2Document()
-	
-		Local doc:=_docs.CurrentDocument
-		If Not doc Return Null
-		
-		Local path:=MainWindow.RequestFile( "Save As","",True )
-		If Not path Return Null
-				
-		If Not ExtractExt( path ) path+=ExtractExt( doc.Path )
-		
-		Return _docs.RenameDocument( doc,path )
-	End
-
-	Method CanClose:Ted2Document( doc:Ted2Document )
-	
-		If Not doc.Dirty Return doc
-		
-		_docs.CurrentDocument=doc
-				
-		Local buttons:=New String[]( "Save","Discard Changes","Cancel" )
-			
-		Select TextDialog.Run( "Close File","File '"+doc.Path+"' has been modified.",buttons )
-		Case 0
-			If MainWindow.IsTmpPath( doc.Path )
-				Return SaveAs()
-			Else
-				If Not doc.Save() Return Null
-			Endif
-		Case 2
-			Return Null
-		End
-		
-		Return doc
-	End
-	
-	Method OnNew()
-	
-		Local path:=MainWindow.AllocTmpPath( "untitled",".monkey2" )
-		If Not path
-			Alert( "Can't allocate temporary file" )
-			Return
-		Endif
-
-		SaveString( "",path )
-		
-		_docs.OpenDocument( path,True )
-	End
-		
-	Method OnOpen()
-	
-		Local path:=MainWindow.RequestFile( "Open File","",False )
-		If Not path Return
-		
-		path=RealPath( path )
-		
-		_docs.OpenDocument( path,True )
-	End
-	
-	Method OnClose()
-	
-		Local doc:=_docs.CurrentDocument
-		If Not doc Return
-		
-		doc=CanClose( doc )
-		If Not doc return
-		
-		doc.Close()
-	End
-	
-	Method OnCloseOthers()
-	
-		If Not _docs.CurrentDocument Return
-	
-		Local docs:=_docs.OpenDocuments
-		
-		For Local doc:=Eachin docs
-			If doc<>_docs.CurrentDocument And Not CanClose( doc ) Return
-		Next
-		
-		For Local doc:=Eachin docs
-			If doc<>_docs.CurrentDocument doc.Close()
-		Next
-	End
-	
-	Method OnCloseToRight()
-	
-		If Not _docs.CurrentDocument Return
-	
-		Local docs:=_docs.OpenDocuments
-		
-		Local close:=False
-		For Local doc:=Eachin docs
-			If close
-				If Not CanClose( doc ) Return
-			Else
-				If doc=_docs.CurrentDocument close=True
-			Endif
-		Next
-		
-		close=False
-		For Local doc:=Eachin docs
-			If close
-				doc.Close()
-			Else
-				If doc=_docs.CurrentDocument close=True
-			Endif
-		Next
-		
-	End
-	
-	Method OnCloseAll()
-
-		Local docs:=_docs.OpenDocuments
-		
-		For Local doc:=Eachin docs
-			If Not CanClose( doc ) Return
-		Next
-		
-		For Local doc:=Eachin docs
-			doc.Close()
-		Next
-		
-	End
-	
-	Method OnSave()
-	
-		Local doc:=_docs.CurrentDocument
-		If Not doc Return
-		
-		If MainWindow.IsTmpPath( doc.Path )
-			SaveAs()
-		Else
-			doc.Save()
-		Endif
-	End
-	
-	Method OnSaveAs()
-	
-		SaveAs()
-	End
-	
-	Method OnSaveAll()
-	
-		For Local doc:=Eachin _docs.OpenDocuments
-
-			If MainWindow.IsTmpPath( doc.Path )
-				_docs.CurrentDocument=doc
-				If Not SaveAs() Return
-			Else
-				doc.Save()
-			Endif
-		Next
-	End
-	
-	Method OnQuit()
-	
-		For Local doc:=Eachin _docs.OpenDocuments
-		
-			If MainWindow.IsTmpPath( doc.Path )
-				If Not doc.Save() Return
-			Else
-				If Not CanClose( doc ) Return
-			Endif
-		Next
-		
-		MainWindow.Terminate()
-	End
-	
-End

+ 0 - 180
src/ted2/findactions.monkey2

@@ -1,180 +0,0 @@
-
-Namespace ted2
-
-Class FindActions
-
-	Field find:Action
-	Field findNext:Action
-	field findPrevious:Action
-	Field replace:Action
-	Field replaceAll:Action
-	
-	Method New( docs:DocumentManager )
-		
-		_docs=docs
-		
-		find=New Action( "Find" )
-		find.Triggered=OnFind
-		find.HotKey=Key.F
-		find.HotKeyModifiers=Modifier.Menu
-		
-		findNext=New Action( "Find next" )
-		findNext.Triggered=OnFindNext
-		findNext.HotKey=Key.F3
-		
-		findPrevious=New Action( "Find previous" )
-		findPrevious.Triggered=OnFindPrevious
-		findPrevious.HotKey=Key.F3
-		findPrevious.HotKeyModifiers=Modifier.Shift
-		
-		replace=New Action( "Replace" )
-		replace.Triggered=OnReplace
-		
-		replaceAll=New Action( "Replace all" )
-		replaceAll.Triggered=OnReplaceAll
-		
-		_findDialog=New FindDialog( Self )
-	End
-	
-	Method Update()
-	
-		Local tv:=_docs.CurrentTextView
-		findNext.Enabled=tv
-		findPrevious.Enabled=tv
-		replace.Enabled=tv
-		replaceAll.Enabled=tv
-	End
-	
-	Private
-	
-	Field _docs:DocumentManager
-	
-	Field _findDialog:FindDialog
-	
-	Method OnFind()
-	
-		_findDialog.Open()
-	End
-	
-	Method OnFindNext()
-	
-		Local tv:=_docs.CurrentTextView
-		If Not tv Return
-		
-		Local text:=_findDialog.FindText
-		If Not text Return
-		
-		Local tvtext:=tv.Text
-		Local cursor:=Max( tv.Anchor,tv.Cursor )
-		
-		If Not _findDialog.CaseSensitive
-			tvtext=tvtext.ToLower()
-			text=text.ToLower()
-		Endif
-		
-		Local i:=tvtext.Find( text,cursor )
-		If i=-1
-			i=tvtext.Find( text )
-			If i=-1 Return
-		Endif
-		
-		tv.SelectText( i,i+text.Length )
-	End
-	
-	Method OnFindPrevious()
-	
-		Local tv:=_docs.CurrentTextView
-		If Not tv Return
-
-		Local text:=_findDialog.FindText
-		If Not text Return
-
-		Local tvtext:=tv.Text
-		Local cursor:=Min( tv.Anchor,tv.Cursor )
-		
-		If Not _findDialog.CaseSensitive
-			tvtext=tvtext.ToLower()
-			text=text.ToLower()
-		Endif
-		
-		Local i:=tvtext.Find( text )
-		If i=-1 Return
-		
-		If i>=cursor
-			i=tvtext.FindLast( text )
-		Else
-			Repeat
-				Local n:=tvtext.Find( text,i+text.Length )
-				If n>=cursor Exit
-				i=n
-			Forever
-		End
-		
-		tv.SelectText( i,i+text.Length )
-	End
-	
-	Method OnReplace()
-	
-		Local tv:=_docs.CurrentTextView
-		If Not tv Return
-		
-		Local text:=_findDialog.FindText
-		If Not text Return
-		
-		Local min:=Min( tv.Anchor,tv.Cursor )
-		Local max:=Max( tv.Anchor,tv.Cursor )
-		
-		Local tvtext:=tv.Text.Slice( min,max )
-
-		If Not _findDialog.CaseSensitive
-			tvtext=tvtext.ToLower()
-			text=text.ToLower()
-		Endif
-		
-		If tvtext<>text Return
-		
-		tv.ReplaceText( _findDialog.ReplaceText )
-		
-		OnFindNext()
-
-	End
-	
-	Method OnReplaceAll()
-	
-		Local tv:=_docs.CurrentTextView
-		If Not tv Return
-		
-		Local text:=_findDialog.FindText
-		If Not text Return
-		
-		Local rtext:=_findDialog.ReplaceText
-		
-		Local tvtext:=tv.Text
-
-		If Not _findDialog.CaseSensitive
-			tvtext=tvtext.ToLower()
-			text=text.ToLower()
-		Endif
-		
-		Local anchor:=tv.Anchor
-		Local cursor:=tv.Cursor
-		
-		Local i:=0,t:=0
-		Repeat
-		
-			i=tvtext.Find( text,i )
-			If i=-1 Exit
-			
-			tv.SelectText( i+t,i+text.Length+t )
-			tv.ReplaceText( rtext )
-			
-			t+=rtext.Length-text.Length
-			i+=text.Length
-			
-		Forever
-		
-		tv.SelectText( anchor,cursor )
-		
-	End
-	
-End

+ 0 - 81
src/ted2/finddialog.monkey2

@@ -1,81 +0,0 @@
-
-Namespace ted2
-
-Class FindDialog Extends Dialog
-
-	Method New( actions:FindActions )
-	
-		_findField=New TextField
-		
-		_replaceField=New TextField
-		
-		_findField.Entered+=Lambda()
-			actions.findNext.Trigger()
-		End
-
-		_findField.Tabbed+=_replaceField.MakeKeyView
-
-		_replaceField.Tabbed+=_findField.MakeKeyView
-		
-		_caseSensitive=New CheckButton( "Case sensitive" )
-		_caseSensitive.Layout="float"
-		
-'		_escapedText=New CheckButton( "Escaped text" )
-
-		Local table:=New TableView( 2,2 )
-		table[0,0]=New Label( "Find" )
-		table[1,0]=_findField
-		table[0,1]=New Label( "Replace" )
-		table[1,1]=_replaceField 
-		
-		_docker=New DockingView
-		_docker.AddView( table,"top" )
-		_docker.AddView( _caseSensitive,"top" )
-'		_docker.AddView( _escapedText,"top" )
-		_docker.AddView( New Label( " " ),"top" )
-		
-		Title="Find/Replace"
-		
-		MaxSize=New Vec2i( 512,0 )
-		
-		ContentView=_docker
-		
-		AddAction( actions.findNext )
-		AddAction( actions.findPrevious )
-		AddAction( actions.replace )
-		AddAction( actions.replaceAll )
-		
-		Local close:=AddAction( "Close" )
-		SetKeyAction( Key.Escape,close )
-		close.Triggered=Close
-		
-		_findField.Activated+=_findField.MakeKeyView
-		
-		Deactivated+=MainWindow.UpdateKeyView
-	End
-	
-	Property FindText:String()
-	
-		Return _findField.Text
-	End
-	
-	Property ReplaceText:String()
-	
-		Return _replaceField.Text
-	End
-	
-	Property CaseSensitive:Bool()
-	
-		Return _caseSensitive.Checked
-	End
-	
-	Private
-	
-	Field _findField:TextField
-	Field _replaceField:TextField
-	Field _caseSensitive:CheckButton
-	Field _escapedText:CheckButton
-
-	Field _docker:DockingView
-
-End

+ 0 - 59
src/ted2/gutterview.monkey2

@@ -1,59 +0,0 @@
-
-Namespace ted2
-
-Class GutterView Extends View
-
-	Method New( textView:TextView )
-		Style=GetStyle( "GutterView" )
-	
-		_textView=textView
-	End
-	
-	Protected
-	
-	Method OnValidateStyle() Override
-	
-		Local font:=RenderStyle.Font
-	
-		_width=font.TextWidth( "1234567" )
-
-		_size=New Vec2i( font.TextWidth( "12345678" ),0 )
-	End
-	
-	Method OnMeasure:Vec2i() Override
-	
-		Return _size
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-	
-		canvas.Color=RenderStyle.BackgroundColor
-		
-		canvas.DrawRect( Rect.X,Rect.Y,Rect.Width,Rect.Height )
-		
-		canvas.Color=RenderStyle.TextColor
-		
-		Local vrect:=_textView.VisibleRect
-		
-		Local firstLine:=_textView.LineAtPoint( vrect.TopLeft )
-
-		Local lastLine:=_textView.LineAtPoint( vrect.BottomLeft )+1
-		
-		canvas.Translate( 0,-vrect.Top )
-		
-		For Local i:=firstLine Until lastLine
-		
-			Local rect:=_textView.LineRect( i )
-		
-			canvas.DrawText( i+1,_width,rect.Top,1,0 )
-		Next
-		
-	End
-	
-	Private
-	
-	Field _width:Int
-	Field _size:Vec2i
-	Field _textView:TextView
-	
-End

+ 0 - 51
src/ted2/helpactions.monkey2

@@ -1,51 +0,0 @@
-
-Namespace ted2
-
-Class HelpActions
-
-	Field onlineHelp:Action
-	Field viewManuals:Action
-	Field uploadModules:Action
-	Field about:Action
-
-	Method New()
-	
-		onlineHelp=New Action( "Online help" )
-		onlineHelp.Triggered=lambda()
-		
-			OpenUrl( "http://monkeycoder.co.nz/modules-reference/" )
-		End
-		
-		viewManuals=New Action( "Browse manuals" )
-		viewManuals.Triggered=Lambda()
-		
-			OpenUrl( RealPath( "docs/index.html" ) )
-		End
-		
-		uploadModules=New Action( "Upload module" )
-		uploadModules.Triggered=Lambda()
-		
-			Alert( "Now taking you to the module manager page at monkeycoder.co.nz~n~nNote: You must have an account at monkeycoder.co.nz and be logged in to upload modules" )
-		
-			OpenUrl( RealPath( "http://monkeycoder.co.nz/module-manager/" ) )
-		End
-
-		about=New Action( "About monkey2" )
-		about.Triggered=Lambda()
-		
-			Local htmlView:=New HtmlView
-			htmlView.Go( "ABOUT.HTML" )
-	
-			Local dialog:=New Dialog( "About monkey2" )
-			dialog.ContentView=htmlView
-
-			dialog.MinSize=New Vec2i( 640,600 )
-
-			dialog.AddAction( "Okay!" ).Triggered=dialog.Close
-			
-			dialog.Open()
-		End
-
-	End
-
-End

+ 0 - 258
src/ted2/helptree.monkey2

@@ -1,258 +0,0 @@
-
-Namespace ted2
-
-Private
-
-Function EnumModules:String[]()
-
-	Local mods:=New StringStack
-	
-	For Local f:=Eachin LoadDir( "modules" )
-	
-		Local dir:="modules/"+f+"/"
-		If GetFileType( dir )<>FileType.Directory Continue
-		
-		Local str:=LoadString( dir+"module.json" )
-		If Not str Continue
-		
-		Local obj:=JsonObject.Parse( str )
-		If Not obj Continue
-		
-		Local jname:=obj["module"]
-		If Not jname Or Not Cast<JsonString>( jname ) Continue
-		
-		mods.Push( jname.ToString() )
-	
-	Next
-	
-	Return mods.ToArray()
-End
-
-Public
-
-Class HelpTree Extends TreeView
-
-	Field PageClicked:Void( page:String )
-	
-	Method New( htmlView:HtmlView )
-	
-		htmlView.AnchorClicked=Lambda( url:String )
-		
-			'dodgy work around for mx2 docs!
-			'
-			If url.StartsWith( "javascript:void('" ) And url.EndsWith( "')" )
-				Local page:=url.Slice( url.Find( "'" )+1,url.FindLast( "'" ) )
-				url=PageUrl( page )
-				If Not url Return
-			Endif
-			
-			MainWindow.ShowHelp( url )
-		End
-		
-		PageClicked+=Lambda( page:String )
-		
-			Local url:=PageUrl( page )
-			If Not url Return
-			
-			MainWindow.ShowHelp( url )
-		End
-		
-		Init()
-	End
-	
-	Property FindField:TextField()
-	
-		Return _textField
-	End
-	
-	Method QuickHelp( text:String )
-	
-		If text<>_textField.Text
-			_textField.Text=text
-		Else
-			NextHelp()
-		End
-		
-	End
-	
-	Method PageUrl:String( page:String )
-	
-		Return RealPath( "modules/"+page.Replace( ":","/docs/__PAGES__/" ).Replace( ".","-" )+".html" )
-	End
-	
-	Method Update()
-	
-		RootNode.RemoveAllChildren()
-
-		For Local modname:=Eachin EnumModules()
-		
-			Local index:="modules/"+modname+"/docs/__PAGES__/index.js"
-
-			Local obj:=JsonObject.Load( index )
-			If Not obj Continue
-			
-			New Node( obj,RootNode,Self )
-		Next
-		
-		NodeClicked+=Lambda( tnode:TreeView.Node )
-		
-			Local node:=Cast<Node>( tnode )
-			If Not node Or Not node.Page Return
-			
-			PageClicked( node.Page )
-		End
-		
-	End
-
-	Private
-	
-	Class Node Extends TreeView.Node
-	
-		Method New( page:String,parent:TreeView.Node,tree:HelpTree )
-			Super.New( page,parent )
-			
-			_page=page
-		End
-	
-		Method New( obj:JsonObject,parent:TreeView.Node,tree:HelpTree )
-			Super.New( "",parent )
-		
-			Text=obj["text"].ToString()
-			
-			If obj.Contains( "data" )
-
-				Local data:=obj["data"].ToObject()
-
-				Local page:=data["page"].ToString()
-				
-				tree._index[page.ToLower()]=Self
-				
-				_page=page
-			Endif
-			
-			If obj.Contains( "children" )
-				For Local child:=Eachin obj["children"].ToArray()
-					New Node( Cast<JsonObject>( child ),Self,tree )
-				Next
-			Endif
-
-		End
-		
-		Property Page:String()
-			Return _page
-		End
-		
-		Property Url:String()
-			Return _url
-		End
-		
-		Private
-		
-		Field _page:String
-		
-		Field _url:String
-	End
-	
-	Method Update( text:String )
-
-		RootNode.CollapseAll()
-			
-		text=text.ToLower()
-			
-		_matches.Clear()
-			
-		Local selected:=New Map<Node,Bool>
-			
-		For Local it:=Eachin _index
-			
-			If Not it.Key.Contains( text ) Continue
-				
-			Local node:=it.Value
-				
-			_matches.Push( node )
-				
-			node.Selected=True
-				
-			selected[node]=True
-				
-			While node
-				node.Expanded=True
-				node=Cast<Node>( node.Parent )
-			Wend
-
-		Next
-						
-		For Local node:=Eachin _selected.Keys
-			
-			If Not selected.Contains( node ) node.Selected=False
-
-		Next
-			
-		_selected=selected
-			
-		RootNode.Expanded=True
-			
-		_matchid=0
-			
-		If _matches.Length
-			
-			PageClicked( _matches[0].Page )
-			
-		Endif
-	
-	End
-	
-	Method NextHelp()
-	
-		If Not _matches Return
-	
-		_matchid+=1
-		If _matchid>=_matches.Length _matchid=0
-		
-		If _matchid<_matches.Length PageClicked( _matches[_matchid].Page )
-	End
-	
-	Method Init()
-
-		_textField=New TextField
-		_textField.Style=GetStyle( "HelpTextField" )
-		
-		_textField.Entered=Lambda()
-		
-			NextHelp()
-		End
-		
-		_textField.Document.TextChanged=Lambda()
-		
-			Local text:=_textField.Text
-			
-			Update( text )
-		End
-		
-		Local find:=New Label( "Find " )
-		find.AddView( _textField )
-		
-		AddView( find,"top" )
-	
-		RootNodeVisible=False
-		RootNode.Expanded=True
-		
-		_textField.Activated+=_textField.MakeKeyView
-		
-		Activated+=MainWindow.ShowHelpView
-		
-		Update()
-				
-	End
-	
-	Field _textField:TextField
-	
-	Field _matchid:Int
-		
-	Field _matches:=New Stack<Node>
-	
-	Field _selected:=New Map<Node,Bool>
-	
-	Field _index:=New Map<String,Node>
-	
-End

+ 0 - 161
src/ted2/imagedocument.monkey2

@@ -1,161 +0,0 @@
-
-Namespace ted2
-
-Class ImageDocumentView Extends View
-
-	Method New( doc:ImageDocument )
-		_doc=doc
-		
-		Layout="fill"
-		
-		_label=New Label( " " )
-		_label.Style=App.Theme.GetStyle( "PushButton" )
-		_label.Layout="float"
-		_label.Gravity=New Vec2f( .5,1 )
-		
-		_doc.ImageChanged=Lambda()
-		
-			If Not _doc.Image 
-				_label.Text=""
-				Return
-			Endif
-			
-			Local format:="?????"
-			Select _doc.Image.Texture.Format
-			Case PixelFormat.I8 format="PixelFormat.I8"
-			Case PixelFormat.A8 format="PixelFormat.A8"
-			Case PixelFormat.IA16 format="PixelFormat.IA16"
-			Case PixelFormat.RGB24 format="PixelFormat.RGB24"
-			Case PixelFormat.RGBA32 format="PixelFormat.RGBA32"
-			End
-			
-			_label.Text="Width="+_doc.Image.Width+", Height="+_doc.Image.Height+", BytesPerPixel="+PixelFormatDepth( _doc.Image.Texture.Format )+", format="+format
-		End
-		
-		AddChildView( _label )
-	End
-	
-	Protected
-	
-	Method OnLayout() Override
-	
-		_label.Frame=Rect
-	End
-	
-	Method OnRender( canvas:Canvas ) Override
-	
-		For Local x:=0 Until Width Step 64
-			For Local y:=0 Until Height Step 64
-				canvas.Color=(x~y) & 64 ? New Color( .1,.1,.1 ) Else New Color( .05,.05,.05 )
-				canvas.DrawRect( x,y,64,64 )
-			Next
-		Next
-		
-		If Not _doc.Image Return
-		
-		canvas.Color=Color.White
-		
-		canvas.Translate( Width/2,Height/2 )
-		
-		canvas.Scale( _zoom,_zoom )
-	
-		canvas.DrawImage( _doc.Image,0,0 )
-	End
-	
-	Method OnMouseEvent( event:MouseEvent ) Override
-	
-		Select event.Type
-		Case EventType.MouseWheel
-			If event.Wheel.Y>0
-				_zoom*=2
-			Else If event.Wheel.Y<0
-				_zoom/=2
-			Endif
-			App.RequestRender()
-		End
-	
-	End
-	
-	Private
-
-	Field _zoom:Float=1
-		
-	Field _doc:ImageDocument
-	
-	Field _label:Label
-End
-
-Class ImageDocument Extends Ted2Document
-
-	Field ImageChanged:Void()
-
-	Method New( path:String )
-		Super.New( path )
-		
-		_view=New ImageDocumentView( Self )
-	End
-	
-	Property Image:Image()
-	
-		Return _image
-	End
-	
-	Protected
-	
-	Method OnLoad:Bool() Override
-	
-		_image=Image.Load( Path )
-		If Not _image Return False
-		
-		_image.Handle=New Vec2f( .5,.5 )
-		
-		ImageChanged()
-		
-		Return True
-	End
-	
-	Method OnSave:Bool() Override
-
-		Return False
-	End
-	
-	Method OnClose() Override
-	
-		If _image _image.Discard()
-
-		_image=Null
-	End
-	
-	Method OnCreateView:ImageDocumentView() Override
-	
-		Return _view
-	End
-	
-	Private
-	
-	Field _image:Image
-	
-	Field _view:ImageDocumentView
-	
-End
-
-Class ImageDocumentType Extends Ted2DocumentType
-
-	Protected
-	
-	Method New()
-		AddPlugin( Self )
-		
-		Extensions=New String[]( ".png",".jpg",".bmp" )
-	End
-	
-	Method OnCreateDocument:Ted2Document( path:String ) Override
-	
-		Return New ImageDocument( path )
-	End
-	
-	Private
-	
-	Global _instance:=New ImageDocumentType
-	
-End

+ 0 - 85
src/ted2/jsondocument.monkey2

@@ -1,85 +0,0 @@
-
-Namespace ted2
-
-Class JsonDocument Extends Ted2Document
-
-	Method New( path:String )
-		Super.New( path )
-		
-		_doc=New TextDocument
-		
-		_view=New TextView( _doc )
-		
-		_browser=New JsonTreeView
-
-		_doc.TextChanged+=Lambda()
-		
-			_browser.Value=JsonValue.Parse( _doc.Text )
-			
-			Dirty=True
-		End
-		
-	End
-
-	Protected
-	
-	Method OnLoad:Bool() Override
-	
-		Local json:=stringio.LoadString( Path )
-		
-		_doc.Text=json
-		
-		Return True
-	End
-	
-	Method OnSave:Bool() Override
-	
-		Local json:=_doc.Text
-		
-		Return stringio.SaveString( json,Path )
-	End
-	
-	Method OnCreateView:View() Override
-	
-		Return _view
-	End
-	
-	Method OnCreateBrowser:View() Override
-	
-		Return _browser
-	End
-	
-	Method OnGetTextView:TextView( view:View ) Override
-	
-		Return Cast<TextView>( view )
-	End
-	
-	Private
-	
-	Field _doc:TextDocument
-	
-	Field _view:TextView
-	
-	Field _browser:JsonTreeView
-End
-
-Class JsonDocumentType Extends Ted2DocumentType
-
-	Protected
-	
-	Method New()
-		AddPlugin( Self )
-		
-		Extensions=New String[]( ".json" )
-	End
-	
-	Method OnCreateDocument:Ted2Document( path:String ) Override
-	
-		Return New JsonDocument( path )
-	End
-	
-	Private
-	
-	Global _instance:=New JsonDocumentType
-	
-End

+ 0 - 93
src/ted2/jsontreeview.monkey2

@@ -1,93 +0,0 @@
-
-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()
-		RootNode.Text="[No Data]"
-	End
-	
-	Method New( value:JsonValue )
-		Self.New()
-		
-		Value=value
-	End
-	
-	Property Value:JsonValue()
-	
-		Return _value
-	
-	Setter( value:JsonValue )
-	
-		RootNode.RemoveAllChildren()
-		
-		If Not value 
-			RootNodeVisible=True
-			RootNode.Text="[No Data]"
-			Return
-		End
-		
-		RootNodeVisible=False
-		RootNode.Expanded=True
-		
-		New Node( value,RootNode )
-	End
-	
-	Private
-	
-	Field _value:JsonValue
-	
-End

+ 0 - 665
src/ted2/mainwindow.monkey2

@@ -1,665 +0,0 @@
-
-Namespace ted2
-
-#Import "assets/themes/@/themes"
-
-#Import "assets/newfiles/@/ted2/newfiles"
-
-Global MainWindow:MainWindowInstance
-
-Class MainWindowInstance Extends Window
-
-	Method New( title:String,rect:Recti,flags:WindowFlags,jobj:JsonObject )
-		Super.New( title,rect,flags )
-		
-		MainWindow=Self
-		
-		If Not App.Theme.Load( jobj.GetString( "theme" ) )
-			jobj.SetString( "theme","ted2-default" )
-			App.Theme.Load( "ted2-default" )
-		Endif
-		
-		_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 )
-		
-		_recentFilesMenu=New Menu( "Recent files..." )
-		_closeProjectMenu=New Menu( "Close project..." )
-		
-		_docBrowser=New DockingView
-		
-		_docsManager=New DocumentManager( _docsTabView,_docBrowser )
-
-		_docsManager.CurrentDocumentChanged+=UpdateKeyView
-		
-		App.FileDropped+=Lambda( path:String )
-			_docsManager.OpenDocument( path,True )
-		End
-
-		_docsManager.DocumentAdded+=Lambda( doc:Ted2Document )
-			AddRecentFile( doc.Path )
-			UpdateRecentFilesMenu()
-		End
-
-		_docsManager.DocumentRemoved+=Lambda( doc:Ted2Document )
-			If IsTmpPath( doc.Path ) DeleteFile( doc.Path )
-		End
-		
-		_buildConsole=New Console
-		_outputConsole=New Console
-		_helpView=New HtmlView
-		_helpView.Go( "ABOUT.HTML" )
-		
-		_projectView=New ProjectView( _docsManager )
-		
-		_helpTree=New HelpTree( _helpView )
-		
-		_debugView=New DebugView( _docsManager,_outputConsole )
-		
-		_fileActions=New FileActions( _docsManager )
-		_editActions=New EditActions( _docsManager )
-		_findActions=New FindActions( _docsManager )
-		_buildActions=New BuildActions( _docsManager,_buildConsole,_debugView )
-		_helpActions=New HelpActions
-
-		_tabMenu=New Menu
-		_tabMenu.AddAction( _fileActions.close )
-		_tabMenu.AddAction( _fileActions.closeOthers )
-		_tabMenu.AddAction( _fileActions.closeToRight )
-		_tabMenu.AddSeparator()
-		_tabMenu.AddAction( _fileActions.save )
-		_tabMenu.AddAction( _fileActions.saveAs )
-		_tabMenu.AddSeparator()
-		_tabMenu.AddAction( _buildActions.lockBuildFile )
-		
-		_docsTabView.RightClicked+=Lambda()
-			_tabMenu.Open()
-		End
-		
-		_docsTabView.CloseClicked+=Lambda( index:Int )
-
-			Local doc:=_docsManager.FindDocument( _docsTabView.TabView( index ) )
-			If Not doc.Dirty And Not IsTmpPath( doc.Path )
-				doc.Close()
-				Return
-			Endif
-			_docsManager.CurrentDocument=doc
-			_fileActions.close.Trigger()
-		End
-
-		
-		'File menu
-		'
-		_newFiles=New Menu( "New..." )
-		Local p:=AssetsDir()+"ted2/newfiles/"
-		For Local f:=Eachin LoadDir( p )
-			Local src:=stringio.LoadString( p+f )
-			_newFiles.AddAction( StripExt( f.Replace( "_"," " ) ) ).Triggered=Lambda()
-				Local path:=AllocTmpPath( "untitled",ExtractExt( f ) )
-				If Not path Return
-				SaveString( src,path )
-				Local doc:=_docsManager.OpenDocument( path,True )
-			End
-		Next
-		
-		_fileMenu=New Menu( "File" )
-		_fileMenu.AddAction( _fileActions.new_ )
-		_fileMenu.AddSubMenu( _newFiles )
-		_fileMenu.AddAction( _fileActions.open )
-		_fileMenu.AddSubMenu( _recentFilesMenu )
-		_fileMenu.AddSeparator()
-		_fileMenu.AddAction( _fileActions.close )
-		_fileMenu.AddAction( _fileActions.closeOthers )
-		_fileMenu.AddAction( _fileActions.closeToRight )
-		_fileMenu.AddAction( _fileActions.closeAll )
-		_fileMenu.AddSeparator()
-		_fileMenu.AddAction( _fileActions.save )
-		_fileMenu.AddAction( _fileActions.saveAs )
-		_fileMenu.AddAction( _fileActions.saveAll )
-		_fileMenu.AddSeparator()
-		_fileMenu.AddAction( _docsManager.nextDocument )
-		_fileMenu.AddAction( _docsManager.prevDocument )
-		_fileMenu.AddSeparator()
-		_fileMenu.AddAction( _projectView.openProject )
-		_fileMenu.AddSubMenu( _closeProjectMenu )
-		_fileMenu.AddSeparator()
-		_fileMenu.AddAction( _fileActions.quit )
-		
-		'Edit menu
-		'
-		_editMenu=New Menu( "Edit" )
-		_editMenu.AddAction( _editActions.undo )
-		_editMenu.AddAction( _editActions.redo )
-		_editMenu.AddSeparator()
-		_editMenu.AddAction( _editActions.cut )
-		_editMenu.AddAction( _editActions.copy )
-		_editMenu.AddAction( _editActions.paste )
-		_editMenu.AddAction( _editActions.selectAll )
-		_editMenu.AddSeparator()
-		_editMenu.AddAction( _editActions.wordWrap )
-		_editMenu.AddSeparator()
-		_editMenu.AddAction( _findActions.find )
-		_editMenu.AddAction( _findActions.findNext )
-		_editMenu.AddAction( _findActions.findPrevious )
-		_editMenu.AddAction( _findActions.replace )
-		_editMenu.AddAction( _findActions.replaceAll )
-		_editMenu.AddAction( _editActions.gotoLine )
-		
-		'Build menu
-		'
-		_forceStop=New Action( "Force Stop" )
-		_forceStop.Triggered=Lambda()
-			If _buildConsole.Running
-				_buildConsole.Terminate()
-			Else If _outputConsole.Running
-				_outputConsole.Terminate()
-			Endif
-		End
-		_forceStop.HotKey=Key.F5
-		_forceStop.HotKeyModifiers=Modifier.Shift
-		
-		_buildMenu=New Menu( "Build" )
-		_buildMenu.AddAction( _buildActions.buildAndRun )
-		_buildMenu.AddAction( _buildActions.build )
-		_buildMenu.AddAction( _buildActions.semant )
-		_buildMenu.AddSubMenu( _buildActions.targetMenu )
-		_buildMenu.AddSeparator()
-		_buildMenu.AddAction( _buildActions.nextError )
-		_buildMenu.AddSeparator()
-		_buildMenu.AddAction( _buildActions.lockBuildFile )
-		_buildMenu.AddSeparator()
-		_buildMenu.AddAction( _buildActions.updateModules )
-		_buildMenu.AddAction( _buildActions.rebuildModules )
-		_buildMenu.AddAction( _buildActions.rebuildHelp )
-		_buildMenu.AddSeparator()
-		_buildMenu.AddAction( _forceStop )
-		_buildMenu.AddSeparator()
-		_buildMenu.AddAction( _buildActions.moduleManager )
-		
-		'View menu
-		'
-		_themesMenu=CreateThemesMenu( "Themes..." )
-		
-		_viewMenu=New Menu( "View" )
-		AddZoomActions( _viewMenu )
-		_viewMenu.AddSeparator()
-		_viewMenu.AddSubMenu( _themesMenu )
-		
-		'Help menu
-		'
-		_helpMenu=New Menu( "Help" )
-		_helpMenu.AddAction( _helpActions.onlineHelp )
-		_helpMenu.AddAction( _helpActions.viewManuals )
-		_helpMenu.AddSeparator()
-		_helpMenu.AddAction( _helpActions.uploadModules )
-		_helpMenu.AddSeparator()
-		_helpMenu.AddAction( _helpActions.about )
-		
-		'Menu bar
-		'
-		_menuBar=New MenuBar
-		_menuBar.AddMenu( _fileMenu )
-		_menuBar.AddMenu( _editMenu )
-		_menuBar.AddMenu( _buildMenu )
-		_menuBar.AddMenu( _viewMenu )
-		_menuBar.AddMenu( _helpMenu )
-		
-		_browsersTabView.AddTab( "Files",_projectView,True )
-		_browsersTabView.AddTab( "Source",_docBrowser,False )
-		_browsersTabView.AddTab( "Debug",_debugView,False )
-		_browsersTabView.AddTab( "Help",_helpTree,False )
-		
-		_consolesTabView.AddTab( "Build",_buildConsole,True )
-		_consolesTabView.AddTab( "Output",_outputConsole,False )
-		_consolesTabView.AddTab( "Documentation",_helpView,False )
-		
-		_contentView=New DockingView
-		_contentView.AddView( _menuBar,"top" )
-		_contentView.AddView( _browsersTabView,"right",250,True )
-		_contentView.AddView( _consolesTabView,"bottom",200,True )
-		_contentView.ContentView=_docsTabView
-		
-		ContentView=_contentView
-
-		LoadState( jobj )
-		
-		App.MouseEventFilter+=ThemeScaleMouseFilter
-		
-		Plugin.CreatePlugins()
-		
-		App.Idle+=OnAppIdle
-		
-		If GetFileType( "bin/ted2.state.json" )=FileType.None _helpActions.about.Trigger()
-	End
-	
-	Property Mx2ccPath:String()
-	
-		Return _mx2cc
-	End
-	
-	Method Terminate()
-	
-		SaveState()
-		
-		App.Terminate()
-	End
-
-	'Use these as macos still seems to have problems running requesters on a fiber - stacksize?
-	'
-	Method RequestFile:String( title:String,path:String,save:Bool )
-	
-		Local future:=New Future<String>
-		
-		App.Idle+=Lambda()
-		
-			future.Set( requesters.RequestFile( title,,save,path ) )
-		End
-		
-		Return future.Get()
-	End
-
-	Method RequestDir:String( title:String,dir:String )
-		
-		Local future:=New Future<String>
-		
-		App.Idle+=Lambda()
-			future.Set( requesters.RequestDir( title,dir ) )
-		End
-		
-		Return future.Get()
-	End
-	
-	Method AllocTmpPath:String( ident:String,ext:String )
-	
-		For Local i:=1 Until 100
-			Local path:=_tmp+ident+i+ext
-			If GetFileType( path )<>FileType.None Continue
-			If CreateFile( path ) Return path
-		Next
-
-		Return ""
-	End
-	
-	Method IsTmpPath:Bool( path:String )
-
-		Return path.StartsWith( _tmp )
-	End
-
-	Private
-		
-	Method DeleteTmps()
-	
-		For Local f:=Eachin LoadDir( _tmp )
-			Local path:=_tmp+f
-			If GetFileType( path )=FileType.File
-				If Not _docsManager.FindDocument( path ) DeleteFile( path )
-			Else
-				DeleteDir( path,True )
-			Endif
-		Next
-		
-	End
-	
-	Public
-	
-	Method ShowProjectView()
-		_browsersTabView.CurrentView=_projectView
-	End
-	
-	Method ShowDebugView()
-		_browsersTabView.CurrentView=_debugView
-	End
-	
-	Method ShowBuildConsole( vis:Bool=True )
-		If vis _consolesTabView.Visible=True
-		_consolesTabView.CurrentView=_buildConsole
-	End
-	
-	Method ShowOutputConsole( vis:Bool=True )
-		If vis _consolesTabView.Visible=True
-		_consolesTabView.CurrentView=_outputConsole
-	End
-	
-	Method ShowHelpView()
-		_consolesTabView.Visible=True
-		_consolesTabView.CurrentView=_helpView
-	End
-	
-	Method ShowQuickHelp( ident:String )
-		_helpTree.QuickHelp( ident )
-	End
-	
-	Method ShowHelp( url:String  )
-		ShowHelpView()
-		_helpView.Go( url )
-		_helpView.Scroll=New Vec2i( 0,0 )
-	End
-	
-	Method UpdateHelpTree()
-		_helpTree.Update()
-	End
-	
-	Method ReadError( path:String )
-		Alert( "I/O Error reading file '"+path+"'" )
-	End
-	
-	Method WriteError( path:String )
-		Alert( "I/O Error writing file '"+path+"'" )
-	End
-
-	Method UpdateKeyView()
-
-		Local doc:=_docsManager.CurrentDocument
-		If Not doc Return
-		
-		If doc.TextView doc.TextView.MakeKeyView() Else doc.View.MakeKeyView()
-	End
-	
-	Method SaveState()
-	
-		Local jobj:=New JsonObject
-		
-		jobj["windowRect"]=ToJson( Frame )
-		jobj["browserSize"]=New JsonNumber( Int( _contentView.GetViewSize( _browsersTabView ) ) )
-		jobj["consoleSize"]=New JsonNumber( Int( _contentView.GetViewSize( _consolesTabView ) ) )
-		
-		Local recent:=New JsonArray
-		For Local path:=Eachin _recentFiles
-			recent.Add( New JsonString( path ) )
-		End
-		jobj["recentFiles"]=recent
-		
-		jobj["theme"]=New JsonString( _theme )
-		
-		jobj["themeScale"]=New JsonNumber( App.Theme.Scale.y )
-		
-		If _mx2ccDir jobj["mx2ccDir"]=New JsonString( _mx2ccDir )
-		
-		_docsManager.SaveState( jobj )
-		_buildActions.SaveState( jobj )
-		_projectView.SaveState( jobj )
-		
-		SaveString( jobj.ToJson(),"bin/ted2.state.json" )
-	End
-
-	Private
-	
-	Method LoadState( jobj:JsonObject )
-	
-		If jobj.Contains( "browserSize" ) _contentView.SetViewSize( _browsersTabView,jobj.GetNumber( "browserSize" ) )
-
-		If jobj.Contains( "consoleSize" ) _contentView.SetViewSize( _consolesTabView,jobj.GetNumber( "consoleSize" ) )
-			
-		If jobj.Contains( "recentFiles" )
-			For Local file:=Eachin jobj.GetArray( "recentFiles" )
-				Local path:=file.ToString()
-				If GetFileType( path )<>FileType.File Continue
-				_recentFiles.Push( path )
-			Next
-		End
-		
-		If jobj.Contains( "theme" ) _theme=jobj.GetString( "theme" )
-		
-		If jobj.Contains( "themeScale" )
-			_themeScale=jobj.GetNumber( "themeScale" )
-			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 )
-		
-		If Not _projectView.OpenProjects _projectView.OpenProject( CurrentDir() )
-		
-		_projectView.ProjectOpened+=UpdateCloseProjectMenu
-		
-		UpdateRecentFilesMenu()
-		
-		UpdateCloseProjectMenu()
-
-		DeleteTmps()
-	End
-	
-	Protected
-	
-	Method OnKeyEvent( event:KeyEvent ) Override
-	
-		Select event.Type
-		Case EventType.KeyDown
-			Select event.Key
-			Case Key.Escape
-				If event.Modifiers & Modifier.Shift
-					_browsersTabView.Visible=Not _browsersTabView.Visible
-				Else
-					_consolesTabView.Visible=Not _consolesTabView.Visible
-				Endif
-			Case Key.Keypad1
-			End
-		End
-	End
-	
-	Method OnWindowEvent( event:WindowEvent ) Override
-
-		Select event.Type
-		Case EventType.WindowClose
-			SaveState()
-			_fileActions.quit.Trigger()
-		Default
-			Super.OnWindowEvent( event )
-		End
-	
-	End
-	
-	Private
-
-	Field _tmp:String
-	Field _mx2cc:String
-	Field _mx2ccDir:String
-	
-	Field _docsManager:DocumentManager
-	Field _fileActions:FileActions
-	Field _editActions:EditActions
-	Field _findActions:FindActions
-	Field _buildActions:BuildActions
-	Field _helpActions:HelpActions
-	
-	Field _buildConsole:Console
-	Field _outputConsole:Console
-	Field _helpView:HtmlView
-
-	Field _projectView:ProjectView
-	Field _docBrowser:DockingView
-	Field _debugView:DebugView
-	Field _helpTree:HelpTree
-
-	Field _docsTabView:TabView
-	Field _consolesTabView:TabView
-	Field _browsersTabView:TabView
-	
-	Field _forceStop:Action
-
-	Field _tabMenu:Menu
-	Field _newFiles:Menu
-	Field _fileMenu:Menu
-	Field _editMenu:Menu
-	Field _viewMenu:Menu
-	Field _buildMenu:Menu
-	Field _helpMenu:Menu
-	Field _menuBar:MenuBar
-	
-	Field _themesMenu:Menu
-	
-	Field _theme:String="default"
-	Field _themeScale:Float=1
-	
-	Field _contentView:DockingView
-
-	Field _recentFiles:=New StringStack
-	
-	Field _recentFilesMenu:Menu
-	Field _closeProjectMenu:Menu
-	
-	Method ToJson:JsonValue( rect:Recti )
-		Return New JsonArray( New JsonValue[]( New JsonNumber( rect.min.x ),New JsonNumber( rect.min.y ),New JsonNumber( rect.max.x ),New JsonNumber( rect.max.y ) ) )
-	End
-	
-	Method ToRecti:Recti( value:JsonValue )
-		Local json:=value.ToArray()
-		Return New Recti( json[0].ToNumber(),json[1].ToNumber(),json[2].ToNumber(),json[3].ToNumber() )
-	End
-	
-	Method AddRecentFile( path:String )
-	
-		_recentFiles.Remove( path )
-		_recentFiles.Insert( 0,path )
-		
-		If _recentFiles.Length>20 _recentFiles.Resize( 20 )
-	End
-	
-	Method UpdateRecentFilesMenu()
-	
-		_recentFilesMenu.Clear()
-		
-		Local recentFiles:=New StringStack
-		
-		For Local path:=Eachin _recentFiles
-			If GetFileType( path )<>FileType.File Continue
-		
-			_recentFilesMenu.AddAction( path ).Triggered=Lambda()
-				_docsManager.OpenDocument( path,True )
-			End
-			
-			recentFiles.Add( path )
-		Next
-		
-		_recentFiles=recentFiles
-	End
-	
-	Method UpdateCloseProjectMenu( dir:String="" )
-	
-		_closeProjectMenu.Clear()
-		
-		For Local dir:=Eachin _projectView.OpenProjects
-		
-			_closeProjectMenu.AddAction( dir ).Triggered=Lambda()
-			
-				_projectView.CloseProject( dir )
-				
-				UpdateCloseProjectMenu()
-			End
-			
-		Next
-	End
-	
-	Method AddZoomActions( menu:Menu )
-		
-		menu.AddAction( "Zoom in" ).Triggered=Lambda()
-			If _themeScale>=4 Return
-			
-			_themeScale+=.125
-
-			App.Theme.Scale=New Vec2f( _themeScale,_themeScale )
-		End
-		
-		menu.AddAction( "Zoom out" ).Triggered=Lambda()
-			If _themeScale<=.5 Return
-			
-			_themeScale-=.125
-
-			App.Theme.Scale=New Vec2f( _themeScale,_themeScale )
-		End
-		
-		menu.AddAction( "Reset zoom" ).Triggered=Lambda()
-		
-			_themeScale=1
-			
-			App.Theme.Scale=New Vec2f( _themeScale,_themeScale )
-		End
-	End
-
-	Method ThemeScaleMouseFilter( event:MouseEvent )
-	
-		If event.Eaten Return
-			
-		If event.Type=EventType.MouseWheel And event.Modifiers & Modifier.Menu
-			
-			If event.Wheel.y>0
-				If _themeScale<4 _themeScale+=0.125
-			Else
-				If _themeScale>.5 _themeScale-=0.125
-			Endif
-				
-			App.Theme.Scale=New Vec2f( _themeScale,_themeScale )
-
-			event.Eat()
-				
-		Else If event.Type=EventType.MouseDown And event.Button=MouseButton.Middle And event.Modifiers & Modifier.Menu
-			
-			_themeScale=1
-
-			App.Theme.Scale=New Vec2f( _themeScale,_themeScale )
-			
-			event.Eat()
-		Endif
-		
-	End
-	
-	Method CreateThemesMenu:Menu( text:String )
-	
-		Local menu:=New Menu( text )
-		
-		Local themes:=JsonObject.Load( "theme::themes.json" )
-		If Not themes Return menu
-		
-		For Local it:=Eachin themes
-			Local name:=it.Key
-			Local value:=it.Value.ToString()
-			menu.AddAction( name ).Triggered=Lambda()
-				_theme=value
-				If Not App.Theme.Load( _theme,New Vec2f( _themeScale ) )
-					If Not App.Theme.Load( "ted2-default" )
-					Endif
-					_theme="ted2-default"
-				Endif
-				SaveState()
-			End
-		Next
-		
-		Return menu
-	End
-		
-	Method OnAppIdle()
-	
-		_docsManager.Update()
-		_fileActions.Update()
-		_editActions.Update()
-		_findActions.Update()
-		_buildActions.Update()
-		
-		_forceStop.Enabled=_buildConsole.Running Or _outputConsole.Running
-	
-		App.Idle+=OnAppIdle
-		
-		GCCollect()	'thrash that GC!
-	End
-	
-End

+ 0 - 628
src/ted2/modulemanager.monkey2

@@ -1,628 +0,0 @@
-
-Namespace ted2
-
-Private
-
-Const MONKEY2_DOMAIN:="monkeycoder.co.nz"
-
-Class Module
-	Field dir:String
-	Field name:String
-	Field about:String
-	Field author:String
-	Field version:String
-	Field new_version:String
-	Field status:String
-	Field checked:Bool
-End
-
-Public
-
-Class ModuleManager Extends Dialog
-
-	Method New( console:Console )
-		Super.New( "Module Manager" )
-		
-		LoadEnv()
-		
-		_console=console
-		
-		_table=New TableView
-'		_table.Style=App.Theme.GetStyle( "TableView" )
-'		_table.Style.BackgroundColor=App.Theme.GetColor( "content" )
-		
-		_table.AddColumn( "Module",,"20%" )
-		_table.AddColumn( "About",,"40%" )
-		_table.AddColumn( "Version",,"10%" )
-		_table.AddColumn( "Status",,"17%" )
-		_table.AddColumn( "Action",,"13%" )
-		
-		_docker=New DockingView
-		_docker.ContentView=_table
-		
-		Local buttons:=New ToolBar
-		
-		buttons.AddView( New Label( "Filters: " ) )
-		
-		Local filters:=New String[]( "Local","Installed","Uninstalled" )
-		
-		For Local f:=Eachin filters
-		
-			Local button:=New CheckButton( f )
-			
-			button.Clicked=Lambda()
-				UpdateTable()
-			End
-			
-			buttons.AddView( button )
-			
-			_filters[f]=button
-		Next
-		
-		buttons.AddAction( "All" ).Triggered=Lambda()
-		
-			For Local button:=Eachin _filters.Values
-				button.Checked=True
-			Next
-			
-			UpdateTable()
-		End
-			
-		buttons.AddAction( "None" ).Triggered=Lambda()
-		
-			For Local button:=Eachin _filters.Values
-				button.Checked=False
-			Next
-			
-			UpdateTable()
-		End
-			
-		_docker.AddView( buttons,"bottom" )
-		
-		ContentView=_docker
-		
-		AddAction( "Perform Actions" ).Triggered=Lambda()
-		
-			If PerformActions() OnActivated()
-		End
-	
-		AddAction( "Close" ).Triggered=Lambda()
-			Close()
-			App.EndModal()
-		End
-		
-		MinSize=New Vec2i( 800,600 )
-		
-		Activated+=Lambda()
-			MainWindow.ShowBuildConsole( True )
-			App.BeginModal( Self )
-			OnActivated()
-		End
-	End
-	
-	Private
-	
-	Const downloadUrl:="http://"+MONKEY2_DOMAIN+"/send-file?file="
-	
-	Const downloadDir:="modules/module-manager/downloads/"
-	
-	Const backupDir:="modules/module-manager/backups/"
-	
-	Field _console:Console
-	Field _docker:DockingView
-	Field _modules:=New StringMap<Module>
-	Field _filters:=New StringMap<CheckButton>
-	Field _table:TableView
-	
-	Field _progress:ProgressDialog
-	Field _procmods:=New Stack<Module>
-	
-	Method WrapString:String( str:String,maxlen:Int )
-	
-		Local bits:=str.Split( " " ),out:="",len:=0
-		
-		For Local i:=0 Until bits.Length
-			Local n:=bits[i].Length+1
-			If len+n<=maxlen
-				out+=" "+bits[i]
-				len+=n
-			Else
-				out+="~n"+bits[i]
-				len=0
-			Endif
-		Next
-		
-		Return out.Trim()
-	End
-	
-	Method BackupModules:Bool()
-	
-		Local backupDir:="modules/module-manager/backups/"
-		
-		If Not DeleteDir( backupDir,True ) Or Not CreateDir( backupDir )
-			Alert( "Failed to create backup dir '"+backupDir+"'" )
-			Return False
-		End
-		
-		For Local module:=Eachin _procmods
-		
-'			Local src:="modules/"+module.name
-			Local src:=module.dir+module.name
-			
-			Local dst:=backupDir+module.name
-			
-			Select GetFileType( src )
-			Case FileType.Directory
-				If Not CopyDir( src,dst,True )
-					Alert( "Failed to copy module dir '"+src+"' to backup dir '"+dst+"'" )
-					Return False
-				Endif
-			End
-		
-		End
-		
-		Return True
-	End
-	
-	Method RestoreModules:Bool()
-
-		Local backupDir:="modules/module-manager/backups/"
-		
-		For Local module:=Eachin _procmods
-		
-			Local src:=backupDir+module.name
-			
-'			Local dst:="modules/"+module.name
-			Local dst:=module.dir+module.name
-			
-			Select GetFileType( src )
-			Case FileType.Directory
-			
-				If Not DeleteDir( dst,True ) Or Not CopyDir( src,dst,True )
-					Alert( "Failed to copy backup dir '"+src+"' to module dir '"+dst+"'" )
-					Return False
-				Endif
-			
-			Case FileType.None
-			
-				If Not DeleteDir( dst,True )
-					Alert( "Failed to delete module dir '"+dst+"'" )
-					Return False
-				Endif
-			End
-		
-		End
-		
-		Return True
-	End
-
-	Method DownloadModules:Bool()
-	
-		If Not CreateDir( downloadDir ) 
-			Alert( "Failed to create download dir '"+downloadDir+"'" )
-			Return False
-		Endif
-		
-		For Local module:=Eachin _procmods
-		
-			Local zip:=module.name+"-v"+module.new_version+".zip"
-			Local src:=downloadUrl+zip
-			Local dst:=downloadDir+zip
-
-#if __HOSTOS__="macos"
-			Local cmd:="curl -s -o ~q"+dst+"~q -data-binary ~q"+src+"~q"
-#Else
-			Local cmd:="wget -q -O ~q"+dst+"~q ~q"+src+"~q"
-#Endif
-			_progress.Text="Downloading "+zip+"..."
-			
-			Print "CD="+CurrentDir()
-			Print "cmd="+cmd
-			
-			If Not _console.Run( cmd )
-				Print "FALSE!"
-				Return False
-			Endif
-			
-			If _console.ExitCode
-				Alert( "Process '"+cmd+"' failed with exit code "+_console.Process.ExitCode )
-				Return False
-			Endif
-			
-			If Not GetFileSize( dst )
-				Alert( "Error downloading file '"+zip+"'" )
-				Return False
-			Endif
-		
-		Next
-		
-		Return True
-	End
-	
-	Method InstallModules:Bool()
-
-		For Local module:=Eachin _procmods
-
-			Local zip:=module.name+"-v"+module.new_version+".zip"
-			Local dst:=downloadDir+zip
-			
-'			If Not DeleteDir( "modules/"+module.name,True )
-			If Not DeleteDir( module.dir+module.name,True )
-				Alert( "Error deleting module directory '"+module.name+"'" )
-				Return False
-			End
-		
-'			If Not ExtractZip( dst,"modules",module.name+"/" )
-			If Not ExtractZip( dst,module.dir,module.name+"/" )
-				Alert( "Error extracting zip to '"+dst+"'" )
-				Return False
-			Endif
-			
-			'Alert( "Test failure!" )
-			'Return False
-		
-		Next
-		
-		Return True
-	End
-	
-	Method UpdateModules:Bool()
-	
-		For Local config:=0 Until 2
-			
-			Local cmd:=MainWindow.Mx2ccPath+" makemods -config="+(config ? "debug" Else "release")
-				
-			If Not _console.Run( cmd ) Return False
-			
-			If _console.Process.ExitCode
-				Alert( "Process '"+cmd+"' failed with exit code "+_console.Process.ExitCode )
-				Return False
-			Endif
-			
-		Next
-		
-		Local cmd:=MainWindow.Mx2ccPath+" makedocs"
-		
-		For Local module:=Eachin _procmods
-			
-			cmd+=" "+module.name
-		Next
-		
-		_console.Run( cmd )
-		
-		Return True
-	End
-	
-	Method PerformActions:Bool()
-	
-		_procmods=New Stack<Module>
-		
-		Local docker:=New DockingView
-		
-		For Local it:=Eachin _modules
-		
-			Local module:=it.Value
-			
-			If Not module.checked Continue
-			
-			_procmods.Push( module )
-			
-			If module.status="Installed"
-				docker.AddView( New Label( "Update module: "+module.name ),"top" )
-			Else
-				docker.AddView( New Label( "Install module: "+module.name ),"top" )
-			Endif
-		Next
-		
-		If Not _procmods.Length
-			Alert( "No actions to perform!" )
-			Return False
-		Endif
-		
-		
-		If Dialog.Run( "Proceed with actions?",New ScrollView( docker ),New String[]( "Proceed!","Cancel" ) )=1 Return False
-		
-
-		_progress=New ProgressDialog( "Module Manager","Performing actions..." )
-		
-		_progress.MinSize=New Vec2i( 320,0 )
-		
-		_progress.Open()
-		
-		App.BeginModal( _progress )
-		
-		
-		Local err:=""
-		Local restore:=False
-
-		_progress.Text="Downloading modules..."
-
-		If DownloadModules()
-
-			_progress.Text="Backing up modules..."
-
-			If BackupModules()
-			
-				restore=True
-				
-				_progress.Text="Installing modules..."
-				
-				If InstallModules()
-				
-					_progress.Text="Updating modules..."
-					
-					If UpdateModules()
-					
-						MainWindow.UpdateHelpTree()
-					
-					Else
-						err="Failed to update modules"
-					Endif
-				Else
-					err="Failed to install modules"
-				Endif
-			Else
-				err="Failed to backup modules"
-			Endif
-		Else
-			err="Failed to download modules"
-		Endif
-		
-		
-		App.EndModal()		
-		
-		_progress.Close()
-		
-		If Not err
-			Alert( "All actions successfully performed!" )
-			Return True
-		Endif
-		
-		Alert( "Error performing actions: "+err )
-		
-		If Not restore Return True
-		
-		If TextDialog.Run( "Restore modules","There was an error performing actions.~nWould you like to restore modules (recommended)?",New String[]( "Okay","Cancel" ) )<>0 Return True
-
-	
-		If RestoreModules()
-			Alert( "Modules successfully restored" )
-		Else
-			Alert( "Failed to restore modules - old modules may be found in 'modules/module-manager/backups'" )
-		Endif
-
-		Return True
-	End
-	
-	Method Version:Int( version:String )
-	
-		Local bits:=version.Split( "." )
-		If bits.Length<>3 Return -1
-		
-		Local i0:=Int( bits[0] )
-		If String(i0)<>bits[0] Return -1
-		
-		Local i1:=Int( bits[1] )
-		If String(i1)<>bits[1] Return -1
-		
-		Local i2:=Int( bits[2] )
-		If String(i2)<>bits[2] Return -1
-		
-		Return i0*1000000 + i1*1000 + i2
-	End
-	
-	Method OnActivated()
-	
-		_modules.Clear()
-
-		EnumLocalModules()
-		
-		EnumRemoteModules()
-		
-		_filters["Local"].Checked=False
-		_filters["Installed"].Checked=True
-		_filters["Uninstalled"].Checked=True
-		
-		UpdateTable()
-	End
-	
-	Method EnumRemoteModules:Bool()
-	
-		Local src:="http://monkeycoder.co.nz/module-manager/?modules=1"
-		
-		Local tmp:="tmp/modules.json"
-	
-		DeleteFile( tmp )
-		
-		Local progress:=New ProgressDialog( "Contacting server","Downloading modules list..." )
-		
-		progress.AddAction( "Cancel" ).Triggered=lambda()
-			_console.Terminate()
-			progress.Close()
-		End
-		
-		progress.Open()
-		
-#if __HOSTOS__="macos"
-		Local cmd:="curl -s -o ~q"+tmp+"~q ~q"+src+"~q"
-#Else
-		Local cmd:="wget -q -O ~q"+tmp+"~q ~q"+src+"~q"
-#Endif
-		If Not _console.Run( cmd )
-		
-			progress.Close()
-			Return False
-		Endif
-		
-		If _console.Process.ExitCode
-		
-			Alert( "Process '"+cmd+"' failed with exit code "+_console.Process.ExitCode )
-			progress.Close()
-			Return False
-		Endif
-		
-		progress.Close()
-		
-		Local str:=LoadString( tmp )
-		If Not str
-			Alert( "Failed to download modules list" )
-			Return False
-		Endif
-		
-		Local jobj:=JsonObject.Parse( str )
-		If Not jobj
-			Alert( "Failed to parse modules list" )
-			Return False
-		Endif
-		
-		Local mods:=jobj.ToObject()
-		
-		For Local it:=Eachin mods
-		
-			Local name:=it.Key
-			Local info:=it.Value.ToObject()
-			
-			Local about:=info["about"].ToString()
-			Local author:=info["author"].ToString()
-			Local version:=info["version"].ToString()
-			
-			Local module:=_modules[name]
-			If module
-				module.new_version=version
-				module.status="Installed"
-				If Version( module.new_version )>Version( module.version )
-					_filters["Installed"].Checked=True
-					module.checked=True
-				Endif
-			Else
-				module=New Module
-				module.dir=ModuleDirs[0]
-				module.version=version
-				module.new_version=version
-				module.status="Uninstalled"
-				_modules[name]=module
-			Endif
-			
-			module.name=name
-			module.about=about
-			module.author=author
-			
-			_modules[name]=module
-			
-		Next
-		
-		Return True
-
-	End
-	
-	Method EnumLocalModules()
-		
-		For Local moddir:=Eachin ModuleDirs
-			
-			For Local f:=Eachin LoadDir( moddir )
-			
-				Local dir:=moddir+f+"/"
-				If GetFileType( dir )<>FileType.Directory Continue
-				
-				Local str:=LoadString( dir+"module.json" )
-				If Not str Continue
-				
-				Local obj:=JsonObject.Parse( str )
-				If Not obj Continue
-				
-				Local jname:=obj["module"]
-				If Not jname Or Not Cast<JsonString>( jname ) Continue
-				
-				Local jabout:=obj["about"]
-				If Not jabout Or Not Cast<JsonString>( jabout ) Continue
-				
-				Local jauthor:=obj["author"]
-				If Not jauthor Or Not Cast<JsonString>( jauthor ) Continue
-				
-				Local jversion:=obj["version"]
-				If Not jversion Or Not Cast<JsonString>( jversion ) Continue
-				
-				Local name:=jname.ToString()
-				Local about:=jabout.ToString()
-				Local author:=jauthor.ToString()
-				Local version:=jversion.ToString()
-				
-				Local module:=New Module
-				module.dir=moddir
-				module.name=name
-				module.about=about
-				module.author=author
-				module.version=version
-				module.status="Local"
-				
-				_modules[name]=module
-			
-			Next
-		End
-	End
-
-	Method UpdateTable()
-	
-		_table.RemoveAllRows()
-		
-		Local style:=New Style( App.Theme.GetStyle( "Label" ) )
-		style.Border=New Recti( 0,-1,0,0 )
-		style.BorderColor=App.Theme.GetColor( "knob" )
-		
-		Local i:=0
-
-		For Local it:=Eachin _modules
-			
-			Local module:=it.Value
-			If Not _filters[module.status].Checked Continue
-			
-			_table.Rows+=1
-			
-			Local about:=module.about
-			
-			Local maxlen:=40
-			
-			about=WrapString( about,40 )
-			
-			Local action:=""
-			
-			Local status:=module.status
-			If status="Installed"
-				If Version( module.new_version )>Version( module.version )
-					status="Update available"
-					action="Update"
-				Endif
-			Else If status="Uninstalled"
-				action="Install"
-			Endif
-			
-			_table[0,i]=New Label( module.name )
-			_table[1,i]=New Label( about )
-			_table[2,i]=New Label( module.version )
-			_table[3,i]=New Label( status )
-			
-			If action
-				Local button:=New CheckButton( action )
-				button.Checked=module.checked
-				button.Clicked=Lambda()
-					module.checked=button.Checked
-				End
-				_table[4,i]=button
-			Else
-				_table[4,i]=New Label( "" )
-			Endif
-			
-			For Local j:=0 Until 5
-				_table[j,i].Layout="fill"
-				_table[j,i].Style=style
-			Next
-			
-			i+=1
-
-		Next
-		
-		App.RequestRender()
-	
-	End
-	
-End

+ 0 - 550
src/ted2/monkey2document.monkey2

@@ -1,550 +0,0 @@
-
-Namespace ted2
-
-Private
-
-Const COLOR_NONE:=0
-Const COLOR_IDENT:=1
-Const COLOR_KEYWORD:=2
-Const COLOR_STRING:=3
-Const COLOR_NUMBER:=4
-Const COLOR_COMMENT:=5
-Const COLOR_PREPROC:=6
-Const COLOR_OTHER:=7
-
-Global Keywords:=New StringMap<String>
-
-Function InitKeywords()
-
-	Local kws:=""
-	kws+="Namespace;Using;Import;Extern;"
-	kws+="Public;Private;Protected;Friend;"
-	kws+="Void;Bool;Byte;UByte;Short;UShort;Int;UInt;Long;ULong;Float;Double;String;Array;CString;Variant;TypeInfo;DeclInfo;Object;Continue;Exit;"
-	kws+="New;Self;Super;Eachin;True;False;Null;Where;"
-	kws+="Alias;Const;Local;Global;Field;Method;Function;Property;Getter;Setter;Operator;Lambda;"
-	kws+="Enum;Class;Interface;Struct;Extends;Implements;Virtual;Override;Abstract;Final;Inline;"
-	kws+="Var;Varptr;Ptr;"
-	kws+="Not;Mod;And;Or;Shl;Shr;End;"
-	kws+="If;Then;Else;Elseif;Endif;"
-	kws+="While;Wend;"
-	kws+="Repeat;Until;Forever;"
-	kws+="For;To;Step;Next;"
-	kws+="Select;Case;Default;"
-	kws+="Try;Catch;Throw;Throwable;"
-	kws+="Return;Print;Static;Cast;Extension;"
-	kws+="Typeof;Finalize"
-	
-	For Local kw:=Eachin kws.Split( ";" )
-		Keywords[kw.ToLower()]=kw
-	Next
-End
-
-Function Monkey2TextHighlighter:Int( text:String,colors:Byte[],sol:Int,eol:Int,state:Int )
-
-	Local i0:=sol
-	
-	Local icolor:=0
-	Local istart:=sol
-	Local preproc:=False
-
-	'comment nest
-	'
-	Local cnest:=state & 255
-	If cnest=255 cnest=-1
-	
-	'block string flag
-	'	
-	Local blkstr:=(state & 256)=0
-	
-	If cnest<>-1 
-		icolor=COLOR_COMMENT
-	Else If blkstr
-		icolor=COLOR_STRING
-	Endif
-	
-	While i0<eol
-	
-		Local start:=i0
-		Local chr:=text[i0]
-		i0+=1
-		
-		If IsSpace( chr ) Continue
-		
-		If blkstr
-			If chr=34 blkstr=False
-			Continue
-		Endif
-		
-		If chr=35 And istart=sol
-			preproc=True
-			If cnest=-1 icolor=COLOR_PREPROC
-			Continue
-		Endif
-		
-		If preproc And (IsAlpha( chr ) Or chr=95)
-
-			While i0<eol And (IsAlpha( text[i0] ) Or IsDigit( text[i0] )  Or text[i0]=95)
-				i0+=1
-			Wend
-			
-			Local id:=text.Slice( start,i0 )
-			
-			Select id.ToLower()
-			Case "rem"
-				cnest+=1
-				icolor=COLOR_COMMENT
-			Case "end"
-				If cnest<>-1
-					cnest-=1
-					icolor=COLOR_COMMENT
-				Endif
-			End
-			
-			Exit
-		
-		Endif
-		
-		If cnest<>-1 Or preproc Exit
-		
-		Local color:=icolor
-		
-		If chr=39
-		
-			i0=eol
-			
-			color=COLOR_COMMENT
-			
-		Else If chr=34
-		
-			While i0<eol And text[i0]<>34
-				i0+=1
-			Wend
-			If i0<eol
-				i0+=1
-			Else
-				blkstr=True
-			Endif
-			
-			color=COLOR_STRING
-			
-		Else If IsAlpha( chr ) Or chr=95
-
-			While i0<eol And (IsAlpha( text[i0] ) Or IsDigit( text[i0] )  Or text[i0]=95)
-				i0+=1
-			Wend
-			
-			Local id:=text.Slice( start,i0 )
-			
-			If preproc And istart=sol
-			
-				Select id.ToLower()
-				Case "rem"				
-					cnest+=1
-				Case "end"
-					cnest=Max( cnest-1,-1 )
-				End
-				
-				icolor=COLOR_COMMENT
-				
-				Exit
-			Else
-			
-				color=COLOR_IDENT
-				
-				If Keywords.Contains( id.ToLower() ) color=COLOR_KEYWORD
-			
-			Endif
-			
-		Else If IsDigit( chr )
-		
-			While i0<eol And IsDigit( text[i0] )
-				i0+=1
-			Wend
-			
-			color=COLOR_NUMBER
-			
-		Else If chr=36 And i0<eol And IsHexDigit( text[i0] )
-		
-			i0+=1
-			While i0<eol And IsHexDigit( text[i0] )
-				i0+=1
-			Wend
-			
-			color=COLOR_NUMBER
-			
-		Else
-			
-			color=COLOR_NONE
-			
-		Endif
-		
-		If color=icolor Continue
-		
-		For Local i:=istart Until start
-			colors[i]=icolor
-		Next
-		
-		icolor=color
-		istart=start
-	
-	Wend
-	
-	For Local i:=istart Until eol
-		colors[i]=icolor
-	Next
-	
-	state=cnest & 255
-	
-	If Not blkstr state|=256
-	
-	Return state
-End
-
-Public
-
-Class Monkey2DocumentView Extends Ted2TextView
-
-	Method New( doc:Monkey2Document )
-		_doc=doc
-		
-		Document=_doc.TextDocument
-		
-		AddView( New GutterView( Self ),"left" )
-	End
-	
-	Protected
-	
-	Method OnRenderContent( canvas:Canvas ) Override
-	
-		Local color:=canvas.Color
-		
-		If _doc._errors.Length
-		
-			canvas.Color=New Color( .5,0,0 )
-			
-			For Local err:=Eachin _doc._errors
-				Local r:=LineRect( err.line )
-				r.min.x=0
-				r.max.x=Width
-				canvas.DrawRect( r )
-			Next
-			
-		Endif
-		
-		If _doc._debugLine<>-1
-
-			Local line:=_doc._debugLine
-			If line<0 Or line>=Document.NumLines Return
-			
-			canvas.Color=New Color( 0,.5,0 )
-			Local r:=LineRect( line )
-			r.min.x=0
-			r.max.x=Width
-			canvas.DrawRect( r )
-		Endif
-		
-		canvas.Color=color
-		
-		Super.OnRenderContent( canvas )
-	End
-	
-	Private
-	
-	Field _doc:Monkey2Document
-	
-	Field _typing:Bool
-	
-	Method Capitalize( all:Bool )
-	
-		_typing=False
-	
-		Local cursor:=Cursor
-		
-		'ignore comments...
-		'
-		Local state:=Document.LineState( Document.FindLine( cursor ) )
-		If state & 255 <> 255 Return
-		
-		Local text:=Text
-		Local start:=cursor
-		Local term:=all ? text.Length Else start
-
-		'find start of ident
-		'		
-		While start And IsIdent( text[start-1] )
-			start-=1
-		Wend
-		While start<cursor And IsDigit( text[start] )
-			start+=1
-		Wend
-		If start>=term Or Not IsIdent( text[start] ) Return
-		
-		'only capitalize keywords and idents
-		'
-		Local color:=Document.Colors[start]
-		If color<>COLOR_KEYWORD And color<>COLOR_IDENT
-			'
-			If color<>COLOR_PREPROC Return
-			'
-			'only do first ident on preproc line
-			'
-			Local i:=start
-			While i And text[i-1]<=32
-				i-=1
-			Wend
-			If Not i Or text[i-1]<>35 Return
-			i-=1
-			While i And text[i-1]<>10
-				i-=1
-				If text[i]>32 Return
-			Wend
-			'
-		Endif
-
-		'find end of ident
-		Local ends:=start
-		'
-		While ends<term And IsIdent( text[ends] ) And text[ends]<>10
-			ends+=1
-		Wend
-		If ends=start return
-
-		Local ident:=text.Slice( start,ends )
-
-		Local kw:=Keywords[ident.ToLower()]
-		If Not kw Or kw=ident Return
-		
-		Document.ReplaceText( start,ends,kw )
-		
-	End
-	
-	Method IdentNearestCursor:String()
-	
-		Local text:=Text
-		Local start:=Cursor
-		
-		If start And start=text.Length start-=1
-		
-		While start And Not IsIdent( text[start] ) And text[start-1]<>10
-			start-=1
-		Wend
-		
-		While start And IsIdent( text[start-1] ) And text[start-1]<>10
-			start-=1
-		Wend
-		
-		While start<text.Length And IsDigit( text[start] ) And text[start]<>10
-			start+=1
-		Wend
-		
-		Local ends:=start
-		
-		While ends<text.Length And IsIdent( text[ends] ) And text[ends]<>10
-			ends+=1
-		Wend
-		
-		Return text.Slice( start,ends )
-	End
-	
-	Method OnKeyDown:Bool( key:Key,modifiers:Modifier ) Override
-	
-		Select key
-		Case Key.F1
-			
-			Local ident:=IdentNearestCursor()
-				
-			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 )
-				
-		Case Key.Left
-			
-			If _typing
-				Local text:=Text
-				Local cursor:=Cursor
-				If cursor And Not IsIdent( text[cursor-1] )
-					Capitalize( True )
-				Endif
-			Endif
-				
-		Case Key.Right
-			
-			If _typing
-				Local text:=Text
-				Local cursor:=Cursor
-				If cursor<text.Length And Not IsIdent( text[cursor] )
-					Capitalize( True )
-				Endif
-			Endif
-				
-		Case Key.Up,Key.Down
-			
-			Capitalize( True )	'in cased we missed anything...
-		End
-		
-		Return Super.OnKeyDown( key,modifiers )
-	End
-	
-	Method OnKeyChar( text:String ) Override
-
-		If IsIdent( text[0] )
-			_typing=True
-		Else
-			If _typing Capitalize( False )
-		Endif
-		
-		Super.OnKeyChar( text )
-	End
-	
-End
-
-Class Monkey2Document Extends Ted2Document
-
-	Method New( path:String )
-		Super.New( path )
-	
-		InitKeywords()
-		
-		_doc=New TextDocument
-		
-		_doc.TextHighlighter=Monkey2TextHighlighter
-		
-		_browser=New Monkey2TreeView( _doc )
-		
-		_doc.TextChanged+=Lambda()
-			Dirty=True
-		End
-		
-		_doc.LinesModified=Lambda( first:Int,removed:Int,inserted:Int )
-			Local put:=0
-			For Local get:=0 Until _errors.Length
-				Local err:=_errors[get]
-				If err.line>=first
-					If err.line<first+removed 
-						err.removed=True
-						Continue
-					Endif
-					err.line+=(inserted-removed)
-				Endif
-				_errors[put]=err
-				put+=1
-			Next
-			_errors.Resize( put )
-		End
-
-	
-		_view=New Monkey2DocumentView( Self )
-	End
-	
-	Property TextDocument:TextDocument()
-	
-		Return _doc
-	End
-	
-	Property DebugLine:Int()
-	
-		Return _debugLine
-	
-	Setter( debugLine:Int )
-		If debugLine=_debugLine Return
-		
-		_debugLine=debugLine
-		If _debugLine=-1 Return
-		
-		_view.GotoLine( _debugLine )
-	End
-	
-	Property Errors:Stack<BuildError>()
-	
-		Return _errors
-	End
-	
-	Protected
-	
-	Method OnLoad:Bool() Override
-	
-		Local text:=stringio.LoadString( Path )
-		
-		_doc.Text=text
-		
-		Return True
-	End
-	
-	Method OnSave:Bool() Override
-	
-		Local text:=_doc.Text
-		
-		Return stringio.SaveString( text,Path )
-	
-	End
-	
-	Method OnCreateView:View() Override
-	
-		Return _view
-	End
-	
-	Method OnCreateBrowser:View() Override
-	
-		Return _browser
-	End
-	
-	Private
-
-	Field _doc:TextDocument
-
-	Field _view:Monkey2DocumentView
-	
-	Field _browser:Monkey2TreeView
-
-	Field _errors:=New Stack<BuildError>
-
-	Field _debugLine:Int=-1
-End
-
-Class Monkey2DocumentType Extends Ted2DocumentType
-
-	Protected
-	
-	Method New()
-		AddPlugin( Self )
-		
-		Extensions=New String[]( ".monkey2",".ogg" )
-	End
-	
-	Method OnCreateDocument:Ted2Document( path:String ) Override
-	
-		Return New Monkey2Document( path )
-	End
-	
-	Private
-	
-	Global _instance:=New Monkey2DocumentType
-	
-End
-

+ 0 - 59
src/ted2/monkey2treeview.monkey2

@@ -1,59 +0,0 @@
-
-Namespace ted2
-
-Class Monkey2TreeView Extends JsonTreeView
-
-	Method New( doc:TextDocument )
-	
-		_doc=doc
-	
-		_doc.TextChanged+=OnTextChanged
-
-	End
-	
-	Private
-	
-	Field _doc:TextDocument
-	
-	Field _timer:Timer
-	
-	Method OnTextChanged()
-	
-		If _timer _timer.Cancel()
-		
-		_timer=New Timer( 1,Lambda()
-		
-			Local tmp:=MainWindow.AllocTmpPath( "_mx2cc_parse_",".monkey2" )
-			
-			Print "parsing:"+tmp
-			
-			SaveString( _doc.Text,tmp )
-		
-			UpdateTree( tmp )
-			
-			Print "finished:"+tmp
-			
-			DeleteFile( tmp )
-			
-			_timer.Cancel()
-			
-			_timer=Null
-		
-		End )
-	End
-	
-	Method UpdateTree( path:String )
-	
-		Local cmd:="~q"+MainWindow.Mx2ccPath+"~q makeapp -parse -geninfo ~q"+path+"~q"
-					
-		Local str:=LoadString( "process::"+cmd )
-		
-		Local jobj:JsonObject,i:=str.Find( "{" )
-		
-		If i<>-1 jobj=JsonObject.Parse( str.Slice( i ) )
-		
-		Super.Value=jobj
-		
-	End
-
-End

+ 0 - 157
src/ted2/mx2ccenv.monkey2

@@ -1,157 +0,0 @@
-
-Namespace ted2
-
-Global ModuleDirs:String[]
-
-Function GetEnv:String( name:String )
-
-	Local p:=libc.getenv( name )
-	If p Return String.FromCString( p )
-	
-	Return ""
-End
-
-Function SetEnv( name:String,value:String )
-
-	libc.setenv( name,value,1 )
-End
-
-Private
-
-#If __TARGET__="windows"
-Const HostOS:="windows"
-#Else If __TARGET__="macos"
-Const HostOS:="macos"
-#Else If __TARGET__="linux"
-Const HostOS:="linux"
-#Else IF __TARGET__="raspbian"
-Const HostOS:="raspbian"
-#Else
-Const HostOS:=""
-#Endif
-
-Function ReplaceEnv:String( str:String,lineid:Int )
-
-	Local i0:=0
-
-	Repeat
-		Local i1:=str.Find( "${",i0 )
-		If i1=-1 Exit
-		
-		Local i2:=str.Find( "}",i1+2 )
-		If i2=-1 Exit
-		
-		Local name:=str.Slice( i1+2,i2 ).Trim()
-		Local value:=GetEnv( name )
-		
-		str=str.Slice( 0,i1 )+value+str.Slice( i2+1 )
-		i0=i1+value.Length
-		
-	Forever
-	
-	Return str
-End
-
-Public
-
-Function LoadEnv()
-
-	Local path:="bin/env_"+HostOS+".txt"
-
-	SetEnv( "MX2_HOME",CurrentDir() )
-	SetEnv( "MX2_MODULES",CurrentDir()+"modules" )
-
-	Local lineid:=0
-	
-	For Local line:=Eachin stringio.LoadString( path ).Split( "~n" )
-		lineid+=1
-	
-		Local i:=line.Find( "'" )
-		If i<>-1 line=line.Slice( 0,i )
-		
-		line=line.Trim()
-		If Not line Continue
-		
-		i=line.Find( "=" )
-		If i=-1 Continue
-		
-		Local name:=line.Slice( 0,i ).Trim()
-		Local value:=line.Slice( i+1 ).Trim()
-		
-		value=ReplaceEnv( value,lineid )
-		
-		SetEnv( name,value )
-	Next
-	
-	Local moddirs:=New StringStack
-	moddirs.Add( CurrentDir()+"modules/" )
-	For Local moddir:=Eachin GetEnv( "MX2_MODULE_DIRS" ).Split( ";" )
-		moddir=moddir.Replace( "\","/" )
-		If GetFileType( moddir )<>FileType.Directory Continue
-		moddir=RealPath( moddir )
-		If Not moddir.EndsWith( "/" ) moddir+="/"
-		If Not moddirs.Contains( moddir ) moddirs.Add( moddir )
-	Next
-	ModuleDirs=moddirs.ToArray()
-	
-End
-
-Function EnumValidTargets:StringStack( console:Console )
-
-	LoadEnv()
-	
-	Local targets:=New StringStack
-	
-	targets.Push( "desktop" )
-	targets.Push( "emscripten" )
-	targets.Push( "android" )
-#If __TARGET__="macos"
-	targets.Push( "ios" )
-#Endif
-
-	Return targets
-	
-	'FIXME - too slow at startup, esp. on Mac!
-	
-	console.Write( "~n***** Checking for valid targets *****~n~n" )
-	
-	CreateDir( "tmp" )
-	
-	If Not libc.system( "g++ --version >tmp/tmp.txt" )
-		Local tmp:=LoadString( "tmp/tmp.txt" )
-		console.Write( "Desktop target OK.~n" )
-		targets.Push( "desktop" )
-	Else
-		console.Write( "Desktop target unavailable - can't find desktop 'g++' tool.~n" )
-	Endif
-	
-	If Not libc.system( "em++ --version >tmp/tmp.txt" )
-		Local tmp:=LoadString( "tmp/tmp.txt" )
-		console.Write( "Emscripten target OK.~n" )
-		targets.Push( "emscripten" )
-	Else
-		console.Write( "Emscripten target unavailable - can't find 'em++' tool.~n" )
-	Endif
-	
-	If Not libc.system( "ndk-build --version >tmp/tmp.txt" )
-		Local tmp:=LoadString( "tmp/tmp.txt" )
-		console.Write( "Android target OK.~n" )
-		targets.Push( "android" )
-	Else
-		console.Write( "Android target unavailable - Can't find 'ndk-build' tool.~n" )
-	Endif
-	
-#if __TARGET__="macos"
-	If targets.Contains( "Desktop" )
-		console.Write( "iOS target OK.~n" )
-		targets.Push( "ios" )
-	Else
-		console.Write( "iOS target unavailable - Can't find 'g++' tool.~n" )
-	Endif
-#else
-		console.Write( "iOS target unavailable (iOS only supported on MacOS).~n" )
-#endif
-
-	Return targets
-
-End

+ 0 - 98
src/ted2/plaintextdocument.monkey2

@@ -1,98 +0,0 @@
-
-Namespace ted2
-
-Class PlainTextDocumentView Extends TextView
-
-	Method New( doc:PlainTextDocument )
-
-		_doc=doc
-		
-		Document=_doc.TextDocument
-		
-		AddView( New GutterView( Self ),"left" )
-		
-		ContentView.Style.Border=New Recti( -4,-4,4,4 )
-		
-		CursorColor=New Color( 0,.5,1 )
-
-		SelectionColor=New Color( .4,.4,.4 )
-		
-		WordWrap=True
-	End
-	
-	Private
-	
-	Field _doc:PlainTextDocument
-	
-End
-
-Class PlainTextDocument Extends Ted2Document
-
-	Method New( path:String )
-		Super.New( path )
-		
-		_doc=New TextDocument
-		
-		_doc.TextChanged=Lambda()
-			Dirty=True
-		End
-		
-		_view=New PlainTextDocumentView( Self )
-	End
-	
-	Property TextDocument:TextDocument()
-	
-		Return _doc
-	End
-	
-	Protected
-	
-	Method OnLoad:Bool() Override
-	
-		Local text:=stringio.LoadString( Path )
-		
-		_doc.Text=text
-		
-		Return True
-	End
-	
-	Method OnSave:Bool() Override
-	
-		Local text:=_doc.Text
-		
-		Return stringio.SaveString( text,Path )
-	End
-	
-	Method OnCreateView:PlainTextDocumentView() Override
-	
-		Return _view
-	End
-	
-	Private
-	
-	Field _doc:TextDocument
-	
-	Field _view:PlainTextDocumentView
-
-End
-
-Class PlainTextDocumentType Extends Ted2DocumentType
-
-	Protected
-	
-	Method New()
-		AddPlugin( Self )
-		
-		Extensions=New String[]( ".h",".hpp",".hxx",".c",".cpp",".cxx",".m",".mm",".s",".asm",".java",".html",".js",".css",".php",".md",".xml",".ini",".sh",".bat",".glsl",".txt",".gradle" )
-	End
-	
-	Method OnCreateDocument:Ted2Document( path:String ) Override
-	
-		Return New PlainTextDocument( path )
-	End
-	
-	Private
-	
-	Global _instance:=New PlainTextDocumentType
-	
-End

+ 0 - 52
src/ted2/plugin.monkey2

@@ -1,52 +0,0 @@
-
-Namespace ted2
-
-Class Plugin
-
-	Property Name:String() Virtual
-	
-		Return "<unititled plugin>"
-	End
-	
-	Function PluginsOfType<T>:T[]() Where T Extends Plugin
-		
-		Return Plugins<T>.Plugins().ToArray()
-	End
-	
-	'***** INTERNAL *****
-	Function CreatePlugins()
-	
-		For Local plugin:=Eachin PluginsOfType<Plugin>()
-			plugin.OnCreate()
-		Next
-	
-	End
-	
-	Protected
-	
-	Method New()
-
-		AddPlugin( Self )
-	End
-	
-	Method AddPlugin<T>( plugin:T ) Where T Extends Plugin
-	
-		Plugins<T>.Plugins().Add( plugin )
-	End
-	
-	Method OnCreate() Virtual
-	
-	End
-
-	Private
-	
-	Struct Plugins<T>
-		Global _plugins:Stack<T>
-		
-		Function Plugins:Stack<T>()
-			If Not _plugins _plugins=New Stack<T>
-			Return _plugins
-		End
-	End
-
-End

+ 0 - 211
src/ted2/projectview.monkey2

@@ -1,211 +0,0 @@
-
-Namespace ted2
-
-Class ProjectView Extends ScrollView
-
-	Field openProject:Action
-	
-	Field ProjectOpened:Void( dir:String )
-
-	Method New( docs:DocumentManager )
-	
-		_docs=docs
-	
-		_docker=New DockingView
-		
-		ContentView=_docker
-		
-		_docker.ContentView=New TreeView
-		
-		openProject=New Action( "Open project" )
-		openProject.Triggered=OnOpenProject
-	End
-	
-	Property OpenProjects:String[]()
-	
-		Local projs:=New StringStack
-		For Local proj:=Eachin _projects.Keys
-			projs.Add( proj )
-		Next
-		
-'		projs.Add( _projects.Keys )	'Should work - FIXME
-		
-		Return projs.ToArray()
-	End
-	
-	Method OpenProject:Bool( dir:String )
-	
-		dir=StripSlashes( dir )
-		
-		If _projects[dir] Return False
-		
-		If GetFileType( dir )<>FileType.Directory Return False
-	
-		Local browser:=New FileBrowser( dir )
-		
-		browser.FileClicked+=Lambda( path:String )
-		
-			If GetFileType( path )=FileType.File
-			
-				New Fiber( Lambda()
-					_docs.OpenDocument( path,True )
-				End )
-				
-			Endif
-			
-		End
-		
-		browser.FileRightClicked+=Lambda( path:String )
-		
-			Local menu:=New Menu
-		
-			Select GetFileType( path )
-			Case FileType.Directory
-			
-				menu.AddAction( "New File" ).Triggered=Lambda()
-				
-					Local file:=RequestString( "New file name:" )
-					If Not file Return
-					
-					Local tpath:=path+"/"+file
-					
-					If GetFileType( tpath )<>FileType.None
-						Alert( "A file or directory already exists at '"+tpath+"'" )
-						Return
-					End
-					
-					If Not CreateFile( tpath )
-						Alert( "Failed to create file '"+file+"'" )
-					Endif
-					
-					browser.Update()
-					Return
-				End
-		
-				menu.AddAction( "New Folder" ).Triggered=Lambda()
-				
-					Local dir:=RequestString( "New folder name:" )
-					If Not dir Return
-					
-					Local tpath:=path+"/"+dir
-					
-					If GetFileType( tpath )<>FileType.None
-						Alert( "A file or directory already exists at '"+tpath+"'" )
-						Return
-					End
-					
-					If Not CreateDir( tpath )
-						Alert( "Failed to create folder '"+dir+"'" )
-						Return
-					Endif
-					
-					browser.Update()
-					Return
-				End
-				
-				menu.AddAction( "Delete" ).Triggered=Lambda()
-
-					If Not RequestOkay( "Really delete folder '"+path+"'?" ) Return
-					
-					If DeleteDir( path,True )
-						browser.Update()
-						Return
-					Endif
-					
-					Alert( "Failed to delete folder '"+path+"'" )
-				End
-				
-			Case FileType.File
-			
-				menu.AddAction( "Open On Desktop" ).Triggered=Lambda()
-				
-					requesters.OpenUrl( path )
-				End
-				
-				menu.AddSeparator()
-			
-				menu.AddAction( "Delete" ).Triggered=Lambda()
-				
-					If Not RequestOkay( "Really delete file '"+path+"'?" ) return
-				
-					If DeleteFile( path )
-					
-						Local doc:=_docs.FindDocument( path )
-						
-						If doc doc.Close()
-					
-						browser.Update()
-						Return
-					Endif
-					
-					Alert( "Failed to delete file: '"+path+"'" )
-				End
-			
-			Default
-			
-				Return
-			End
-			
-			menu.Open()
-		End
-		
-		browser.RootNode.Text=StripDir( dir )+" ("+dir+")"
-		
-		_docker.AddView( browser,"top" )
-		
-		_projects[dir]=browser
-		
-		ProjectOpened( dir )
-
-		Return True
-	End
-	
-	Method CloseProject( dir:String )
-
-		dir=StripSlashes( dir )
-		
-		Local view:=_projects[dir]
-		If Not view Return
-		
-		_docker.RemoveView( view )
-		
-		_projects.Remove( dir )
-	End
-	
-	Method SaveState( jobj:JsonObject )
-	
-		Local jarr:=New JsonArray
-		For Local it:=Eachin _projects
-			jarr.Add( New JsonString( it.Key ) )
-		Next
-		jobj["openProjects"]=jarr
-	End
-	
-	Method LoadState( jobj:JsonObject )
-	
-		If jobj.Contains( "openProjects" )
-			local arr:=jobj["openProjects"].ToArray()
-			For Local dir:=Eachin arr
-				OpenProject( dir.ToString() )
-			Next
-		Endif
-		
-	End
-	
-	Private
-	
-	Field _docs:DocumentManager
-	
-	Field _docker:=New DockingView
-	
-	Field _projects:=New StringMap<FileBrowser>
-
-	Method OnOpenProject()
-	
-		Local dir:=MainWindow.RequestDir( "Select Project Directory...","" )
-		If Not dir Return
-		
-		OpenProject( dir )
-	End
-	
-End

+ 0 - 208
src/ted2/scenedocument.monkey2

@@ -1,208 +0,0 @@
-
-Namespace ted2
-
-#Import "<mojo3d>"
-#Import "<mojo3d-loaders>"
-
-Using mojo3d..
-
-Class SceneDocumentView Extends View
-
-	Method New( doc:SceneDocument )
-		_doc=doc
-		
-		Layout="fill"
-	End
-	
-	Protected
-	
-	Method OnRender( canvas:Canvas ) Override
-	
-		For Local x:=0 Until Width Step 64
-			For Local y:=0 Until Height Step 64
-				canvas.Color=(x~y) & 64 ? New Color( .1,.1,.1 ) Else New Color( .05,.05,.05 )
-				canvas.DrawRect( x,y,64,64 )
-			Next
-		Next
-		
-		Local model:=_doc.Model
-		If Not model
-			canvas.Clear( Color.Sky )
-			Return
-		Endif
-		
-		RequestRender()
-		
-		Global _anim:Float=0
-		
-		If Keyboard.KeyDown( Key.A )
-			If _doc.Model.Animator
-				_anim+=12.0/60.0
-				_doc.Model.Animator.Animate( 0,_anim )
-			Endif
-		Else
-			_anim=0
-		Endif
-		
-		_doc.Scene.Render( canvas,_doc.Camera )
-	End
-	
-	Method OnMouseEvent( event:MouseEvent ) Override
-		
-		If Not _doc.Model Return
-		
-		Global _v:Vec2i
-		Global _f:Bool
-		
-		Select event.Type
-		Case EventType.MouseDown
-			_v=event.Location
-			_f=True
-		Case EventType.MouseMove
-			If _f
-				Local dv:=event.Location-_v
-				Local rx:=Float(dv.x)/Height * +180.0
-				Local ry:=Float(dv.y)/Height * -180.0
-				_doc.Model.Rotate( ry,rx,0 )
-				_v=event.Location
-			Endif
-		Case EventType.MouseUp
-			_f=False
-		Case EventType.MouseWheel
-			_doc.Camera.MoveZ( Float(event.Wheel.y)*-.1 )
-		End
-	End
-	
-	Method OnKeyEvent( event:KeyEvent ) Override
-		
-		If event.Type=EventType.KeyDown
-			Select event.Key
-			Case Key.R
-				_doc.Camera.Position=New Vec3f(0,0,-2.5)
-				_doc.Model.Rotation=New Vec3f(0,0,0)
-			Case Key.S
-				_doc.Light.CastsShadow=Not _doc.Light.CastsShadow
-			Case Key.A
-				
-			End
-		Endif
-		
-	End
-	
-	Private
-
-	Field _doc:SceneDocument
-End
-
-Class SceneDocument Extends Ted2Document
-	
-	Method New( path:String )
-		Super.New( path )
-		
-		_view=New SceneDocumentView( Self )
-		
-		_scene=New Scene
-		
-		Scene.SetCurrent( _scene )
-		
-		_camera=New Camera
-		_camera.Near=.01
-		_camera.Far=10
-		_camera.MoveZ( -2.5 )
-			
-		_light=New Light
-		_light.RotateX( Pi/2 )
-		
-		_model=null
-		
-		Scene.SetCurrent( Null )
-	End
-	
-	Property Scene:Scene()
-		
-		Return _scene
-	End
-	
-	Property Camera:Camera()
-		
-		Return _camera
-	End
-	
-	Property Light:Light()
-		
-		Return _light
-	End
-	
-	Property Model:Model()
-	
-		Return _model
-	End
-	
-	Protected
-	
-	Method OnLoad:Bool() Override
-		
-		If _model _model.Destroy()
-		
-		Print "Loading model:"+Path
-
-		Scene.SetCurrent( _scene )
-		
-		_model=Model.Load( Path )
-		
-		Scene.SetCurrent( Null )
-
-		If _model _model.Mesh.FitVertices( New Boxf( -1,1 ) )
-	
-		Return True
-	End
-	
-	Method OnSave:Bool() Override
-
-		Return False
-	End
-	
-	Method OnClose() Override
-		
-		_scene.DestroyAllEntities()
-		
-	End
-	
-	Method OnCreateView:SceneDocumentView() Override
-	
-		Return _view
-	End
-	
-	Private
-	
-	Field _view:SceneDocumentView
-	
-	Field _scene:Scene
-	
-	Field _camera:Camera
-	
-	Field _light:Light
-	
-	Field _model:Model
-End
-
-Class SceneDocumentType Extends Ted2DocumentType
-
-	Protected
-	
-	Method New()
-		AddPlugin( Self )
-		
-		Extensions=New String[]( ".gltf",".b3d",".3ds",".obj",".dae",".fbx",".blend",".x" )
-	End
-	
-	Method OnCreateDocument:Ted2Document( path:String ) Override
-		
-		Return New SceneDocument( path )
-	End
-	
-	Private
-	
-	Global _instance:=New SceneDocumentType
-	
-End

+ 0 - 106
src/ted2/ted2.monkey2

@@ -1,106 +0,0 @@
-
-#If __TARGET__="windows"
-#Import "bin/wget.exe"
-#End
-
-#Import "<std>"
-#Import "<mojo>"
-#Import "<mojox>"
-#Import "<tinyxml2>"
-
-#Import "mainwindow"
-#Import "documentmanager"
-#import "fileactions"
-#import "editactions"
-#import "findactions"
-#import "finddialog"
-#import "buildactions"
-#import "helpactions"
-#import "debugview"
-#import "projectview"
-#import "helptree"
-#Import "modulemanager"
-#import "ted2textview"
-#Import "jsontreeview"
-#Import "xmltreeview"
-#Import "monkey2treeview"
-#Import "gutterview"
-
-#import "plugin"
-#Import "ted2document"
-#Import "monkey2document"
-#Import "plaintextdocument"
-#Import "imagedocument"
-#import "audiodocument"
-#import "jsondocument"
-#import "xmldocument"
-#Import "scenedocument"
-
-#import "textviewkeyeventfilter"
-
-#Import "buildproduct"
-#Import "editproductdialog"
-
-#Import "mx2ccenv"
-
-Namespace ted2
-
-Using std..
-Using mojo..
-Using mojox..
-Using tinyxml2..
-
-Function Main()
-
-#If __DESKTOP_TARGET__
-		
-	ChangeDir( AppDir() )
-	
-	While GetFileType( "bin" )<>FileType.Directory Or GetFileType( "modules" )<>FileType.Directory
-
-		If IsRootDir( CurrentDir() )
-			Print "Error initializing Ted2 - can't find working dir!"
-			libc.exit_( 1 )
-		Endif
-		
-		ChangeDir( ExtractDir( CurrentDir() ) )
-	Wend
-	
-#Endif
-	
-	'load ted2 state
-	'
-	Local jobj:=JsonObject.Load( "bin/ted2.state.json" )
-	If Not jobj jobj=New JsonObject
-
-	'initial theme
-	'	
-	If Not jobj.Contains( "theme" ) jobj["theme"]=New JsonString( "theme-classic-dark" )
-	If Not jobj.Contains( "themeScale" ) jobj["themeScale"]=New JsonNumber( 1 )
-	
-	Local config:=New StringMap<String>
-	
-	'config["initialTheme"]=jobj.GetString( "theme" )
-	'config["initialThemeScale"]=jobj.GetNumber( "themeScale" )
-	
-	'initial window state
-	'
-	Local flags:=WindowFlags.Resizable|WindowFlags.HighDPI
-
-	Local rect:Recti
-	
-	If jobj.Contains( "windowRect" ) 
-		rect=ToRecti( jobj["windowRect"] )
-	Else
-		rect=New Recti( 0,0,1024,768 )
-		flags|=WindowFlags.Center
-	Endif
-
-	'start the app!
-	'	
-	New AppInstance( config )
-	
-	New MainWindowInstance( "Ted2",rect,flags,jobj )
-	
-	App.Run()
-End

+ 0 - 207
src/ted2/ted2document.monkey2

@@ -1,207 +0,0 @@
-
-Namespace ted2
-
-Class Ted2Document
-
-	Field DirtyChanged:Void()
-	
-	Field StateChanged:Void()
-
-	Field Closed:Void()
-
-	Method New( path:String )
-	
-		_path=path
-		
-		_modTime=GetFileTime( _path )
-	End
-	
-	Property Path:String()
-
-		Return _path
-	End
-	
-	Property ModTime:Long()
-	
-		Return _modTime
-	End
-	
-	Property State:String()
-	
-		Return _state
-	
-	Setter( state:String )
-	
-		_state=state
-		
-		StateChanged()
-	End
-	
-	Property View:View()
-	
-		If Not _view _view=OnCreateView()
-		
-		Return _view
-	End
-	
-	Property BrowserView:View()
-	
-		If Not _browser _browser=OnCreateBrowser()
-		
-		Return _browser
-	End
-	
-	Property TextView:TextView()
-	
-		Return OnGetTextView( View )
-	End
-	
-	Property Dirty:Bool()
-	
-		Return _dirty
-	
-	Setter( dirty:Bool)
-
-		If dirty=_dirty Return
-		
-		_dirty=dirty
-		
-		DirtyChanged()
-	End
-	
-	Method Load:Bool()
-	
-		If Not OnLoad() 
-			MainWindow.ReadError( _path )
-			Return False
-		Endif
-		
-		_modTime=GetFileTime( _path )
-
-		Dirty=False
-		
-		Return True
-	End
-	
-	Method Save:Bool()
-	
-		If Not _dirty Return True
-		
-		If Not OnSave()
-			MainWindow.WriteError( _path )
-			Return False
-		Endif
-		
-		_modTime=GetFileTime( _path )
-		
-		Dirty=False
-
-		Return True
-	End
-
-	'DON'T USE YET!	
-	Method Rename( path:String )
-		_path=path
-		
-		Dirty=True
-	End
-	
-	Method Close()
-	
-		OnClose()
-		
-		Closed()
-	End
-	
-	Protected
-
-	Method OnLoad:Bool() Virtual
-	
-		Return False
-	End
-	
-	Method OnSave:Bool() Virtual
-	
-		Return False
-	End
-	
-	Method OnCreateView:View() Virtual
-	
-		Return Null
-	End
-	
-	Method OnCreateBrowser:View() Virtual
-	
-		Return Null
-	End
-	
-	Method OnGetTextView:TextView( view:View ) virtual
-	
-		Return Cast<TextView>( view )
-	End
-	
-	Method OnClose() Virtual
-	End
-	
-	Private
-
-	Field _dirty:Bool
-	Field _path:String
-	Field _modTime:Long
-	Field _state:String
-	Field _view:View
-	Field _browser:View
-	
-End
-
-Class Ted2DocumentType Extends Plugin
-
-	Function ForExtension:Ted2DocumentType( ext:String )
-	
-		ext=ext.ToLower()
-
-		Local types:=Plugin.PluginsOfType<Ted2DocumentType>()
-
-		For Local type:=Eachin types
-		
-			For Local ext2:=Eachin type.Extensions	'Array.Contains() would be nice!
-			
-				If ext=ext2 Return type
-			
-			Next
-			
-		Next
-		
-		Return Null
-	End
-	
-	Method CreateDocument:Ted2Document( path:String )
-	
-		Return OnCreateDocument( path )
-	End
-
-	Protected
-	
-	Method New()
-
-		AddPlugin( Self )
-	End
-	
-	Property Extensions:String[]()
-	
-		Return _exts
-	
-	Setter( exts:String[] )
-	
-		_exts=exts
-	End
-	
-	Method OnCreateDocument:Ted2Document( path:String ) Virtual
-	
-		Return Null	'should return hex editor!
-	End
-	
-	Private
-	
-	Field _exts:String[]
-End

+ 0 - 27
src/ted2/ted2textview.monkey2

@@ -1,27 +0,0 @@
-
-Namespace ted2
-
-Class Ted2TextView Extends TextView
-
-	Method New()
-
-		CursorType=CursorType.Line
-		CursorColor=App.Theme.GetColor( "text-default" )
-		SelectionColor=App.Theme.GetColor( "text-selected" )
-
-#If __TARGET__<>"raspbian"
-		CursorBlinkRate=2.5	'crashing on Pi?
-#Endif
-
-	End
-
-	Protected
-	
-	Method OnKeyEvent( event:KeyEvent ) Override
-	
-		TextViewKeyEventFilter.FilterKeyEvent( event,Self )
-		
-		If Not event.Eaten Super.OnKeyEvent( event )
-	End
-
-End

+ 0 - 64
src/ted2/textviewkeyeventfilter.monkey2

@@ -1,64 +0,0 @@
-
-Namespace ted2
-
-Class TextViewKeyEventFilter Extends Plugin
-
-	Function FilterKeyEvent( event:KeyEvent,textView:TextView )
-	
-		Local filters:=Plugin.PluginsOfType<TextViewKeyEventFilter>()
-		
-		For Local filter:=Eachin filters
-		
-			If event.Eaten Return
-			
-			filter.OnFilterKeyEvent( event,textView )
-		Next
-	
-	End
-
-	Protected
-	
-	Method New()
-	
-		AddPlugin( Self )
-	End
-	
-	Method OnFilterKeyEvent( event:KeyEvent,textView:TextView ) Virtual
-
-	End
-	
-End
-
-Class IJKMTextViewKeyEventFilter Extends TextViewKeyEventFilter
-
-	Protected
-	
-	Method New()
-	
-		AddPlugin( Self ) 'don't REALLY need this unless when want to enum all IJKTextViewBlah filters!
-	End
-	
-	Method OnFilterKeyEvent( event:KeyEvent,textView:TextView ) Override
-	
-		If (event.Type<>EventType.KeyDown And event.Type<>EventType.KeyRepeat) Or Not (event.Modifiers & Modifier.Alt) Return
-
-		Local fake:Key
-		Select event.Key
-		Case Key.I fake=Key.Up
-		Case Key.J fake=Key.Left
-		Case Key.K fake=Key.Right
-		Case Key.M fake=Key.Down
-		Default
-			Return
-		End
-			
-		textView.SendKeyEvent( New KeyEvent( EventType.KeyDown,textView,fake,Null,event.Modifiers & Modifier.Shift,"" ) )
-			
-		event.Eat()
-	End
-	
-	Private
-	
-	Global _instance:=New IJKMTextViewKeyEventFilter
-
-End

+ 0 - 83
src/ted2/xmldocument.monkey2

@@ -1,83 +0,0 @@
-
-Namespace ted2
-
-Class XmlDocument Extends Ted2Document
-
-	Method New( path:String )
-		Super.New( path )
-		
-		_doc=New TextDocument
-		
-		_view=New TextView( _doc )
-		
-		_browser=New XmlTreeView
-		
-		_doc.TextChanged+=Lambda()
-		
-			Local xml:=New XMLDocument
-			
-			If xml.Parse( _doc.Text )<>XMLError.XML_SUCCESS xml=Null
-			
-			_browser.Data=xml
-		
-			Dirty=True
-		End
-	End
-
-	Protected
-	
-	Method OnLoad:Bool() Override
-	
-		Local xml:=stringio.LoadString( Path )
-		
-		_doc.Text=xml
-		
-		Return True
-	End
-	
-	Method OnSave:Bool() Override
-	
-		Local xml:=_doc.Text
-		
-		Return stringio.SaveString( xml,Path )
-	End
-	
-	Method OnCreateView:View() Override
-	
-		Return _view
-	End
-	
-	Method OnCreateBrowser:View() Override
-	
-		Return _browser
-	End
-	
-	Private
-	
-	Field _doc:TextDocument
-	
-	Field _view:TextView
-	
-	Field _browser:XmlTreeView
-End
-
-Class XmlDocumentType Extends Ted2DocumentType
-
-	Protected
-	
-	Method New()
-		AddPlugin( Self )
-		
-		Extensions=New String[]( ".xml" )
-	End
-	
-	Method OnCreateDocument:Ted2Document( path:String ) Override
-	
-		Return New XmlDocument( path )
-	End
-	
-	Private
-	
-	Global _instance:=New XmlDocumentType
-	
-End

+ 0 - 78
src/ted2/xmltreeview.monkey2

@@ -1,78 +0,0 @@
-
-Namespace ted2
-
-'Based on code by Shane Raffa!
-'
-Class XmlTreeView Extends TreeView
-
-	Method New()
-		RootNode.Text="[No Data]"
-	End
-
-	Property Data:XMLDocument()
-	
-		Return _data
-	
-	Setter( data:XMLDocument )
-	
-		_data=data
-		
-		RootNode.RemoveAllChildren()
-		
-		If Not _data
-			RootNode.Text="[No Data]"
-			Return
-		Endif
-
-		RootNode.Text = "XML Document"
- 
-		AddXMLNodeToTree( _data,RootNode )
-	End
-	
-	Private
-	
-	Field _data:XMLDocument
-	
-	Method AddXMLNodeToTree( xmlNode:XMLNode,parent:Node )
-	
-		Local str := ""
-	
-		Local xmlElement := xmlNode.ToElement()
-		
-		If xmlElement
-		
-			str += "<" + xmlNode.Value()
-			
-			Local attrib := xmlElement.FirstAttribute()
-			While attrib 
-				str += " " + attrib.Name() + "=~q" + attrib.Value() + "~q "
-				attrib=attrib.NextAttribute()
-			wend
-			
-			str += ">"
-		Else
-			str += xmlNode.Value()
-		Endif
- 
-		Local treeNode:Node
-	
-		If str
-			treeNode = New Node(str, parent)
-		Endif
-		
-		Local xmlChild := xmlNode.FirstChild()
-	
-		While xmlChild
-		
-			If Not xmlChild.NoChildren()
-				If treeNode Then parent = treeNode
-			Endif
-		
-			AddXMLNodeToTree(xmlChild, parent)
-			
-			xmlChild = xmlChild.NextSibling()
-	
-		Wend
-	
-	End
-End