Browse Source

Merge pull request #52 from blitz-research/develop

Develop up (docs stuffs!!)
abakobo 8 năm trước cách đây
mục cha
commit
73a1f18bbb
58 tập tin đã thay đổi với 1185 bổ sung207 xóa
  1. 7 5
      ABOUT.HTML
  2. 9 0
      VERSIONS.TXT
  3. 4 5
      bin/env_windows.txt
  4. 0 38
      hello-world.monkey2
  5. 2 0
      modules/assimp/assimp/contrib/zlib/gzguts.h
  6. 5 0
      modules/litehtml/litehtml/src/gumbo/attribute.c
  7. 5 0
      modules/litehtml/litehtml/src/gumbo/parser.c
  8. 5 0
      modules/litehtml/litehtml/src/gumbo/string_buffer.c
  9. 5 0
      modules/litehtml/litehtml/src/gumbo/string_piece.c
  10. 6 1
      modules/litehtml/litehtml/src/gumbo/utf8.c
  11. 6 0
      modules/litehtml/litehtml/src/gumbo/util.c
  12. 5 0
      modules/litehtml/litehtml/src/gumbo/vector.c
  13. 6 0
      modules/mojo/input/mouse.monkey2
  14. 11 0
      modules/monkey/docs/articles/articles.md
  15. 32 0
      modules/monkey/docs/articles/lambda-functions.md
  16. 58 0
      modules/monkey/docs/articles/multifile-projects.md
  17. 50 0
      modules/monkey/docs/articles/namespaces-and-using.md
  18. 105 0
      modules/monkey/docs/articles/operator-overloading.md
  19. 23 2
      modules/monkey/docs/language/functions.md
  20. 2 0
      modules/monkey/docs/manual.md
  21. 11 3
      modules/monkey/docs/sdks.md
  22. 0 4
      modules/monkey/native/strings.h
  23. 4 1
      modules/std/fiber/native/asm/jump_i386_ms_pe_masm.asm
  24. 4 1
      modules/std/fiber/native/asm/make_i386_ms_pe_masm.asm
  25. 4 1
      modules/std/fiber/native/asm/ontop_i386_ms_pe_masm.asm
  26. 1 1
      modules/std/process/native/procutil.cpp
  27. 44 9
      modules/std/resource/resource.monkey2
  28. 1 0
      scripts/rebuildall.bat
  29. 1 0
      scripts/rebuildall.sh
  30. 7 6
      scripts/rebuildall2go.bat
  31. 1 0
      scripts/rebuildall2go.sh
  32. 4 2
      src/createrelease/createrelease.monkey2
  33. 85 49
      src/mx2cc/builder.monkey2
  34. 16 25
      src/mx2cc/buildproduct.monkey2
  35. 13 1
      src/mx2cc/mx2cc.monkey2
  36. 31 4
      src/mx2cc/test.monkey2
  37. 1 1
      src/ted2/helpactions.monkey2
  38. 1 6
      src/ted2/mainwindow.monkey2
  39. 167 0
      src/ted2/scenedocument.monkey2
  40. 2 0
      src/ted2/ted2.monkey2
  41. 77 18
      src/ted2go/MainWindow.monkey2
  42. 2 1
      src/ted2go/Prefs.monkey2
  43. 1 1
      src/ted2go/README.md
  44. 1 1
      src/ted2go/Ted2.monkey2
  45. 23 5
      src/ted2go/action/BuildActions.monkey2
  46. 18 5
      src/ted2go/action/FindActions.monkey2
  47. 1 1
      src/ted2go/assets/aboutTed2Go.html
  48. BIN
      src/ted2go/assets/themes/outputbar/clean.png
  49. 6 0
      src/ted2go/assets/themes/ted2-default.json
  50. BIN
      src/ted2go/assets/themes/toolbar/check.png
  51. 7 0
      src/ted2go/dialog/FindDialog.monkey2
  52. 7 0
      src/ted2go/parser/CodeItem.monkey2
  53. 1 0
      src/ted2go/parser/Monkey2Parser.monkey2
  54. 14 4
      src/ted2go/product/ModuleManager.monkey2
  55. 1 1
      src/ted2go/product/Mx2ccEnv.monkey2
  56. 8 0
      src/ted2go/utils/Utils.monkey2
  57. 272 3
      src/ted2go/view/ConsoleViewExt.monkey2
  58. 2 2
      src/ted2go/view/DebugView.monkey2

+ 7 - 5
src/ted2/assets/about.html → ABOUT.HTML

