About Monkey 2 › Forums › Monkey 2 Development › Another modified version of Ted2
This topic contains 13 replies, has 5 voices, and was last updated by 
 cocon 2 years, 8 months ago.
- 
		AuthorPosts
 - 
		
			
				
August 8, 2016 at 9:43 pm #2887
This thread is obsolete due to changes, check this thread instead:
http://monkey2.monkey-x.com/forums/topic/ted2-experimental-plugin-system/Here is some changes I made to Ted2 test it and see if you like it.https://github.com/coconcode/ted2modAugust 9, 2016 at 5:45 am #2895what are the changes? couldn’t see any?
August 9, 2016 at 3:36 pm #2903Hi, thank for checking the project out.
I have mentioned some of information in the readme file, however my purpose is to make experimentation.
The best feature so far is the ability to configure the hotkeys with a JSON file.
https://github.com/coconcode/ted2mod/blob/master/hotkeyloader.monkey2Also I did a massive refactoring by redesigning the program (the commands of the IDE) by using a design pattern. I was very skeptic about this, although it makes the code more organized, it makes it over engineered. I am more of a Python-esque style fan, where you create lists at will and put whatever you like there, perhaps later with the reflection capabilities I will try to see this alternative.
https://github.com/coconcode/ted2mod/blob/master/idecommand.monkey2August 10, 2016 at 3:33 am #2909Automatic reloading of files when saving with another external editor is now ready.
https://github.com/coconcode/ted2mod/blob/master/documentwatcher.monkey2August 10, 2016 at 7:29 pm #2926Here is a video to see how to use Ted2 with an external text editor (i.e. Sublime).
https://1drv.ms/v/s!AquVr9J7xRcsgWyEt7ehOL5vPeycAugust 17, 2016 at 12:19 pm #3114Since Ted2 is much improved now, there was no need to keep obsolete features around. I did a hard reset of the repository to the current newest version of Ted2 and started on some new ideas.
At this time I thought of a new design on how to extend Ted2 without messing with the core codebase too much. Since it’s better Ted2 to remain a simple project and solid project, any additional functionality could be implemented in a more flexible way.
https://github.com/coconcode/ted2mod/blob/master/extension.monkey2
https://github.com/coconcode/ted2mod/blob/master/extensioncursormoveijkl.monkey2August 17, 2016 at 12:30 pm #3116What i am missing in ted is 2 things.
-Find in files
-A code treeview with class/method/function names.
August 17, 2016 at 9:53 pm #3152I noted these down, thanks for the suggestions.
August 18, 2016 at 6:54 am #3156I’m definitely keen on making ted2 as expanded as possible – this would help keep the ‘core’ mean and clean.
Not sure if an ‘uber’ extension class is necessarily a good idea though, as there could be many ‘kinds’ of extension. One thing that’s definitely going in is a ‘Ted2DocumentType’ class, for example (just experimental!)…
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051Class Ted2DocumentTypeFunction CreateDocument:Ted2Document( path:String )If Not _types Return NullLocal ext:=ExtractExt( path )For Local type:=Eachin _typesFor Local ext2:=Eachin type.ExtensionsIf ext=ext2 Return type.OnCreateDocument( path )NextNextReturn NullEndProtectedMethod New()If Not _types _types=New Stack<Ted2DocumentType>_types.Push( Self )EndProperty Extensions:String[]()Return _extsSetter( exts:String[] )_exts=extsEndMethod OnCreateDocument:Ted2Document( path:String ) VirtualReturn Null 'should return hex editor!EndPrivateGlobal _types:Stack<Ted2DocumentType>Field _exts:String[]EndThen, DocumentManager just calls Ted2DocumentType.Create() instead of it’s current select/case block. Just had a quick hack with an AudioDocumentType class…
Monkey1234567891011121314151617181920Class AudioDocumentType Extends Ted2DocumentTypeProtectedMethod New()Extensions=New String[]( ".wav",".ogg" )EndMethod OnCreateDocument:Ted2Document( path:String ) OverrideReturn New AudioDocument( path )EndPrivateGlobal _instance:=New AudioDocumentTypeEndWith this in place, adding a new document is just a single #import away – which is really one step away from being able to drop in dlls (which I still plan to do eventually).
Ted2DocumentType could also provide the ability for document types to add their own views to the right/bottom tabviews, eg:
Method AddBrowserTab( name:String,view:View ) ‘Add a tab+view to the RHS tabview.
Method AddConsoleTab( name:String,view:View ) ‘Add a tab+view to the BOTTOM tabview.The views passed to these tabs could contain things like editing tools for image apps etc. The IDE would automatically hide/show them as documents became current etc.
There’s also the potential for multiple document types per extension, in which case ‘Open’ would need some kind of ‘Open With’ trickery.
I do think this should be kept separate from stuff like ‘KeyFilter’ extensions though, even if they do work sort of the same. You want ‘DocumentTypes’ and ‘KeyFilters’ in separate lists in the first place, so there’s not much they have in common at all. Perhaps description/version info?
Just brainstorming!
August 18, 2016 at 7:09 am #3157Actually, here’s an interesting approach…
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100Class PluginFunction PluginsOfType<T>:T[]() Where T Extends PluginReturn Plugins<T>.Plugins().ToArray()EndProtectedMethod New()AddPlugin( Self )EndMethod AddPlugin<T>( plugin:T ) Where T Extends PluginPlugins<T>.Plugins().Add( plugin )EndPrivateStruct Plugins<T>Global _plugins:Stack<T>Function Plugins:Stack<T>()If Not _plugins _plugins=New Stack<T>Return _pluginsEndEndEndClass Ted2DocumentType Extends PluginFunction CreateDocument:Ted2Document( path:String )Local ext:=ExtractExt( path ).ToLower()Local types:=Plugin.PluginsOfType<Ted2DocumentType>()For Local type:=Eachin typesFor Local ext2:=Eachin type.ExtensionsIf ext=ext2 Return type.OnCreateDocument( path )NextNextReturn NullEndProtectedMethod New()AddPlugin( Self )EndProperty Extensions:String[]()Return _extsSetter( exts:String[] )_exts=extsEndMethod OnCreateDocument:Ted2Document( path:String ) VirtualReturn Null 'should return hex editor!EndPrivateField _exts:String[]EndClass AudioDocumentType Extends Ted2DocumentTypeProtectedMethod New()AddPlugin( Self )Extensions=New String[]( ".wav",".ogg" )EndMethod OnCreateDocument:Ted2Document( path:String ) OverrideReturn New AudioDocument( path )EndPrivateGlobal _instance:=New AudioDocumentTypeEndAs long as your plugin calls ‘AddPlugin’ in it’s ctor, it will automagically appear in it’s Plugin.PluginsOfType() array!
So to get at all Ted2DocumentType plugins, you call Plugin.PluginsOfType<Ted2DocumentType>(), while to get at *all* plugins you call Plugin.PluginsOfType<Plugin>() (theoretically…).
Definitely has the ‘cute’ factor and I *think* it’s useful…?
August 18, 2016 at 7:10 am #3158Note: I’ve gone for ‘Plugin’ instead of ‘Extension’ because extension still might end up as a keyword, although I suspect not…
August 18, 2016 at 8:18 am #3160OK, just pushed the results of this evenings experiments if you want to have a play.
There’s a TextViewKeyEventFilter plugin class in there too. I just did it as an experiment so feel free to go nuts with it.
I also added a Ted2TextView subclass to call the key event filters, so anything that extends this (only Monkey2TextView right now) will get filtered.
August 18, 2016 at 10:55 am #3163Nice!
August 19, 2016 at 10:25 am #3221OK I noted down the details of the implementation, very impressive indeed. The conversation continues here:
http://monkey2.monkey-x.com/forums/topic/ted2-experimental-plugin-system/
 - 
		AuthorPosts
 
You must be logged in to reply to this topic.