September 2, 2016 at 11:13 am #3610
Let me introduce my version of ted2 – Ted2Go.
(based on original v1.0.4 sources)
I am at the beginning of way, but I done some things and want to share and discuss with you.
The Main idea is in using the only Ted2CodeTextView class for all documents with code.
I already made this class.
How it works?
Class CodeTextView contains components: Keywords, Highlighter and CodeFormatter, which allow us to customize text view. These componets based on Plugin system and assigned automatically according to opened file type.
For this purposes I extend Plugin class to PluginDependsOnFileType – this kind of plugins are stored info about file type (file extension) and method CheckFileTypeSuitability, that do checking. So we can use this method to check – is this plugin designed for our file or not.
I created 3 base plugin classes: KeywordsPlugin, HighlighterPlugin and CodeFormatterPlugin. By extending these classes you can add you own Keywords, Highlighter and CodeFormatter for any language! Easily, not need to change other parts of code. 🙂
Now, I am thinking about auto-registering code-filetypes – to eliminate the need to specify extensions.
That is, when we add new instance of KeywordPlugin – we’ll automatically got registration of this-plugin-specific-filetypes as part of CodeDocument and such filetypes will be opened as code files.
The main thing here – automatically.
[ Inheritance: Ted2CodeTextView < CodeTextView < TextViewExt < TextView (mojox) ]
What I done:
TextViewExt – extended version of mojox.TextView, contains basic key and mouse processing inherent to all textual documents. also has a flashing cursor. (can be included in mojox)
CodeTextView – extended version of TextViewExt, contains basic key processing inherent to all code documents; also contains CodeFormatter, Keywords and Highlighter components.
ConsoleExt – extended version of mojox.Console, allow to copy selected text and select whole line by mouse double click.
Monkey2CodeFormatter – plugin for monkey2 files, now it can only capitalize keywords.
Monkey2Highlighter – highligher from original ted2.
Monkey2Keywords – load keywords from json or hardcoded.
CppKeywords – test plugin for c++ keywords
CppHighlighter – also test plugin, is equivalent to Monkey2.
Monkey2KeyEventFilter – key filter for .monkey2 files, for example, it catch F1 to show help.
PS. sorry for my english, it’s not my primary lang.September 6, 2016 at 3:04 pm #3705
Wow, basically you can make Ted a multi language editor that way, clever mod.September 6, 2016 at 3:31 pm #3707
I think – it’s good idea to continue develop inside of monkey2-fork (not separated ted2) to make merge from official easily.
And maybe Mark pull some of changes.:)September 8, 2016 at 2:35 am #3754
Hi. Here is an easy way to cancel progress dialogs.
In this case – for cancel building dialog.123456App.KeyEventFilter += Lambda(event:KeyEvent)If event.Type = EventType.KeyDown And event.Key = Key.Escape_console.Terminate()event.Eat()EndifEnd
Just add this code into buildactions.mx2 / BuildActions class / BuildMx2 method.September 8, 2016 at 11:09 am #3764
I just pushed new stuff – base auto completion support! 🙂
Now it shows keywords only, but easy to extend.
Next step 1 – write simple monkey2-parser, so we get smart completion.
Next step 2 – write code analyzer to check current scope and all variables (global, local, params), so we get pro-level ide 🙂
And between these steps – add CodeTreeView and Navigation panels (each cool ide must have).
Windows version of ted2go (dropbox)
Issue: cursor became invisible after some time. (Timer became broken? but why)September 11, 2016 at 7:31 am #3859
New stuff in my repo – code parser for monkey2 files.
Parser is simple yet. What it can:
- Parse the first word after these keywords: “class”,”struct”,”enum”,”global”,”const”,”method”,”function”,”property”
- Parse recursively if file contains #import
- Check file last modified time before paring – to skip not modified files.
And all words from parser we can see in autocomplete list.
- Improve parser – so it can know about scopes and all variable types (field, local, params, lambda – gradually)
- Check current scope for autocomplete
- Merge with latest monkey2 repo changes.
Even now, writing code has become much easier! 🙂
Attachments:September 11, 2016 at 10:32 am #3863
Wow, so many things in so few time!
I’m still trying to understand MX2 !!!
Just a quick question1App.KeyEventFilter += Lambda(event:KeyEvent)
What does exactly mean += in this case?
It means ‘Add a NEW event filter to (list/stack/map) etc? And of course ‘attach’ the code in the labmda() section.’
I saw the same syntax in the module source, but it’s no so clear (to me).September 11, 2016 at 10:44 am #3865
What does exactly mean += in this case?
This mean ‘subscribe’ to KeyEventFilter function inside of App.
This Lambda is a listener.
So all listeners subscribed to KeyEventFilter (via += operator) will be called when App begin processing keyboard event.
This call is usual function call, in our case: KeyEventFilter(event)
If there is no one listener subscribed to then nothing happen.September 11, 2016 at 11:27 am #3870
a little more clear!September 11, 2016 at 11:33 am #3871
BTW, just compiled your TED2Go… nice implementation of autocomplete! Very handy (and fast compiling!)
More to learn (for me!)September 11, 2016 at 11:49 am #3872
Nice to hear you! 🙂
and fast compiling
Because there is just a bit of code. Ted2 is small app 🙂
But ‘clean’ compiling (no cached files yet) makes me wait.September 12, 2016 at 5:48 am #3889
Useful git command for all fork-men:1git subtree split -P src/ted2 -b ted2only
Separate all-and-only ted2 changes into custom branch.
Then we can easily merge with our fork – pull from branch ted2only into fork repo (if repo contains ted2 stuff only, not all monkey2).September 20, 2016 at 11:01 am #4036
question which version of monkey2 do I need to compile?
V1.02 and v1.04 just give loads of errors.
I’m very interested in how you implemented the autocompleteSeptember 20, 2016 at 11:14 am #4037
I’m using the latest version (1.0.6).
But my code is dirty now; I clean up it when complete common features (like checking current scope and getting variable types in := expression.
Now I’m using ‘dev’ branch for undone things.September 21, 2016 at 4:34 pm #4049
Working on code parser I just added simple CodeTreeView navigator – I need it to see parsing result.
There are idents only in the tree, that’s enough for the moment.
All variables started with Local, Field and so on is presented here, even if they are deep inside of For, If, etc. Will be fixed later.
CodeTreeView filled on document open, don’t adjust changes yet.
Click on item – jump to line with it.
You must be logged in to reply to this topic.