@@ -4,7 +4,7 @@
 <style>
 
 body{
-	background: transparent;
+	background: #333;
 	color: #eee;
 	font-size: 16px;
 	margin: 8px;
@@ -44,13 +44,15 @@ a:hover{
 
 <body>
 
-<h1>Monkey2 v1.1.04</h1>
+<h1>Monkey2 v1.1.05</h1>
 
-<p>Welcome to monkey2, a new, open source, user friendly, multi target programming language by Mark Sibly.
+<p>Welcome to monkey2, an open source, user friendly, multi target programming language by Mark Sibly.
 
-<p>Please post any bug reports or feature requests to the monkey2 github repository: <a href="https://github.com/blitz-research/monkey2">https://github.com/blitz-research/monkey2</a>.
+<p>Example programs can be found in the bananas directory.
+
+<p>For monkey2 discussion and programming help, feel free to drop by the monkey2 forums: <a href="http://monkeycoder.co.nz/forums">http://monkeycoder.co.nz/forums</a>.
 
-<p>For monkey2 discussion and programming help, feel free to drop by the monkey2 forums: <a href="http://monkey2.monkey-x.com/forums">http://monkey2.monkey-x.com/forums</a>.
+<p>Please post any bug reports or feature requests to the monkey2 github repository: <a href="https://github.com/blitz-research/monkey2">https://github.com/blitz-research/monkey2</a>.
 
 <p>Monkey2 is a crowd funded project. If you like what you see, please consider contributing to development either via paypal donation or by becoming a Patreon supporter.
 

+ 9 - 0
VERSIONS.TXT

@@ -0,0 +1,9 @@
+
+***** Monkey2 v1.1.05 *****
+
+* Added WIP MSVC support - see: #MX2_USE_MSVC in bin/windows_env.txt
+
+* Added assimp model for loading 3d models.
+
+* Added std.requesters.OpenUrl support for android and ios.
+

+ 4 - 5
bin/env_windows.txt

@@ -37,21 +37,20 @@ MX2_CPP_OPTS_WINDOWS_RELEASE=-O3 -DNDEBUG
 
 MX2_USE_MSVC=0
 
-PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin;${PATH}
+PATH=${ProgramFiles(x86)}\Microsoft Visual Studio 14.0\VC\bin;${PATH}
 
-INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE;C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\shared;
+INCLUDE=${ProgramFiles(x86)}\Microsoft Visual Studio 14.0\VC\INCLUDE;${ProgramFiles(x86)}\Windows Kits\10\include\10.0.10586.0\ucrt;${ProgramFiles(x86)}\Windows Kits\10\include\10.0.10586.0\um;${ProgramFiles(x86)}\Windows Kits\10\include\10.0.10586.0\shared;
 
-LIB=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB;C:\Program Files (x86)\Windows Kits\10\lib\10.0.10586.0\ucrt\x86;C:\Program Files (x86)\Windows Kits\10\lib\10.0.10586.0\um\x86;
+LIB=${ProgramFiles(x86)}\Microsoft Visual Studio 14.0\VC\LIB;${ProgramFiles(x86)}\Windows Kits\10\lib\10.0.10586.0\ucrt\x86;${ProgramFiles(x86)}\Windows Kits\10\lib\10.0.10586.0\um\x86;
 
 'Linker options
 MX2_LD_OPTS_MSVC=
 MX2_LD_OPTS_MSVC_DEBUG=
 MX2_LD_OPTS_MSVC_RELEASE=
 
-'C Compiler options. Note: -D_WIN32_WINNT=0x0601 means headers for Windows 7, ie: Windows 7 is min SDK!
 MX2_CC_OPTS_MSVC=-EHs -W0 -MT
 MX2_CC_OPTS_MSVC_DEBUG=
-MX2_CC_OPTS_MSVC_RELEASE=
+MX2_CC_OPTS_MSVC_RELEASE=-Ox
 
 'C++ Compiler options
 MX2_CPP_OPTS_MSVC=-EHs -W0 -MT

+ 0 - 38
hello-world.monkey2

@@ -1,38 +0,0 @@
-
-#rem
-
-Hello World!
-
-A minimal monkey2 graphical app.
-
-See /bananas directory for more examples.
-
-#end
-
-#Import "<std>"
-#Import "<mojo>"
-
-Using std..
-Using mojo..
-
-Class MyWindow Extends Window
-
-	Method OnRender( canvas:Canvas ) Override
-	
-		canvas.DrawText( "Hello World!",Width/2,Height/2,.5,.5 )
-
-	End
-	
-End
-
-Function Main()
-
-	Print "Hello World!"
-
-	New AppInstance
-	
-	New MyWindow
-	
-	App.Run()
-	
-End

+ 2 - 0
modules/assimp/assimp/contrib/zlib/gzguts.h

@@ -20,7 +20,9 @@
 
 #include <stdio.h>
 
+#if !_MSC_VER
 #include <unistd.h>
+#endif
 
 #include "zlib.h"
 #ifdef STDC

+ 5 - 0
modules/litehtml/litehtml/src/gumbo/attribute.c

@@ -19,7 +19,12 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+
+#if _MSC_VER
+#include "strings.h"
+#else
 #include <strings.h>
+#endif
 
 #include "util.h"
 

+ 5 - 0
modules/litehtml/litehtml/src/gumbo/parser.c

@@ -19,7 +19,12 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
+
+#if _MSC_VER
+#include "strings.h"
+#else
 #include <strings.h>
+#endif
 
 #include "attribute.h"
 #include "error.h"

+ 5 - 0
modules/litehtml/litehtml/src/gumbo/string_buffer.c

@@ -19,7 +19,12 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+
+#if _MSC_VER
+#include "strings.h"
+#else
 #include <strings.h>
+#endif
 
 #include "string_piece.h"
 #include "util.h"

+ 5 - 0
modules/litehtml/litehtml/src/gumbo/string_piece.c

@@ -19,7 +19,12 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+
+#if _MSC_VER
+#include "strings.h"
+#else
 #include <strings.h>
+#endif
 
 #include "util.h"
 

+ 6 - 1
modules/litehtml/litehtml/src/gumbo/utf8.c

@@ -19,7 +19,12 @@
 #include <assert.h>
 #include <stdint.h>
 #include <string.h>
-#include <strings.h>  // For strncasecmp.
+
+#if _MSC_VER
+#include "strings.h"
+#else
+#include <strings.h>
+#endif
 
 #include "error.h"
 #include "gumbo.h"

+ 6 - 0
modules/litehtml/litehtml/src/gumbo/util.c

@@ -19,7 +19,13 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+
+#if _MSC_VER
+#include "strings.h"
+#else
 #include <strings.h>
+#endif
+
 #include <stdarg.h>
 #include <stdio.h>
 

+ 5 - 0
modules/litehtml/litehtml/src/gumbo/vector.c

@@ -19,7 +19,12 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+
+#if _MSC_VER
+#include "strings.h"
+#else
 #include <strings.h>
+#endif
 
 #include "util.h"
 

+ 6 - 0
modules/mojo/input/mouse.monkey2

@@ -104,9 +104,15 @@ Class MouseDevice Extends InputDevice
 	End
 
 	#rem monkeydoc The mouse location.
+	
+	This property may be written to warp the mouse to a new location.
+	
 	#end
 	Property Location:Vec2i()
 		Return _location
+	Setter( location:Vec2i )
+		_location=location
+		SDL_WarpMouseInWindow( Null,location.x,location.y )
 	End
 	
 	#rem monkeydoc The mouse wheel delta x value since the last app update.

+ 11 - 0
modules/monkey/docs/articles/articles.md

@@ -0,0 +1,11 @@
+
+@manpage Articles and tutorials
+
+# Articles and tutorials
+
+This section contains a number of articles and tutorials.
+
+@import operator-overloading.md
+@import lambda-functions.md
+@import namespaces-and-using.md
+@import multifile-projects.md

+ 32 - 0
modules/monkey/docs/articles/lambda-functions.md

@@ -0,0 +1,32 @@
+
+### What are 'lambda functions'?
+
+A lambda function is a special type of function that can be declared in the middle of an expression.
+
+You can think of a lambda function a bit like a ‘temporary’ function – instead of having to declare an entirely separate function to do what you need, you can just declare a lambda function ‘on the fly’ in the middle of an expression.
+
+ A lambda function is anonymous. It has no name so can only be used by the expression it is declared within.
+
+A lambda functions can make use of the same local variables as the expression it is declared within. It does this by ‘capturing’ these variables, which means the lambda function receives a copy of the local variable’s value at the point the lambda function is declared. This means that a lambda function will not ‘see’ any  future modifications to local variables. A lambda function cannot ‘see’ local variables that have not been declared yet!
+
+If a lambda function is declared within a method, it can also see (and modify) object fields, and call object methods.
+
+Here is a simple example:
+
+```
+Function Test( func:Void() )
+   
+   func()
+
+End
+
+Function Main()
+
+   Test( Lambda()
+
+      Print "Hello from lambda!"
+
+   End )
+
+End
+```

+ 58 - 0
modules/monkey/docs/articles/multifile-projects.md

@@ -0,0 +1,58 @@
+
+# Multifile projects and #Import.
+
+To add additional source files to a monkey2 project, you use the #Import directive. #Import can also be used to import other stuff into a project, but more on that late
+
+\#Imports should appear at the top of a source file before any declarations occur. #Import takes one parameter – the path to the file to import. If the file is a '.monkey2' file, the extensions can be omitted, eg:
+ 
+
+```
+'file1.monkey2
+'
+#Import "file2"
+#Import "file3"
+ 
+Function Something()
+End
+```
+
+The import path can be relative or absolute, and contain “../” etc, making it easy to get at source files located anywhere.
+
+When you build a monkey2 app (or module), the compiler starts with a single ‘root’ monkey2 source file and searches for all other monkey2 files reachable – directly or indirectly – from that root file via #Import directives. All files found via #Import this way will ultimately be included in the project and built  by the compiler.
+
+You only need to #Import a particular file once per project – duplicate #Imports of the same file are ignored by the compiler.
+
+Code in any imported monkey2 file can use code in any other imported monkey2 file, regardless of whether or not the files #Import each other. For example:
+
+```
+'***** file1.monkey2 *****
+'
+#Import "file2"
+#Import "file3"
+ 
+Function Func1()
+   Func1()
+   Func2()
+   Func3()
+End
+ 
+'***** file2.monkey2 *****
+ 
+Function Func2()
+   Func1()
+   Func2()
+   Func3()
+End
+ 
+'***** file3.monkey2 *****
+ 
+Function Func3()
+   Func1()
+   Func2()
+   Func3()
+End
+```
+
+This is perfectly valid, as long as file1.monkey2 is the ‘root file’ you compile.
+
+ 

+ 50 - 0
modules/monkey/docs/articles/namespaces-and-using.md

@@ -0,0 +1,50 @@
+
+### Namespaces and using.
+
+Monkey2 provides simple support for namespaces.
+
+Each file can have a Namespace directive at the top that specifies the ‘scope’ of all the declarations (functions, globals, classes etc) in the file. For example:
+
+```
+'***** file1.monkey2 *****
+'
+Namespace myapp 'declare namesapce
+ 
+Global SomeGlobal:Int
+ 
+Function SomeFunction()
+End
+```
+
+The ‘namespace myapp’ at the top here means that the SomeGlobal and SomeFunction declarations end up in the ‘myapp’ namespace. If you don’t have a Namespace at the top of a source file, a ‘default’ namespace is used. It is recommended that you use Namespace for all substantial projects though.
+
+To access stuff declared in a namespace, use the ‘.’ operator. For example, you can access the SomeGlobal variable above using myapp.SomeGlobal.
+
+However, you don’t need to do this if the declaration being accessed is in the same namespace (or a ‘parent’ namespace…see below) as the code doing the accessing. For example, any code within the above file can use SomeGlobal and SomeFunction without the need for  a ‘myapp.’ prefix, as that code is also in the myapp namespace.
+
+This also applies to multifile projects. If 2 separate monkey2 files are in the same namespace, then they can freely access each other declarations without the need for a namespace prefix.
+
+You can almost think of namespace as simple classes – albeit classes that can’t be new’d so can’t have fields or methods. The name of the class provides a ‘scope’ for the globals and functions declared in the class, and declarations with the class can directly access other declarations in the same class.
+
+Namespaces are also hierarchical. While ‘Namespace myapp’ creates a simple ‘top level’ namespace, it’s also possible to create child namespaces using ‘.’. For example ‘Namespace myapp.utils’ referes to a ‘utils’ namespace within the top level ‘myapp’ namespace.
+
+Finally, the Using directive can make it easier to access frequently used declarations inside a namespace. For example, the ChangeDir and CurrentDir functions are declared in the ‘std.filesystem’ namespace, but (depending on your self discipline level) it can be a hassle having to use std.filesystem.ChangeDir and std.filesystem.CurrentDir all the time.
+
+To help out here, the ‘Using’ directive can be used to instruct the compiler to search a particular namespace for identifiers that it can’t normally find. For example:
+
+```
+Namespace myapp
+ 
+Using std.filesystem
+ 
+Function Main()
+   ChangeDir( ".." )
+   Print CurrentDir()
+End
+```
+
+Without the Using declaration in the above code, you would need to use std.filesystem.ChangeDir and std.filesystem.CurrentDir.
+
+You can have multiple Usings in an app, and Usings must appear at the top of a file, before any declarations.
+
+The namespace specified in a Using must be ‘absolute’. That is, the namespace of the file is not taken into account when resolving the Using namespace.

+ 105 - 0
modules/monkey/docs/articles/operator-overloading.md

@@ -0,0 +1,105 @@
+
+### Operator Overloading
+
+Operator overloading is a very cool feature that allows you to customize the behaviour of the built-in monkey2 operators for classes and structs.
+
+You overload an operator by writing an ‘operator method’, which is effectively just a special kind of method. Operators must appear inside classes/structs – they cannot currently be ‘global’.
+
+Here is a simple example:
+
+```
+Struct Vec2
+
+   Field x:Float
+   Field y:Float
+
+   Method New( x:Float,y:Float )
+      Self.x=x
+      Self.y=y
+   End
+
+   Method ToString:String()
+      Return "Vec2("+x+","+y+")"
+   End
+
+   'Overload the addition operator.
+   Operator+:Vec2( rhs:Vec2 )
+      Return New Vec2( x+rhs.x,y+rhs.y )
+   End
+
+End
+```
+
+The ‘Operator+’ declaration here defines an addition operator for Vec2. This is then used whenever a Vec2 appears as the ‘left hand side’ of an addition. For example:
+
+```
+Function Main()
+   Local v1:=New Vec2( 10.0,20.0 )
+   Local v2:=New Vec2( 30.0,40.0 )
+   Local v3:=v1+v2    'note: calls Operator+ in Vec2.
+   Print v3.ToString()
+End
+```
+
+The following unary operators can be overloaded: + – ~
+
+The following binary operators can be overloaded: * / Mod + – Shl Shr & | ~ = <> < > <= >= <=>
+
+The following assignment operators can be overloaded: *= /= Mod= += -= Shl= Shr= &= |= ~=
+
+Indexing behaviour can also be overloaded using: [] []=
+
+Note that you cannot override ‘Not’, ‘And’ or ‘Or’ - would just be too confusing if the meaning of these weren't consistent IMO!
+
+Operators can return any type of value, and can take any type of value for their ‘right hand side’ argument(s). However, the precedence of operators cannot be changed.
+
+The ‘[]’ and ‘[]=’ operators allow you to define ‘indexing’ like behaviour. The ‘[]’ operator is used when an object is indexed, and ‘[]=’ is used when an object is indexed and assigned. Both of these operators can accept any number of parameters of any type. The ‘[]=’ operator requires an additional parameter that is the value to be assigned. This must appear at the end of the parameter list.
+
+Here is an example of some indexing operators for the Vec2 class above:
+
+```
+Struct Vec2
+
+   ...etc...
+
+   Operator[]:Float( index:Int )
+      Assert( index=0 Or index=1 )
+      If index=0 Return x Else Return y
+   End
+
+   Operator[]=( index:Int,value:Float )
+      Assert( index=0 Or index=1 )
+      If index=0 Then x=value Else y=value
+   End
+End
+```
+
+With these additions, you can access Vec2 coordinates ‘by index’, eg:
+
+```
+Function Main()
+   Local v:=New Vec2
+   v[0]=10.0
+   v[1]=20.0
+   Print v[0]
+   Print v[1]
+End
+```
+
+You can also overload assignment operators, for example:
+
+```
+Struct Vec2
+
+   ...etc...
+
+   Operator+=( v:Vec2 )
+      x+=v.x
+      y+=v.y
+   End
+End
+```
+
+If you have already written an Operator+ (as is the case here) this is not strictly necessary, as monkey2 will generate the code for Operator+= for you. However, you may still want to provide a custom version for Operator+= if your code can do so more efficiently.
+
+Note that you cannot overload the plain assignment operator '='.

+ 23 - 2
modules/monkey/docs/language/functions.md

@@ -5,7 +5,7 @@
 
 To declare a global function:
 
-`Function` _Identifier_ [ `:` _ReturnType_ ] `(` _Arguments_ `)`
+`Function` _Identifier_ [ _GenericParams_ ] [ `:` _ReturnType_ ] `(` _Parameters_ `)`
 ```
 	...Statements...
 ```
@@ -13,7 +13,28 @@ To declare a global function:
 
 _ReturnType_ defaults to `Void` if omitted.
 
-_Arguments_ is a comma separated list of parameter declarations.
+_Parameters_ is a comma separated list of parameter declarations.
+
+
+#### Class methods
+
+The syntax for declaring a class method is:
+
+`Method` _Identifier_ [ _GenericParams_ ] [ `:` _ReturnType_ ] `(` _Parameters_ `)` [ `Virtual`|`Abstract|`Override``|`Final`|`Override Final` ]
+```
+	...Statements...
+```
+`End`
+
+If a method is declared `Virtual` or `Abstract`, it can be overriden by methods in derived classes. Overriding methods must have the same return type and parameter types as the class method, and must be declared `Override`.
+
+If a method is declared `Abstract`, no implementation may be provided (ie: no 'statements' or 'End'). Such a method must be overriden by a method in a derived class, and also makes its enclosing class implictly abstract (an abstract class cannot be instantiated).
+
+If a method is declared `Override` or `Override Final`, it must override a virtual method in a base class.
+
+If a method is declared `Final` or `Override Final`, it cannot be overriden by any methods in derived classes.
+
+By default, class methods are final.
 
 
 #### Lambda functions

+ 2 - 0
modules/monkey/docs/manual.md

@@ -13,6 +13,8 @@ Have fun!
 
 @import language/language.md
 
+@import articles/articles.md
+
 @import sdks.md
 
 @import mx2cc.md

+ 11 - 3
modules/monkey/docs/sdks.md

@@ -6,11 +6,19 @@ Monkey2 target SDKs.
 
 #### The Windows Desktop Target
 
-Monkey2 uses the mingw compilers and tools to build desktop apps for windows.
+Monkey2 can use either the mingw or msvc express 2015 compilers to build desktop apps.
 
-If you don't already have mingw installed, you can use the mingw build tools available at [[http://monkey2.monkey-x.com/monkey2-files]]. Simply download the mingw build tools package, run it (it's a self extracting exe), and select your monkey2 'devtools' dir for installation.
+To use mingw, you can use the mingw build tools available at [[http://monkey2.monkey-x.com/monkey2-files]]. Simply download the mingw build tools package, run it (it's a self extracting exe), and select your monkey2 'devtools' dir for installation.
 
-Note that the prebuilt binaries available from itch.io already include mingw.
+Note that the prebuilt binaries available from itch.io already include mingw in the 'devtools' dir.
+
+To use msvc instead of mingw, you will need to install msvc express 2015 and change the following line in bin/env_windows.txt:
+
+#MX2_USE_MSVC=1
+
+You will need to rebuild all modules after doing this.
+
+Downloads for msvc express can be found here - https://www.visualstudio.com/vs/visual-studio-express/
 
 
 #### The Macos Desktop Target

+ 0 - 4
modules/monkey/native/strings.h

@@ -1,4 +0,0 @@
-
-//Dummy include file for unix code that wants strings.h
-//
-#include <string.h>

+ 4 - 1
modules/std/fiber/native/asm/jump_i386_ms_pe_masm.asm

@@ -24,7 +24,10 @@
 .model flat, c
 .code
 
-jump_fcontext PROC BOOST_CONTEXT_EXPORT
+jump_fcontext PROC 
+
+	;BOOST_CONTEXT_EXPORT
+	
     push  ebp  ; save EBP 
     push  ebx  ; save EBX 
     push  esi  ; save ESI 

+ 4 - 1
modules/std/fiber/native/asm/make_i386_ms_pe_masm.asm

@@ -26,7 +26,10 @@
 _exit PROTO, value:SDWORD
 .code
 
-make_fcontext PROC BOOST_CONTEXT_EXPORT
+make_fcontext PROC 
+
+	;BOOST_CONTEXT_EXPORT
+	
     ; first arg of make_fcontext() == top of context-stack
     mov  eax, [esp+04h]
 

+ 4 - 1
modules/std/fiber/native/asm/ontop_i386_ms_pe_masm.asm

@@ -24,7 +24,10 @@
 .model flat, c
 .code
 
-ontop_fcontext PROC BOOST_CONTEXT_EXPORT
+ontop_fcontext PROC 
+
+	;BOOST_CONTEXT_EXPORT
+	
     push  ebp  ; save EBP 
     push  ebx  ; save EBX 
     push  esi  ; save ESI 

+ 1 - 1
modules/std/process/native/procutil.cpp

@@ -1,5 +1,5 @@
 
-#import "procutil.h"
+#include "procutil.h"
 
 namespace bbProcUtil{
 

+ 44 - 9
modules/std/resource/resource.monkey2

@@ -1,15 +1,26 @@
 
 Namespace std.resource
 
+#Rem monkeydoc The Resource class.
+
+Currently WIP!
+
+#end
 Class Resource
 	
+	#rem monkeydoc Invoked when a resource is dscarded.
+	#end
 	Field Discarded:Void()
 	
+	#rem monkeyoc @hidden
+	#end
 	Property Refs:Int()
 		
 		Return _refs
 	End
 	
+	#rem monkeyoc @hidden
+	#end
 	Method Retain()
 		
 		If Not _refs Return
@@ -17,6 +28,8 @@ Class Resource
 		_refs+=1
 	End
 	
+	#rem monkeyoc @hidden
+	#end
 	Method Release()
 		
 		If Not _refs Return
@@ -24,6 +37,24 @@ Class Resource
 		If _refs=1 Discard() Else _refs-=1
 	End
 	
+	#rem monkeyoc @hidden
+	#end
+	Method AddDependancy( r:Resource )
+		
+		If Not r Return
+		
+		r.Retain()
+
+		Discarded+=r.Release
+	End
+	
+	#rem monkeyoc Discards the resource.
+	
+	Calling this will cause the resource's internal [[OnDiscard]] method to be invoked, followed by the [[Discarded]] signal.
+	
+	A resource can only be discarded once. Once discarded a resource should be consider invalid.
+	
+	#end
 	Method Discard()
 		
 		If Not _refs Return
@@ -35,17 +66,15 @@ Class Resource
 		Discarded()
 	End
 	
-	Method AddDependancy( r:Resource )
-		
-		If Not r Return
-		
-		r.Retain()
-
-		Discarded+=r.Release
-	End
-	
 	Protected
 	
+	#rem monkeyoc @hidden
+	
+	This method is invoked when the resource is discarded.
+	
+	This is where subclasses should place their actual discard code.
+	
+	#end
 	Method OnDiscard() Virtual
 	End
 	
@@ -54,6 +83,8 @@ Class Resource
 	Field _refs:=1
 End
 
+#rem monkeydoc @hidden
+#end
 Class ResourceManager Extends Resource
 
 	Method New()
@@ -110,11 +141,15 @@ Class ResourceManager Extends Resource
 
 End
 
+#rem monkeydoc @hidden
+#end
 Function SafeRetain( r:Resource )
 	
 	If r r.Retain()
 End
 
+#rem monkeydoc @hidden
+#end
 Function SafeRelease( r:Resource )
 	
 	If r r.Release()

+ 1 - 0
scripts/rebuildall.bat

@@ -1,6 +1,7 @@
 
 echo off
 
+call rebuildmx2cc
 call rebuildmods
 call rebuildted2
 call makedocs

+ 1 - 0
scripts/rebuildall.sh

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

+ 7 - 6
scripts/rebuildall2go.bat

@@ -1,6 +1,7 @@
-
-echo off
-
-call rebuildmods
-call rebuildted2go
-call makedocs
+
+echo off
+
+call rebuildmx2cc
+call rebuildmods
+call rebuildted2go
+call makedocs

+ 1 - 0
scripts/rebuildall2go.sh

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

+ 4 - 2
src/createrelease/createrelease.monkey2

@@ -5,7 +5,7 @@
 Using libc..
 Using std..
 
-Const MX2CC_VERSION:="1.1.04"
+Const MX2CC_VERSION:="1.1.05"
 
 Const OUTPUT:="Monkey2-v"+MX2CC_VERSION
 
@@ -84,6 +84,7 @@ Function CopyRelease()
 	CreateDir( output )
 	
 	CreateDir( output+"/devtools" )
+	CreateDir( output+"/tmp" )
 	
 	CopyFiles( "bin" )
 	CopyFiles( "docs" )
@@ -93,9 +94,10 @@ Function CopyRelease()
 	CopyFiles( "src" )
 	
 	Copy( "hello-world.monkey2" )
+	Copy( "ABOUT.HTML" )
+	Copy( "VERSIONS.TXT" )
 	Copy( "LICENSE.TXT" )
 	Copy( "README.TXT" )
-	Copy( "TODO.TXT" )
 	
 #if __TARGET__="windows"
 	Copy( "Monkey2 (Windows).exe" )

+ 85 - 49
src/mx2cc/builder.monkey2

@@ -126,6 +126,7 @@ Class BuilderInstance
 		End
 
 		profileName=opts.target+"_"+opts.config
+		If opts.target="windows" And Int( GetEnv( "MX2_USE_MSVC" ) ) profileName+="_msvc"
 		
 		MODULES_DIR=CurrentDir()+"modules/"
 		
@@ -607,19 +608,43 @@ Class BuilderInstance
 		
 		Select ext.ToLower()
 		Case ".a"
-
-			If name.StartsWith( "lib" ) name=name.Slice( 3 ) Else name=path
-			product.LD_SYSLIBS.Push( "-l"+name )
 			
-		Case ".lib",".dylib"
-		
-			product.LD_SYSLIBS.Push( "-l"+name )
+			If name.StartsWith( "lib" )
+				
+				name=name.Slice( 3 )
+				
+				If product.toolchain="msvc"
+					product.LIB_FILES.Push( name+".lib" )
+				Else
+					product.LIB_FILES.Push( "-l"+name )
+				Endif
+			
+			Else
+				
+				New BuildEx( "Import Error: "+path )
+			Endif
+			
+		Case ".lib"
+			
+			If product.toolchain="msvc"
+				product.LIB_FILES.Push( name )
+			Else
+				product.LIB_FILES.Push( "-l"+name )
+			Endif
+			
+		Case ".dylib"
+			
+			If product.toolchain="gcc"
+				product.LIB_FILES.Push( "-l"+name )
+			Endif
 			
 		Case ".framework"
-		
-			product.LD_SYSLIBS.Push( "-framework "+name )
 			
-		Case ".h",".hh",".hpp"
+			If product.toolchain="gcc"
+				product.LIB_FILES.Push( "-framework "+name )
+			Endif
+			
+		Case ".h",".hh",".hxx",".hpp"
 		
 '			STD_INCLUDES.Push( "<"+path+">" )
 			
@@ -674,17 +699,29 @@ Class BuilderInstance
 				product.CC_OPTS+=" -I"+qdir
 				product.CPP_OPTS+=" -I"+qdir
 				
-			Case ".hh",".hpp"
+			Case ".hh",".hpp",".hxx"
 			
 				product.CPP_OPTS+=" -I"+qdir
 				
-			Case ".a",".lib",".dylib"
-			
-				product.LD_OPTS+=" -L"+qdir
+			Case ".a",".lib"
+				
+				If product.toolchain="msvc"
+					product.LD_OPTS+=" -LIBPATH:"+qdir
+				Else
+					product.LD_OPTS+=" -L"+qdir
+				Endif
+				
+			Case ".dylib"
+				
+				If product.toolchain="gcc"
+					product.LD_OPTS+=" -L"+qdir
+				Endif
 				
 			Case ".framework"
-			
-				product.LD_OPTS+=" -F"+qdir
+				
+				If product.toolchain="gcc"
+					product.LD_OPTS+=" -F"+qdir
+				Endif
 				
 			Default
 			
@@ -699,9 +736,11 @@ Class BuilderInstance
 		Select ext
 		Case ".framework"
 			
-			If GetFileType( path )<>FileType.Directory
-				New BuildEx( "Framework "+qpath+" not found" )
-				Return
+			If product.toolchain="gcc"
+				If GetFileType( path )<>FileType.Directory
+					New BuildEx( "Framework "+qpath+" not found" )
+					Return
+				Endif
 			Endif
 			
 		Default
@@ -724,60 +763,57 @@ Class BuilderInstance
 		
 			MX2_SRCS.Push( path )
 			
-		Case ".h",".hh",".hpp"
+		Case ".h",".hh",".hxx",".hpp"
 		
 '			STD_INCLUDES.Push( qpath )
 			
 		Case ".c",".cc",".cxx",".cpp",".m",".mm",".asm",".s"
 		
-			If parsingModule=mainModule product.SRC_FILES.Push( path )
+			If parsingModule=mainModule 
+				product.SRC_FILES.Push( path )
+			Endif
 		
-'			If modules.Length=1
-'				SRC_FILES.Push( path )
-'			Endif
-
 		Case ".java"
-		
-'			If parsingModule=mainModule product.JAVA_FILES.Push( path )
-			product.JAVA_FILES.Push( path )
+			
+			If opts.target="android"
+				product.JAVA_FILES.Push( path )
+			Endif
 			
 		Case ".o"
 		
 			product.OBJ_FILES.Push( path )
 			
-		Case ".a",".lib"
-		
-			product.LD_SYSLIBS.Push( qpath )
+		Case ".lib"
 			
-		Case ".so"
+			product.LIB_FILES.Push( qpath )
 		
-			If opts.target="android"		'probably all non-windows targets
-			
-				product.LD_SYSLIBS.Push( qpath )
+		Case ".a"
 			
+			If product.toolchain="gcc"
+				product.LIB_FILES.Push( qpath )
 			Endif
 			
-			product.DLL_FILES.Push( path )
+		Case ".so",".dylib"
 			
-		Case ".dll",".exe"
-		
-			product.DLL_FILES.Push( path )
+			If product.toolchain="gcc"
+				product.LIB_FILES.Push( qpath )
+				product.DLL_FILES.Push( path )
+			Endif
 			
-		Case ".dylib"
-		
-			product.LD_SYSLIBS.Push( qpath )
+		Case ".dll",".exe"
 			
-			product.DLL_FILES.Push( path )
+			If opts.target="windows"
+				product.DLL_FILES.Push( path )
+			Endif
 			
 		Case ".framework"
-		
-			'OK, this is ugly...
-		
-			ImportLocalFile( ExtractDir( path )+"*.framework" )
-			
-			ImportSystemFile( StripDir( path ) )
 			
-			product.DLL_FILES.Push( path )
+			If product.toolchain="gcc"
+				'OK, this is ugly...
+				ImportLocalFile( ExtractDir( path )+"*.framework" )
+				ImportSystemFile( StripDir( path ) )
+				product.DLL_FILES.Push( path )
+			Endif
 		
 		Default
 		

+ 16 - 25
src/mx2cc/buildproduct.monkey2

@@ -8,22 +8,27 @@ Class BuildProduct
 	Field imports:=New Stack<Module>
 	Field outputFile:String
 	
+	Field toolchain:String
+
 	Field CC_OPTS:String
 	Field CPP_OPTS:String
 	Field AS_OPTS:String
 	Field LD_OPTS:String
 	
-	Field SRC_FILES:=New StringStack
-	Field OBJ_FILES:=New StringStack
-	Field LD_SYSLIBS:=New StringStack
+	Field SRC_FILES:=New StringStack	'source code files
+	Field JAVA_FILES:=New StringStack	'java files
+	Field OBJ_FILES:=New StringStack	'object code files - added to module .a
+	Field LIB_FILES:=New StringStack	'library files - passed to linker.
+	Field DLL_FILES:=New StringStack	'dll/exe files, copied to app dir.
+	
 	Field ASSET_FILES:=New StringStack
-	Field JAVA_FILES:=New StringStack
-	Field DLL_FILES:=New StringStack
 	
 	Method New( module:Module,opts:BuildOpts )
 		Self.module=module
 		Self.opts=opts
 		
+		toolchain=opts.target="windows" And Int( GetEnv( "MX2_USE_MSVC" ) ) ? "msvc" Else "gcc"
+		
 		Local copts:=""
 		copts+=" -I~q"+MODULES_DIR+"~q"
 		copts+=" -I~q"+MODULES_DIR+"monkey/native~q"
@@ -256,8 +261,6 @@ End
 
 Class GccBuildProduct Extends BuildProduct
 	
-	Field toolchain:String
-
 	Field CC_CMD:=""
 	Field CXX_CMD:=""
 	Field AS_CMD:=""
@@ -267,8 +270,6 @@ Class GccBuildProduct Extends BuildProduct
 	Method New( module:Module,opts:BuildOpts )
 		Super.New( module,opts )
 		
-		toolchain=opts.target="windows" And Int( GetEnv( "MX2_USE_MSVC" ) ) ? "msvc" Else "gcc"
-		
 		Local target:="_"+opts.target.ToUpper()
 		Local config:="_"+opts.config.ToUpper()
 		
@@ -460,8 +461,6 @@ Class GccBuildProduct Extends BuildProduct
 			
 		Else If toolchain="msvc"
 			
-			'args="-out:~q"+output+"~q"+args
-
 			Local tmp:=AllocTmpFile( "libFiles" )
 			SaveString( args,tmp )
 			
@@ -479,7 +478,6 @@ Class GccBuildProduct Extends BuildProduct
 #Else
 			cmd=AR_CMD+" q ~q"+output+"~q"+args
 #Endif
-			
 		Endif
 		
 		Exec( cmd )
@@ -503,8 +501,8 @@ Class GccBuildProduct Extends BuildProduct
 			If ExtractExt( outputFile ).ToLower()<>".exe" outputFile+=".exe"
 				
 			If toolchain="msvc"
-				If opts.appType="gui" cmd+=" -subsystem:windows" Else cmd+=" -subsystem:console"
 '				cmd+=" -entry:main"
+				If opts.appType="gui" cmd+=" -subsystem:windows" Else cmd+=" -subsystem:console"
 			Else
 				If opts.appType="gui" cmd+=" -mwindows"
 			Endif
@@ -565,7 +563,7 @@ Class GccBuildProduct Extends BuildProduct
 		If opts.verbose>=0 Print "Linking "+outputFile+"..."
 			
 		If toolchain="msvc"
-			cmd+=" -out:~q"+outputFile+"~q"
+			cmd+=" -entry:mainCRTStartup -out:~q"+outputFile+"~q"
 		Else
 			cmd+=" -o ~q"+outputFile+"~q"
 		Endif
@@ -582,14 +580,7 @@ Class GccBuildProduct Extends BuildProduct
 			lnkFiles+=" ~q"+afile+"~q"
 		Next
 
-		If toolchain="msvc"
-			For Local i:=0 Until LD_SYSLIBS.Length
-				Local lib:=LD_SYSLIBS[i]
-				If lib.StartsWith( "-l" ) LD_SYSLIBS[i]=lib.Slice( 2 )+".lib"
-			Next
-		endif
-
-		lnkFiles+=" "+LD_SYSLIBS.Join( " " )
+		lnkFiles+=" "+LIB_FILES.Join( " " )
 		
 #If __TARGET__="windows"
 		lnkFiles=lnkFiles.Replace( " -Wl,"," " )
@@ -599,7 +590,7 @@ Class GccBuildProduct Extends BuildProduct
 #Else
 		cmd+=lnkFiles
 #Endif
-CopyAssets( assetsDir )
+		CopyAssets( assetsDir )
 		
 		CopyDlls( dllsDir )
 		
@@ -650,7 +641,7 @@ Class IosBuildProduct Extends GccBuildProduct
 
 		If opts.wholeArchive cmd+=" -Wl,--no-whole-archive"
 		
-		For Local lib:=Eachin LD_SYSLIBS
+		For Local lib:=Eachin LIB_FILES
 			If lib.ToLower().EndsWith( ".a~q" ) cmd+=" "+lib
 		Next
 		
@@ -803,7 +794,7 @@ Class AndroidBuildProduct Extends BuildProduct
 			
 			buf.Push( "LOCAL_LDLIBS += -ldl" )
 			
-			For Local lib:=Eachin LD_SYSLIBS
+			For Local lib:=Eachin LIB_FILES
 				If lib.StartsWith( "-l" ) buf.Push( "LOCAL_LDLIBS += "+lib )
 			Next
 			

+ 13 - 1
src/mx2cc/mx2cc.monkey2

@@ -19,10 +19,18 @@ Using libc..
 Using std..
 Using mx2..
 
+#If __CONFIG__="debug"
+Const FORCE_MSVC:=False
+#Endif
+
 Global StartDir:String
 
+'Const TestArgs:="mx2cc makemods -clean"
+
 'Const TestArgs:="mx2cc makemods -clean monkey"
 
+'Const TestArgs:="mx2cc makemods -config=debug monkey libc miniz stb-image stb-image-write stb-vorbis std"
+
 Const TestArgs:="mx2cc makeapp -target=desktop -apptype=console -run src/mx2cc/test.monkey2"
 
 'To build with old mx2cc...
@@ -38,7 +46,7 @@ Const TestArgs:="mx2cc makeapp -target=desktop -apptype=console -run src/mx2cc/t
 'Const TestArgs:="mx2cc makeapp -build -clean -config=release -target=raspbian src/mx2cc/mx2cc.monkey2"
 
 Function Main()
-	
+
 	'Set aside 64M for GC!
 	GCSetTrigger( 64*1024*1024 )
 
@@ -60,6 +68,10 @@ Function Main()
 
 	LoadEnv( env )
 	
+#If __CONFIG__="debug"
+	If FORCE_MSVC libc.setenv( "MX2_USE_MSVC","1",1 )
+#Endif
+	
 	Local args:=AppArgs()
 	
 	If args.Length<2

+ 31 - 4
src/mx2cc/test.monkey2

@@ -1,9 +1,36 @@
+Namespace myapp
 
-Function Main()
+#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 )
+		
+		New Fiber( Lambda()
+			Print "HERE"
+		End )
+	End
+
+	Method OnRender( canvas:Canvas ) Override
 	
-	Print ULong( ".1" )
+		App.RequestRender()
+	
+		canvas.DrawText( "Hello World!",Width/2,Height/2,.5,.5 )
+	End
+	
+End
+
+Function Main()
+
+	New AppInstance
 	
-	Local x:Int=.1
-	Print x
+	New MyWindow
 	
+	App.Run()
 End

+ 1 - 1
src/ted2/helpactions.monkey2

@@ -34,7 +34,7 @@ Class HelpActions
 		about.Triggered=Lambda()
 		
 			Local htmlView:=New HtmlView
-			htmlView.Go( "asset::ted2/about.html" )
+			htmlView.Go( "ABOUT.HTML" )
 	
 			Local dialog:=New Dialog( "About monkey2" )
 			dialog.ContentView=htmlView

+ 1 - 6
src/ted2/mainwindow.monkey2

@@ -1,8 +1,6 @@
 
 Namespace ted2
 
-#Import "assets/about.html@/ted2"
-
 #Import "assets/themes/@/themes"
 
 #Import "assets/newfiles/@/ted2/newfiles"
@@ -58,10 +56,7 @@ Class MainWindowInstance Extends Window
 		_buildConsole=New Console
 		_outputConsole=New Console
 		_helpView=New HtmlView
-'		_helpView.Style=New Style( _helpView.Style )
-'		_helpView.Style.Border=New Recti( 0,-4,0,0 )
-'		_helpView.Style.BorderColor=App.Theme.GetColor( "content" )
-		_helpView.Go( "asset::ted2/about.html" )
+		_helpView.Go( "ABOUT.HTML" )
 		
 		_projectView=New ProjectView( _docsManager )
 		

+ 167 - 0
src/ted2/scenedocument.monkey2

@@ -0,0 +1,167 @@
+
+Namespace ted2
+
+#Import "<mojo3d>"
+#Import "<mojo3d-assimp>"
+
+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()
+		
+		If Keyboard.KeyDown( Key.Up )
+			model.RotateX( .1 )
+		Else If Keyboard.KeyDown( Key.Down )
+			model.RotateX( -.1 )
+		Endif
+		
+		If Keyboard.KeyDown( Key.Left )
+			model.RotateY( .1,True )
+		Else If Keyboard.KeyDown( Key.Right )
+			model.RotateY( -.1,True )
+		Endif
+
+		If Keyboard.KeyDown( Key.A )
+			_doc.Camera.MoveZ( .1 )
+		Else If Keyboard.KeyDown( Key.Z )
+			_doc.Camera.MoveZ( -.1 )
+		Endif
+		
+		_doc.Scene.Render( canvas,_doc.Camera )
+	End
+	
+	Method OnMouseEvent( event:MouseEvent ) Override
+	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=.1
+		_camera.Far=100
+		_camera.MoveZ( -2.5 )
+			
+		_light=New Light
+		_light.RotateX( Pi/2 )
+		
+		Scene.SetCurrent( Null )
+	End
+	
+	Property Model:Model()
+	
+		Return _model
+	End
+	
+	Property Scene:Scene()
+		
+		Return _scene
+	End
+	
+	Property Camera:Camera()
+		
+		Return _camera
+	End
+	
+	Protected
+	
+	Method OnLoad:Bool() Override
+
+		Scene.SetCurrent( _scene )
+		
+		Print "Loading model:"+Path
+
+		_model=Model.Load( Path )
+
+		If _model
+			_model.Mesh.FitVertices( New Boxf( -1,1 ) )
+		Endif
+		
+		Scene.SetCurrent( Null )
+	
+		Return True
+	End
+	
+	Method OnSave:Bool() Override
+
+		Return False
+	End
+	
+	Method OnClose() Override
+		
+	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[]( ".b3d",".3ds",".dae" )
+	End
+	
+	Method OnCreateDocument:Ted2Document( path:String ) Override
+		
+		Return New SceneDocument( path )
+	End
+	
+	Private
+	
+	Global _instance:=New SceneDocumentType
+	
+End

+ 2 - 0
src/ted2/ted2.monkey2

@@ -35,6 +35,8 @@
 #import "jsondocument"
 #import "xmldocument"
 
+'#Import "scenedocument"
+
 #import "textviewkeyeventfilter"
 
 #Import "buildproduct"

+ 77 - 18
src/ted2go/MainWindow.monkey2

@@ -53,8 +53,45 @@ Class MainWindowInstance Extends Window
 			SaveState()
 		End
 
+		'Build tab
+		
 		_buildConsole=New ConsoleExt
+		
+		'Output tab
+		
 		_outputConsole=New ConsoleExt
+		Local bar:=New ToolBarExt
+		bar.MaxSize=New Vec2i( 300,30 )
+		
+		bar.AddIconicButton(
+			ThemeImages.Get( "outputbar/clean.png" ),
+			Lambda()
+				_outputConsole.ClearAll()
+			End,
+			"Clear all" )
+		
+		'bar.AddSeparator()
+		'bar.AddSeparator()
+			
+		Local label:=New Label( "Filter:" )
+		bar.AddView( label,"left" )
+		Local editFilter:=New TextField()
+		editFilter.Style=GetStyle( "TextFieldBordered" )
+		editFilter.CursorType=CursorType.Line
+		editFilter.CursorBlinkRate=2.5
+		bar.AddView( editFilter,"left",200 )
+		editFilter.TextChanged+=Lambda()
+		
+			Local t:=editFilter.Text
+			_outputConsole.SetFilter( t )
+		End
+		
+		_outputConsoleView=New DockingView
+		_outputConsoleView.AddView( bar,"top" )
+		_outputConsoleView.ContentView=_outputConsole
+		
+		
+		'Find tab
 		
 		_findConsole=New TreeViewExt
 		_findConsole.NodeClicked+=Lambda( node:TreeView.Node )
@@ -79,7 +116,7 @@ Class MainWindowInstance Extends Window
 		
 		_helpView=New HtmlViewExt
 		_helpConsole=New DockingView
-		Local bar:=New ToolBarExt
+		bar=New ToolBarExt
 		bar.MaxSize=New Vec2i( 300,30 )
 		bar.AddIconicButton(
 			ThemeImages.Get( "docbar/home.png" ),
@@ -102,7 +139,7 @@ Class MainWindowInstance Extends Window
 			"Forward" )
 		bar.AddSeparator()
 		bar.AddSeparator()
-		Local label:=New Label
+		label=New Label
 		bar.AddView( label,"left" )
 		
 		_helpView.Navigated+=Lambda( url:String )
@@ -252,6 +289,8 @@ Class MainWindowInstance Extends Window
 		_buildMenu.AddAction( _buildActions.buildAndRun )
 		_buildMenu.AddAction( _buildActions.build )
 		_buildMenu.AddAction( _buildActions.semant )
+		_buildMenu.AddAction( _buildActions.debugApp )
+		_buildMenu.AddSeparator()
 		_buildMenu.AddSubMenu( _buildActions.targetMenu )
 		_buildMenu.AddSeparator()
 		_buildMenu.AddAction( _forceStop )
@@ -313,7 +352,7 @@ Class MainWindowInstance Extends Window
 		_browsersTabView.AddTab( "Help",_helpTree,False )
 		
 		_consolesTabView.AddTab( "Build",_buildConsole,True )
-		_consolesTabView.AddTab( "Output",_outputConsole,False )
+		_consolesTabView.AddTab( "Output",_outputConsoleView,False )
 		_consolesTabView.AddTab( "Docs",_helpConsole,False )
 		_consolesTabView.AddTab( "Find",_findConsole,False )
 		
@@ -506,10 +545,12 @@ Class MainWindowInstance Extends Window
 	Method StoreConsoleVisibility()
 		
 		_storedConsoleVisible=_consolesTabView.Visible
+		_consoleVisibleCounter=0
 	End
 	
 	Method RestoreConsoleVisibility()
 	
+		If _consoleVisibleCounter > 0 Return
 		_consolesTabView.Visible=_storedConsoleVisible
 		RequestRender()
 	End
@@ -540,7 +581,7 @@ Class MainWindowInstance Extends Window
 		Local pos:=tv.Cursor-tv.Document.StartOfLine( line )
 		line+=1
 		pos+=1
-		_statusBar.SetLineInfo( "Ln : "+line+"  Col : "+pos )
+		_statusBar.SetLineInfo( "Ln : "+line+"    Col : "+pos )
 	End
 	
 	Method ShowStatusBarProgress( cancelCallback:Void(),cancelIconOnly:Bool=False )
@@ -572,6 +613,7 @@ Class MainWindowInstance Extends Window
 		Local buildTitle:=GetActionTextWithShortcut( _buildActions.build )
 		Local checkTitle:=GetActionTextWithShortcut( _buildActions.semant )
 		Local findTitle:=GetActionTextWithShortcut( _findActions.find )
+		Local debugTitle:=GetActionTextWithShortcut( _buildActions.debugApp )
 		
 		_toolBar=New ToolBarExt
 		_toolBar.Style=GetStyle( "MainToolBar" )
@@ -588,6 +630,7 @@ Class MainWindowInstance Extends Window
 		_toolBar.AddIconicButton( ThemeImages.Get( "toolbar/check.png" ),_buildActions.semant.Triggered,checkTitle )
 		_toolBar.AddIconicButton( ThemeImages.Get( "toolbar/build.png" ),_buildActions.build.Triggered,buildTitle )
 		_toolBar.AddIconicButton( ThemeImages.Get( "toolbar/run.png" ),_buildActions.buildAndRun.Triggered,runTitle )
+		_toolBar.AddIconicButton( ThemeImages.Get( "toolbar/debug.png" ),_buildActions.debugApp.Triggered,debugTitle )
 		_toolBar.AddSeparator()
 		
 		Local act:=Lambda()
@@ -642,7 +685,7 @@ Class MainWindowInstance Extends Window
 	
 	Method ShowOutputConsole( vis:Bool=True )
 		If vis _consolesTabView.Visible=True
-		_consolesTabView.CurrentView=_outputConsole
+		_consolesTabView.CurrentView=_outputConsoleView
 	End
 	
 	Method ShowHelpView()
@@ -801,14 +844,18 @@ Class MainWindowInstance Extends Window
 		
 		jobj["windowRect"]=ToJson( Frame )
 		
-		jobj["browserSize"]=New JsonNumber( Int( _contentView.GetViewSize( _browsersTabView ) ) )
-		jobj["browserVisible"]=New JsonBool( _browsersTabView.Visible )
+		Local vis:Bool
+		vis=_browsersTabView.Visible
+		jobj["browserVisible"]=New JsonBool( vis )
 		jobj["browserTab"]=New JsonString( GetBrowsersTabAsString() )
+		If vis Then _browsersSize=Int( _contentView.GetViewSize( _browsersTabView ) )
+		If _browsersSize > 0 Then jobj["browserSize"]=New JsonNumber( _browsersSize )
 		
-		jobj["consoleSize"]=New JsonNumber( Int( _contentView.GetViewSize( _consolesTabView ) ) )
-		jobj["consoleVisible"]=New JsonBool( _consolesTabView.Visible )
+		vis=_consolesTabView.Visible
+		jobj["consoleVisible"]=New JsonBool( vis )
 		jobj["consoleTab"]=New JsonString( GetConsolesTabAsString() )
-		
+		If vis Then _consolesSize=Int( _contentView.GetViewSize( _consolesTabView ) ) 
+		If _consolesSize > 0 Then jobj["consoleSize"]=New JsonNumber( _consolesSize )
 		
 		Local recent:=New JsonArray
 		For Local path:=Eachin _recentFiles
@@ -889,11 +936,17 @@ Class MainWindowInstance Extends Window
 	
 	Method LoadState( jobj:JsonObject )
 	
-		If jobj.Contains( "browserSize" ) _contentView.SetViewSize( _browsersTabView,jobj.GetNumber( "browserSize" ) )
+		If jobj.Contains( "browserSize" )
+			_browsersSize=Int( jobj.GetNumber( "browserSize" ) )
+			_contentView.SetViewSize( _browsersTabView,_browsersSize )
+		Endif
 		If jobj.Contains( "browserVisible" ) _browsersTabView.Visible=jobj.GetBool( "browserVisible" )
 		If jobj.Contains( "browserTab" ) SetBrowsersTabByString( jobj.GetString( "browserTab" ) )
 		
-		If jobj.Contains( "consoleSize" ) _contentView.SetViewSize( _consolesTabView,jobj.GetNumber( "consoleSize" ) )
+		If jobj.Contains( "consoleSize" )
+			_consolesSize=Int( jobj.GetNumber( "consoleSize" ) )
+			_contentView.SetViewSize( _consolesTabView,_consolesSize )
+		Endif
 		If jobj.Contains( "consoleVisible" ) _consolesTabView.Visible=jobj.GetBool( "consoleVisible" )
 		If jobj.Contains( "consoleTab" ) SetConsolesTabByString( jobj.GetString( "consoleTab" ) )
 		
@@ -953,6 +1006,7 @@ Class MainWindowInstance Extends Window
 					_browsersTabView.Visible=Not _browsersTabView.Visible
 				Else
 					_consolesTabView.Visible=Not _consolesTabView.Visible
+					_consoleVisibleCounter+=1
 				Endif
 			Case Key.Keypad1
 			End
@@ -987,8 +1041,9 @@ Class MainWindowInstance Extends Window
 	Field _helpActions:HelpActions
 	Field _viewActions:ViewActions
 	
-	Field _buildConsole:Console
-	Field _outputConsole:Console
+	Field _buildConsole:ConsoleExt
+	Field _outputConsole:ConsoleExt
+	Field _outputConsoleView:DockingView
 	Field _helpView:HtmlViewExt
 	Field _helpConsole:DockingView
 	Field _findConsole:TreeViewExt
@@ -1017,8 +1072,8 @@ Class MainWindowInstance Extends Window
 	
 	Field _themesMenu:MenuExt
 	
-	Field _theme:String="default"
-	Field _themeScale:Float=1
+	Field _theme:="default"
+	Field _themeScale:=1.0
 	
 	Field _contentView:DockingView
 	Field _contentLeftView:DockingView
@@ -1033,8 +1088,12 @@ Class MainWindowInstance Extends Window
 	Field _statusBar:StatusBarView
 	Field _ovdMode:=False
 	Field _storedConsoleVisible:Bool
+	Field _consoleVisibleCounter:=0
 	Field _isTerminating:Bool
 	Field _enableSaving:Bool
+	Field _browsersSize:=0,_consolesSize:=0
+	
+	
 	
 	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 ) ) )
@@ -1215,7 +1274,7 @@ Class MainWindowInstance Extends Window
 	Method GetConsolesTabAsString:String()
 		
 		Select _consolesTabView.CurrentView
-			Case _outputConsole
+			Case _outputConsoleView
 				Return "output"
 			Case _buildConsole
 				Return "build"
@@ -1232,7 +1291,7 @@ Class MainWindowInstance Extends Window
 		Local view:View
 		Select value
 			Case "output"
-				view=_outputConsole
+				view=_outputConsoleView
 			Case "build"
 				view=_buildConsole
 			Case "docs"

+ 2 - 1
src/ted2go/Prefs.monkey2

@@ -9,9 +9,10 @@ Class Prefs
 	Global AcShowAfter:=2
 	Global AcUseTab:=True
 	Global AcUseEnter:=False
-	Global AcUseSpace:=True
+	Global AcUseSpace:=False
 	Global AcUseDot:=False
 	Global AcNewLineByEnter:=True
+	Global AcStrongFirstChar:=True
 	'
 	Global MainToolBarVisible:=True
 	Global MainProjectTabsRight:=True

+ 1 - 1
src/ted2go/README.md

@@ -1,5 +1,5 @@
 # Ted2Go
-My custom version of Ted2 IDE.
+An IDE for Monkey2 programming language.
 
 ## Benefits & Goals
 * Autocompletion for keywords, modules and user's code (WIP).

+ 1 - 1
src/ted2go/Ted2.monkey2

@@ -109,7 +109,7 @@ Using mojox..
 Using tinyxml2..
 
 
-Global AppTitle:="Ted2Go v2.3.1"
+Global AppTitle:="Ted2Go v2.3.2"
 
 
 Function Main()

+ 23 - 5
src/ted2go/action/BuildActions.monkey2

@@ -34,6 +34,7 @@ End
 Class BuildActions Implements IModuleBuilder
 
 	Field buildAndRun:Action
+	Field debugApp:Action
 	Field build:Action
 	Field semant:Action
 	Field buildSettings:Action
@@ -49,7 +50,7 @@ Class BuildActions Implements IModuleBuilder
 	
 	Field PreBuild:Void()
 	
-	Method New( docs:DocumentManager,console:Console,debugView:DebugView )
+	Method New( docs:DocumentManager,console:ConsoleExt,debugView:DebugView )
 	
 		_docs=docs
 		_console=console
@@ -60,7 +61,7 @@ Class BuildActions Implements IModuleBuilder
 			If doc=_locked _locked=Null
 		End
 		
-		buildAndRun=New Action( "Build and run" )
+		buildAndRun=New Action( "Run" )
 #If __TARGET__="macos"
 		buildAndRun.HotKey=Key.R
 		buildAndRun.HotKeyModifiers=Modifier.Menu
@@ -69,8 +70,16 @@ Class BuildActions Implements IModuleBuilder
 #Endif
 		buildAndRun.Triggered=OnBuildAndRun
 		
+		debugApp=New Action( "Debug" )
+#If __TARGET__="macos"
+		debugApp.HotKey=Key.D
+		debugApp.HotKeyModifiers=Modifier.Menu
+#Else
+		debugApp.HotKey=Key.F8
+#Endif
+		debugApp.Triggered=OnDebugApp
 
-		build=New Action( "Build only" )
+		build=New Action( "Build" )
 #If __TARGET__="macos"
 		build.HotKey=Key.B
 		build.HotKeyModifiers=Modifier.Menu
@@ -79,7 +88,7 @@ Class BuildActions Implements IModuleBuilder
 #Endif
 		build.Triggered=OnBuild
 		
-		semant=New Action( "Check app" )
+		semant=New Action( "Check" )
 #If __TARGET__="macos"
 		semant.HotKey=Key.R
 		semant.HotKeyModifiers=Modifier.Menu|Modifier.Shift
@@ -330,7 +339,7 @@ Class BuildActions Implements IModuleBuilder
 	Private
 	
 	Field _docs:DocumentManager
-	Field _console:Console
+	Field _console:ConsoleExt
 	Field _debugView:DebugView
 	
 	Field _locked:CodeDocument
@@ -569,6 +578,15 @@ Class BuildActions Implements IModuleBuilder
 		BuildApp( _buildConfig,_buildTarget,"run" )
 	End
 	
+	Method OnDebugApp()
+	
+		PreBuild()
+	
+		If _console.Running Return
+	
+		BuildApp( "debug",_buildTarget,"run" )
+	End
+	
 	Method OnBuild()
 		
 		PreBuild()

+ 18 - 5
src/ted2go/action/FindActions.monkey2

@@ -23,7 +23,9 @@ Class FindActions
 		find.HotKeyModifiers=Modifier.Menu
 		
 		findNext=New Action( "Find next" )
-		findNext.Triggered=OnFindNext
+		findNext.Triggered=Lambda()
+			OnFindNext()
+		End
 		findNext.HotKey=Key.F3
 		
 		findPrevious=New Action( "Find previous" )
@@ -58,6 +60,12 @@ Class FindActions
 		replaceAll.Enabled=tv
 	End
 	
+	Method FindByTextChanged()
+		
+		OnFindNext( False )
+	End
+	
+	
 	Private
 	
 	Field _docs:DocumentManager
@@ -65,7 +73,7 @@ Class FindActions
 	Field _findDialog:FindDialog
 	Field _findInFilesDialog:FindInFilesDialog
 	Field _findConsole:TreeViewExt
-	
+	Field _cursorPos:=0
 	
 	Method OnFind()
 		
@@ -79,6 +87,7 @@ Class FindActions
 				Local s:=tv.Text.Slice( min,max )
 				_findDialog.SetInitialText( s )
 			Endif
+			_cursorPos=Min( tv.Cursor,tv.Anchor )
 		Endif
 	End
 	
@@ -97,7 +106,7 @@ Class FindActions
 		Endif
 	End
 	
-	Method OnFindNext()
+	Method OnFindNext( changeCursorPos:Bool=True )
 	
 		Local tv:=_docs.CurrentTextView
 		If Not tv Return
@@ -106,7 +115,11 @@ Class FindActions
 		If Not text Return
 		
 		Local tvtext:=tv.Text
-		Local cursor:=Max( tv.Anchor,tv.Cursor )
+		Local cursor:=_cursorPos
+		If changeCursorPos
+			cursor=Max( tv.Anchor,tv.Cursor )
+			_cursorPos=cursor
+		Endif
 		
 		If Not _findDialog.CaseSensitive
 			tvtext=tvtext.ToLower()
@@ -166,7 +179,7 @@ Class FindActions
 		Local root:=_findConsole.RootNode
 		root.RemoveAllChildren()
 		
-		root.Text="Finding of '"+what+"'"
+		root.Text="Results for '"+what+"'"
 		
 		Local subRoot:TreeView.Node
 		Local items:=New Stack<FileJumpData>

+ 1 - 1
src/ted2go/assets/aboutTed2Go.html

@@ -120,7 +120,7 @@ Enjoy coding!</p>
 
 <h3>Special Thanks</h3>
 
-<p>Peter Scheutz, Matthieu Chemin, David Maziarka, Leonardo Teixeira, Jesus Perez, Mark Sibly, Philipp Moeller, Lee Wade.</p>
+<p>Sal Gunduz, Peter Scheutz, Matthieu Chemin, David Maziarka, Leonardo Teixeira, Jesus Perez, Mark Sibly, Philipp Moeller, Lee Wade.</p>
 
 </body>
 

BIN
src/ted2go/assets/themes/outputbar/clean.png


+ 6 - 0
src/ted2go/assets/themes/ted2-default.json

@@ -113,6 +113,12 @@
 			"extends":"ToolButton",
 			"padding":[ 0 ],
 			"skinColor":"transparent"
+		},
+		
+		"TextFieldBordered":{
+			"extends":"TextField",
+			"border":[ 1 ],
+			"borderColor":"clear"
 		}
 		
 	}

