It turns out that using C# was a good decision. I was a bit disappointed with Monodevelop because it appeared to lack debugging support and refactoring, plus it has some issues when encapsulating private fields as properties. The missing debugger turned out to be a missing plugin, which I installed. Still, it feels a bit unfinished (crashes, apparent lockups etc.)
Other than these minor nuisances, the language feels great. API exploration is much easier with autocompletion. Monodevelop's Stetic GUI designer helps a lot with building the GUI without remembering much about Gtk#/Gtk+. It's true it is also buggy (I had to edit its XML file by hand to remove some cruft it added), but it is a timesaver nevertheless.
I did make some progress with the Sexp parser - I am now capable of editing (slowly) little LISP programs. I do need to add keyboard shortcut support (all the 'structured' editing is menu driven right now), probably also through IAbstractEditor so the platform dependent stuff stays isolated.
No regrets over switching to C#. Looking forward to further development of Synpl (I'm thinking that once I get the basic parts right with the Sexp parser, I should add a more sophisticated parser - something like a parser for JavaScript/Pascal/Basic to check the usability of 'structured' editing further).
Monday, June 29, 2009
Sunday, June 14, 2009
Another Twist in the Road
This weekend I thought about using C# for Synpl. This was the original plan when I started working on the "structured editor" variation of Synpl, but I gave up because I didn't want to tie it to Windows.
Since wxWidgets is such a great library, I tried to find a .NET wrapper for it. There is one, but it's not updated since 2007, and it doesn't work out of the box. Maybe the fact that I tried it on 64bit Ubuntu didn't help, but I had to abandon it anyway.
So I tried Mono and Monodevelop and Gtk#. Gtk again. This time, I managed to tweak the GtkTextView and associated classes to do what I want (for instance, raise events similar to Scintilla's Modification event). There were some bugs, but I managed to find some quick workarounds (for instance, the C# Gtk.TextBuffer class doesn't have a CreateTag method :-) ).
I made some very quick progress and I like the result a lot. Besides, working with autocompletion is so much better than trying to figure out things in the plain Python REPL or the Gedit Python REPL. I guess autocompletion in the editor is a very good complement to a REPL sometimes.
So I'm back to Gtk (well, Gtk#, but only the language is different), but not Gedit since there is no Gedit-sharp.
It did feel like "lateral progress", but the development speed is better. And the final product will be faster.
I need to port the Python code to C# ... good thing there isn't so much of it. I wonder if I'll regret switching from Python to C#.
Wednesday, June 3, 2009
Editor components API
Today I managed to finish the tests for the "Text with changes" data structures described in a previous post.
I felt ready to create a basic Gedit plugin - but to my surprise, I found out that the API offered by Gedit doesn't offer a few essential notifications. I want to be able to register a callback with events such as 'buffer changes', regardless of cause (insertions, deletions, cuts, pastes, undos, redos etc.)
It turns out that the concepts used in the Gedit API are described in the PyGTK tutorial, but the event system in Gedit is even weaker than that in the TextView component of GTK (which doesn't offer generic enough 'buffer modification' events either).
I can hook up the keyboard events and handle insertions and deletions, but when it comes to cuts/pastes/undos/redos I have a hard time detecting the events (the user may use non-standard shortcuts) but, most importantly, I cannot isolate the text changes (which characters changed).
After a little more digging, I found out that 1) Scintilla supports a 'buffer modification' event that offers everything I need and 2) wxPython has a portable (GTK+/Win32) wrapper over Scintilla, along with demos with full source code that show how to use the control AND the 'buffer modification' notification/event.
So Synpl changes once again, not so radically this time. It was supposed to become a Gedit plugin, now it seems I'll end up with a standalone editor based on Scintilla and wxPython.
At least I feel like I'm making progress.
I felt ready to create a basic Gedit plugin - but to my surprise, I found out that the API offered by Gedit doesn't offer a few essential notifications. I want to be able to register a callback with events such as 'buffer changes', regardless of cause (insertions, deletions, cuts, pastes, undos, redos etc.)
It turns out that the concepts used in the Gedit API are described in the PyGTK tutorial, but the event system in Gedit is even weaker than that in the TextView component of GTK (which doesn't offer generic enough 'buffer modification' events either).
I can hook up the keyboard events and handle insertions and deletions, but when it comes to cuts/pastes/undos/redos I have a hard time detecting the events (the user may use non-standard shortcuts) but, most importantly, I cannot isolate the text changes (which characters changed).
After a little more digging, I found out that 1) Scintilla supports a 'buffer modification' event that offers everything I need and 2) wxPython has a portable (GTK+/Win32) wrapper over Scintilla, along with demos with full source code that show how to use the control AND the 'buffer modification' notification/event.
So Synpl changes once again, not so radically this time. It was supposed to become a Gedit plugin, now it seems I'll end up with a standalone editor based on Scintilla and wxPython.
At least I feel like I'm making progress.
Subscribe to:
Posts (Atom)