Gordon P. Hemsley

Linguist by day. Web developer by night.

Posts Tagged ‘editor’

Real Tab Support in Bespin, Part 2

Posted by Gordon P. Hemsley on March 21, 2009

A couple of days ago, I blogged about trying to add real tab support into Bespin, and about the discussion going on about where that code should live. However, I can now report that, not only have I been successful in my endeavors (again, if you count my first attempt), I have been able to accomplish it solely within the Cursor Manager. This means that I have gone against what I had originally argued for, and I did it by simply starting over.

My first few attempts helped me get familiar with the code that controls the model, the cursor, and the editor. (MVC, as Ben referred to it. But no, not that MVC.) But attempting to switch between model-awareness and cursor-awareness just cluttered up my code and confused the heck out of me. So I saved everything I had in a little patch file, then reverted all my changes and began anew. (Having Ben first commit some basic cleanup stuff I came across certainly helped to clear things, too.)

So I approached the problem logically, with none of the conceptions from my prior attempts, other than my new-found familiarity with the code. This allowed me to focus on the one task that I had: keep everything in cursor. It also helped prevent me from having dozens of search windows up trying to figure out where things were. And, after a bit of minor confusion about object state persistence and object cloning (thanks, kdangoor!), it was done pretty quickly. But it does require that any position coordinates that are sent to the model be translated via the new getModelPosition().

Since Julian Viereck has been “messing around” with “my” code a lot lately, and since this darn task has taken up a good chunk of my day every day this past week and a half, I decided to put up my own public clone of the Bespin repository on BitBucket to keep things running smoothly. That way I can mess around with things, too, and not get in other people’s way (as much). My code for the tab support is available in this changeset, in addition to this attachment on the bug.

So go merge or import or whatever it is you do in Hg, and give my code a whirl. If you find anything amiss, don’t hesitate to let me know. I would imagine Ben will be critiquing my code at some point soon and then eventually getting it into the main source. Enjoy!

Advertisements

Posted in Mozilla, Open Source | Tagged: , , , , , , , , , , , , , , , , , , , | 1 Comment »

Real Tab Support in Bespin

Posted by Gordon P. Hemsley on March 18, 2009

Over the past week, I have been attempting to add real tab support to Bespin (bug 474055), under the guidance of Ben Galbraith (bgalbraith). Discussion on this issue has ensued in many places, including on Ben’s blog (in which he indirectly called me a weird hippie), as well as in at least two topics on the Google Group/mailing list Bespin Core.

The issue behind supporting real tabs is getting the editor to know that a tab is a variable width character. I was able to solve the problem of calculating just how wide that character is supposed to be, but that turned out to be the easy part. The problem that I’ve/we’ve been having is whether to contain all that knowledge in the cursor code (since it is essentially only a display issue) or to allow it to seep into the model code (which does all the actual text manipulation). That discussion is still ongoing right now, but either way, the change would require a little bit of refactoring of a lot of different functions, so that we can keep track of whether the function is getting the cursor position or the model position (as the latter is really just the nth index in the array, with all characters being equal).

So that’s where I’m at now. I’ve tagged the bug with the “student-project” keyword, since I’m a student and I’m working on the project, and I’ve posted a couple of patches in the bug to track my progress (the first one actually works, for the most part; the second one, not so much). All suggestions welcome.

Posted in Mozilla | Tagged: , , , , , , , , , , , , , , | 1 Comment »