BIN
src/ted2go/assets/themes/toolbar/check.png


+ 7 - 0
src/ted2go/dialog/FindDialog.monkey2

@@ -13,6 +13,13 @@ Class FindDialog Extends DialogExt
 		_findField.Entered+=Lambda()
 			actions.findNext.Trigger()
 		End
+		_findField.TextChanged+=Lambda(  )
+			
+			Local t:=_findField.Text
+			If t.Length > 1
+				actions.FindByTextChanged()
+			Endif
+		End
 
 		_findField.Tabbed+=_replaceField.MakeKeyView
 

+ 7 - 0
src/ted2go/parser/CodeItem.monkey2

@@ -535,6 +535,13 @@ Struct CodeItemsSorter Final
 			Endif
 		Next
 		
+		' strong first char
+		If Prefs.AcStrongFirstChar
+			Local lower1:=IsLowercacedFirstChar( ident )
+			Local lower2:=IsLowercacedFirstChar( etalon )
+			If lower1 <> lower2 Then power-=10000
+		End
+		
 		Return power
 	End
 	

+ 1 - 0
src/ted2go/parser/Monkey2Parser.monkey2

@@ -1004,6 +1004,7 @@ Class Monkey2Parser Extends CodeParserPlugin
 	Method CheckIdent:Bool( ident1:String,ident2:String,startsOnly:Bool,smartStarts:Bool=True )
 	
 		If ident2 = "" Return True
+		
 		If startsOnly
 			Return smartStarts ? CheckStartsWith( ident1,ident2 ) Else ident1.StartsWith( ident2 )
 		Else

+ 14 - 4
src/ted2go/product/ModuleManager.monkey2

@@ -4,6 +4,9 @@ Namespace ted2go
 
 Private
 
+Const MONKEY2_DOMAIN:="http://monkeycoder.co.nz"
+
+
 Class Module
 	Field name:String
 	Field about:String
@@ -18,7 +21,7 @@ Public
 
 Class ModuleManager Extends Dialog
 
-	Method New( console:Console )
+	Method New( console:ConsoleExt )
 		Super.New( "Module Manager" )
 		
 		_console=console
@@ -99,13 +102,14 @@ Class ModuleManager Extends Dialog
 	Private
 	
 	'Const downloadUrl:="http://monkey2.monkey-x.com/wp-content/uploads/mx2-modules/public/"
-    Const downloadUrl:="http://monkey2.monkey-x.com/send-file?file="
-    
+    'Const downloadUrl:="http://monkey2.monkey-x.com/send-file?file="
+    Const downloadUrl:=MONKEY2_DOMAIN+"/send-file?file="
+	
 	Const downloadDir:="modules/module-manager/downloads/"
 	
 	Const backupDir:="modules/module-manager/backups/"
 	
-	Field _console:Console
+	Field _console:ConsoleExt
 	Field _docker:DockingView
 	Field _modules:=New StringMap<Module>
 	Field _filters:=New StringMap<CheckButton>
@@ -601,6 +605,12 @@ Class ModuleManager Extends Dialog
 
 		Next
 		
+		' some bottom pagdding
+		_table.Rows+=1
+		Local label:=New Label( "" )
+		label.MinSize=New Vec2i( 0,30 )
+		_table[0,_table.Rows-1]=label
+		
 		App.RequestRender()
 	
 	End

+ 1 - 1
src/ted2go/product/Mx2ccEnv.monkey2

@@ -83,7 +83,7 @@ End
 
 Public
 
-Function EnumValidTargets:StringStack( console:Console )
+Function EnumValidTargets:StringStack( console:ConsoleExt )
 
 	LoadEnv()
 	

+ 8 - 0
src/ted2go/utils/Utils.monkey2

@@ -2,6 +2,14 @@
 Namespace ted2go
 
 
+Function IsLowercacedFirstChar:Bool(s:String)
+	
+	If Not s Return False
+	Local s1:=s.Slice( 0,1 )
+	Return s1 = s1.ToLower()
+End
+
+
 Class Utils
 	
 	Function ArrayContains<T>:Bool( arr:T[],value:T )

+ 272 - 3
src/ted2go/view/ConsoleViewExt.monkey2

@@ -2,21 +2,246 @@
 Namespace ted2go
 
 
-Class ConsoleExt Extends Console
+#if __TARGET__<>"emscripten"
 
+#rem monkeydoc The Console class.
+#end
+Class ConsoleExt Extends TextView
+
+	#rem monkeydoc Invoked when the console finishes executing a process.
+	#end
+	Field Finished:Void( exitCode:Int )
+	
+	#rem monkeydoc Creates a new console.
+	#end
 	Method New()
-		Super.New()
+		Style=GetStyle( "Console" )
+		
+		ReadOnly=True
+	End
+	
+	#rem monkeydoc True if the process is running.
+	#end
+	Property Running:Bool()
+
+		Return _running
+	End
+	
+	#rem monkeydoc The process.
+	#end
+	Property Process:Process()
+
+		Return _process
+	End
+	
+	#rem monkeydoc Process exit code.
+	
+	If the process is still running, -1 is returned.
+	
+	#end
+	Property ExitCode:Int()
+
+		If _process And Not _procOpen return _process.ExitCode
+
+		Return -1
+	End
+	
+	#rem monkeydoc Runs a process.
+	
+	Returns true if the process was successfully started, else false.
+	
+	Process stdout is written to the console while the process is running.
+	
+	This method waits for the process to complete, so should always be called on a fiber.
+	
+	#end
+	Method Run:Bool( cmd:String )
+	
+		If Not Start( cmd )
+			Alert( "Failed to start process '"+cmd+"'" )
+			Return False
+		Endif
+		
+		Repeat
+		
+			Local stdout:=ReadStdout()
+			If Not stdout Exit
+			
+			Write( stdout )
+		Forever
+		
+		Return True
+	End
+
+	#rem monkeydoc Starts a process.
+	
+	Returns true if the process was successfully started, else false.
+	
+	#end	
+	Method Start:Bool( cmd:String )
+	
+		If _running Return False
+		
+		Local process:=New Process
+	
+		process.Finished=Lambda()
+			_procOpen=False
+			UpdateRunning()
+		End
+		
+		process.StdoutReady=Lambda()
+		
+			Local stdout:=process.ReadStdout()
+			
+'			Print "**** CONSOLE STDOUT *****"
+'			Print stdout
+'			Print "***** END STDOUT *****"
+			
+			If Not stdout
+				If _stdout _stdoutBuf.Add( _stdout )
+				_stdoutOpen=False
+				UpdateRunning()
+				Return
+			Endif
+			
+			stdout=_stdout+(stdout.Replace( "~r~n","~n" ).Replace( "~r","~n" ))
+			
+			Local i0:=0
+			Repeat
+				Local i:=stdout.Find( "~n",i0 )
+				If i=-1
+					_stdout=stdout.Slice( i0 )
+					Exit
+				Endif
+				_stdoutBuf.Add( stdout.Slice( i0,i+1 ) )
+				i0=i+1
+			Forever
+			
+			If _stdoutWaiting And Not _stdoutBuf.Empty _stdoutWaiting.Set( True )
+			
+		End
+		
+		If Not process.Start( cmd ) Return False
+		
+		_process=process
+		
+		_running=True
+		_procOpen=True
+		_stdoutOpen=True
+
+		_stdout=""
+		_stdoutBuf.Clear()
+		_stdoutWaiting=Null
+		
+		Return True
+	End
+	
+	#rem monkeydoc Reads process stdout.
+	
+	If an empty string is returned, the process has finished.
+	
+	This method may have to wait for stdout to become available, so should always be called on a fiber.
+	
+	#end
+	Method ReadStdout:String()
+	
+		While _stdoutBuf.Empty
+		
+			If Not _stdoutOpen
+				If _procOpen
+					_stdoutWaiting=New Future<Bool>
+					_stdoutWaiting.Get()
+					_stdoutWaiting=Null
+				Endif
+				Return ""
+			Endif
+			
+			_stdoutWaiting=New Future<Bool>
+			_stdoutWaiting.Get()
+			_stdoutWaiting=Null
+		Wend
+		
+		Return _stdoutBuf.RemoveFirst()
+	End
+	
+	#rem monkeydoc Writes to process stdin.
+	#end
+	Method WriteStdin( str:String )
+	
+		If Not _procOpen Return
+	
+		_process.WriteStdin( str )
+	End
+	
+	#rem monkeydoc Terminates the process.
+	#end
+	Method Terminate()
+
+		If Not _procOpen Return
+		
+		_process.Terminate()
+	End
+	
+	#rem monkeydoc Writes text to the console.
+	#end
+	Method Write( text:String )
+	
+		_lines.Add( text )
+		AddFiltered( text )
+	End
+	
+	Method SetFilter( value:String )
+	
+		If value = _filter Return
+		
+		_filter=value
+		Clear()
+		For Local s:=Eachin _lines
+			AddFiltered( s )
+		End
+		
+		SelectText( Text.Length,Text.Length )
+	End
+	
+	Method ClearAll()
+		
+		Clear()
+		_lines.Clear()
 	End
 	
 	
 	Protected
 	
 	Method OnKeyEvent( event:KeyEvent ) Override
-		
+	
 		If CanCopy And (event.Key = Key.C Or event.Key = Key.Insert) And  event.Type = EventType.KeyDown And event.Modifiers & Modifier.Control
+		
 			Copy()
+			Return
 		Endif
 		
+		If event.Type = EventType.KeyDown
+			
+			If event.Key = Key.PageUp
+			
+				Scroll-=New Vec2i( 0,VisibleRect.Height )
+				
+			Else If event.Key = Key.PageDown
+			
+				Scroll+=New Vec2i( 0,VisibleRect.Height )
+				
+			Else If event.Modifiers & Modifier.Control
+				
+				If event.Key = Key.Home
+					SelectText( 0,0 )
+				Else If event.Key = Key.KeyEnd
+					SelectText( Text.Length,Text.Length )
+				Endif
+				
+			Endif
+		Endif
+	
+		'Super.OnKeyEvent( event )
 	End
 	
 	Method OnContentMouseEvent( event:MouseEvent ) Override
@@ -31,4 +256,48 @@ Class ConsoleExt Extends Console
 		Super.OnContentMouseEvent( event )
 	End
 	
+	
+	Private
+	
+	Field _lines:=New StringStack
+	Field _filter:=""
+	
+	Field _process:Process
+	
+	Field _running:Bool
+	Field _procOpen:Bool
+	Field _stdoutOpen:Bool
+
+	Field _stdout:String
+	Field _stdoutBuf:=New StringList
+	Field _stdoutWaiting:Future<Bool>
+	
+	Method UpdateRunning()
+	
+		If Not _running Or _procOpen Or _stdoutOpen Return
+		
+		_running=False
+		
+		Finished( _process.ExitCode )
+		
+		If _stdoutWaiting _stdoutWaiting.Set( True )
+	End
+
+	Method AddFiltered( text:String )
+		
+		If Not _filter Or text.Find( _filter) <> -1
+			Local cur:=Cursor,anc:=Anchor
+			Local sc:=Scroll
+			AppendText( text )
+			Local atBottom:=(Scroll.y-sc.y<=LineRect(Document.NumLines-1).Height) And cur=anc
+			If Not atBottom
+				Scroll=sc 'restore
+				SelectText( anc,cur )
+			Endif
+			
+		Endif
+	End
+	
 End
+
+#endif

+ 2 - 2
src/ted2go/view/DebugView.monkey2

@@ -4,7 +4,7 @@ Namespace ted2go
 
 Class DebugView Extends DockingView
 
-	Method New( docs:DocumentManager,console:Console )
+	Method New( docs:DocumentManager,console:ConsoleExt )
 	
 		_docs=docs
 		_console=console
@@ -279,7 +279,7 @@ Class DebugView Extends DockingView
 	Field _toolBar:ToolBar
 
 	Field _docs:DocumentManager	
-	Field _console:Console
+	Field _console:ConsoleExt
 
 	Field _debugging:Bool
 	Field _stopped:Bool