﻿<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text" xml:lang="en">MfGames GtkExt Text Editor CIL</title>
  <link type="application/atom+xml" href="https://d.moonfire.us/tags/mfgames-gtkext-text-editor-cil/atom.xml" rel="self" />
  <link type="text/html" href="https://d.moonfire.us/tags/mfgames-gtkext-text-editor-cil/" rel="alternate" />
  <updated>2026-09-06T17:41:56Z</updated>
  <id>https://d.moonfire.us/tags/mfgames-gtkext-text-editor-cil/</id>
  <author>
    <name>D. Moonfire</name>
  </author>
  <rights>Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International</rights>
  <entry>
    <title>Author Intrusion 0.4.0 "Frederik Pohl"</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2013/10/02/author-intrusion-0-4-0-frederik-pohl/" />
    <updated>2013-10-02T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2013/10/02/author-intrusion-0-4-0-frederik-pohl/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="author-intrusion" scheme="https://d.moonfire.us/tags/" label="Author Intrusion" />
    <category term="mfgames-commands-cil" scheme="https://d.moonfire.us/tags/" label="MfGames Commands CIL" />
    <category term="mfgames-gtkext-text-editor-cil" scheme="https://d.moonfire.us/tags/" label="MfGames GtkExt Text Editor CIL" />
    <content type="html">&lt;p&gt;&lt;a href="/assets/2013/10/author-intrusion-0.4.0.png"&gt;&lt;img src="/assets/author-intrusion-0.4.0-300x232.png" alt="author-intrusion-0.4.0" width="300" height="232" class="alignright size-medium wp-image-3274" /&gt;&lt;/a&gt;It's now time for the fourth release of &lt;a href="http://mfgames.com/author-intrusion"&gt;Author Intrusion&lt;/a&gt;. This is my attempt to have a monthly release of the text editor and, as the previous release, it isn't exactly stable enough to write without a lot of patience.&lt;/p&gt;
&lt;p&gt;It is fairly capable though, but mostly as a pure text editor with spell-checking. I've written a novella and seven short stories since I started developing the project. For a sake of curiosity, I used the associated &lt;a href="https://github.com/dmoonfire/author-intrusion-linux"&gt;Linux tools&lt;/a&gt; to convert my weekly serial (624k words) into the program and navigate around. It's slow to start, but once loaded, it ran rather zippy and I could write almost at my full typing speed in the middle.&lt;/p&gt;
&lt;p&gt;The bulk of the changes are related to technical debt, cleaning up code to make it easier to develop in the long run. Mostly, these changes were to fix things like "select all", or selecting text and then typing.&lt;/p&gt;
&lt;p&gt;As you can tell from the screenshot, I shifted a few things around. These are completely arbitrary changes until I can figure out docking panes. The project pane on the right is not functional at this point, but I needed it on screen to verify that I had a bug; this will also lead into the changes I'm planning on for October.&lt;/p&gt;
&lt;h1&gt;Author Intrusion&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Updated changes to use MfGames.Commands.TextEditing structures. +Changed
&lt;ul&gt;
&lt;li&gt;Changed integer indexes to LinePosition and CharacterPosition.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;MfGames GtkExt Text Editor CIL&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Removed legency references to BufferPosition and the integer-based system for MfGames.Commands.TextEditing LinePosition and CharacterPosition. +Changed&lt;/li&gt;
&lt;li&gt;Various corrections to get Select All, copying, and pasting working properly. +Changed&lt;/li&gt;
&lt;li&gt;Corrections to get the abstract text commands working with end of buffers and lines. +Changed&lt;/li&gt;
&lt;li&gt;Added extension methods to wrap the GetCharacterIndex and GetLineIndex in LineBuffer-specific calls. +Changed&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;MfGames Commands CIL&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Bumped version to MfGames.Commands 0.2.0&lt;/li&gt;
&lt;li&gt;Added the concept of "first" and "last" for text ranges to ensure ordered usage. +New&lt;/li&gt;
&lt;li&gt;Added more logic to the generic text commands to bring it more in line with Microsoft Word. +Changed&lt;/li&gt;
&lt;li&gt;Removed the white space while joining next and previous paragraphs. +Changed&lt;/li&gt;
&lt;li&gt;Renamed properties to give them consistent names across positions and lines. +Changed&lt;/li&gt;
&lt;li&gt;Renamed NormalizeIndex into GetLineIndex and GetCharacterIndex to allow them to be merged at the position and line ranges. +Changed&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Dependencies&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;MfGames.Commands 0.2.0&lt;/li&gt;
&lt;li&gt;MfGames.GtkExt.TextEditor 0.4.0&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
  <entry>
    <title>Technical debt</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2013/09/27/technical-debt/" />
    <updated>2013-09-27T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2013/09/27/technical-debt/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="author-intrusion" scheme="https://d.moonfire.us/tags/" label="Author Intrusion" />
    <category term="mfgames-commands-cil" scheme="https://d.moonfire.us/tags/" label="MfGames Commands CIL" />
    <category term="mfgames-gtkext-text-editor-cil" scheme="https://d.moonfire.us/tags/" label="MfGames GtkExt Text Editor CIL" />
    <content type="html">&lt;p&gt;This week I've been working on &lt;a href="https://github.com/dmoonfire/author-intrusion-cil"&gt;Author Intrusion&lt;/a&gt;. I needed a break from trying to get my novel out and I'm trying to maintain a once a month release schedule for the program, so it was pretty obvious I needed to spend some time on it.&lt;/p&gt;
&lt;p&gt;The wishlist for Author Intrusion is fairly high. The next step is sizable and may actually take more than a month to complete. So, I figured I could get started with the framework and just start chipping away at the large task.&lt;/p&gt;
&lt;p&gt;Before that, I decided to fix some "easy" bugs that were bothering me. The first one was &lt;code&gt;Select All&lt;/code&gt; command caused the system to crash. That shouldn't be too hard to fix, I'm sure its minor.&lt;/p&gt;
&lt;p&gt;Six days later and I'm still not done fixing the mass destruction of that little command.&lt;/p&gt;
&lt;p&gt;&lt;!--more--&gt;&lt;/p&gt;
&lt;h1&gt;The cause&lt;/h1&gt;
&lt;p&gt;When I was trying to get Author Intrusion 0.1.0 out, I made a number of libraries to encapsulate logic. One of them was &lt;a href="https://github.com/dmoonfire/mfgames-commands-cil"&gt;MfGames Commands CIL&lt;/a&gt; which was an abstraction for text editors. Mostly, I know that Author Intrusion will have different front ends and it has its own internal, text-editor-like state. Having a common code base for these things made my life easier, but there were some complexity involved with an abstracted system.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Abstracted systems always increase complexity.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The problem with &lt;code&gt;Select All&lt;/code&gt; came from how to identify a location in the document. In &lt;a href="https://github.com/dmoonfire/mfgames-gtkext-texteditor-cil"&gt;MfGames GtkExt Text Editor&lt;/a&gt;, I had a class-based implementation that used Int32.MaxValue for "end of line" and very little type safety.&lt;/p&gt;
&lt;p&gt;The new commands version took what I learned in two years of writing a text editor and used a struct-based system that had symbolic values for "End" of a line or buffer and "Word" for character. These classes were also immutable (once created, they couldn't be changed).&lt;/p&gt;
&lt;p&gt;Side note: The magic values was the preferred system because I encountered a couple "plus one" problems where I accidently added or subtracted one from MaxValue. With a number that large, I couldn't identify the problems easily. Now, I &lt;a href="https://github.com/dmoonfire/mfgames-commands-cil/blob/master/src/MfGames.Commands.TextEditing/CharacterPosition.cs"&gt;have -113 as the "end of line"&lt;/a&gt; and -1053 as the "word" symbol. This way, I know if there is a plus one problem because both -112 and -114 are always invalid.&lt;/p&gt;
&lt;h1&gt;Make it work&lt;/h1&gt;
&lt;p&gt;This change broke a lot of things when I integrated the two systems together (Author Intrusion and the text editor). Since I was running out of time for an arbitrary release, I wrote some hack layers to translate between the two layers and jammed it into the places that broke.&lt;/p&gt;
&lt;p&gt;In programming terms, this is &lt;em&gt;technical debt&lt;/em&gt;. I was writing crappy code on purpose. True, I didn't know exactly what I was doing (one common reason for debt) but also because I needed something done.&lt;/p&gt;
&lt;p&gt;Sooner or later, I knew I'd have to fix it "properly" but I figured I could do it later once things were working.&lt;/p&gt;
&lt;h1&gt;Compound interest&lt;/h1&gt;
&lt;p&gt;Technical debt, in itself, isn't entirely bad. As I mentioned, when you are fumbling through the code, not everything can be elegant and pretty. The better it is thought out, the less work it takes to maintain, but I believe most programs have to "settle" before they can be cleaned up.&lt;/p&gt;
&lt;p&gt;The nasty part comes when I wrote code on top of the lousy code. Every time I build on it, I'm adding to the effort to clean it up. Do it once, it's just a little bit more. A year of heavy development on a lousy base... almost impossible to fix.&lt;/p&gt;
&lt;h1&gt;Biting the bullet&lt;/h1&gt;
&lt;p&gt;This week is cleaning up some of the worst of that debt. A simple thing, a text position, that is critical to almost every part of the system. I know it needed to be done and I have a much better idea of how to do it (the code is &lt;em&gt;much&lt;/em&gt; simplier now), but still isn't fun.&lt;/p&gt;
&lt;p&gt;And this week was the week to clean it up.&lt;/p&gt;
&lt;h1&gt;No regrets&lt;/h1&gt;
&lt;p&gt;I don't regret writing it in the first place. Sometimes, the software needs to ship because making it "right" will take too long. Other times, there isn't a good answer yet. The important part, more so with this 5-10 year project, is that I keep it mind and fix it before it becomes too integral to the system.&lt;/p&gt;
&lt;p&gt;On the other hand, &lt;code&gt;Select All&lt;/code&gt; works again. Page Up, Page Down, Right Word (but not Left Word), selection operations, Control Home (but not Control End) broke, but at least Select All works. :)&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Yeah, I'll have that fixed by the 1st.&lt;/em&gt;&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>MfGames GtkExt TextEditor v0.2.0</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2013/08/02/mfgames-gtkext-texteditor-v0-2-0/" />
    <updated>2013-08-02T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2013/08/02/mfgames-gtkext-texteditor-v0-2-0/</id>
    <category term="programming" scheme="https://d.moonfire.us/categories/" label="Programming" />
    <category term="mfgames-gtkext-text-editor-cil" scheme="https://d.moonfire.us/tags/" label="MfGames GtkExt Text Editor CIL" />
    <content type="html">&lt;p&gt;Well, it was a minor set of changes over the month, but the text editor needed quite a bit of work. In specific, the problems I had last month with accented characters blew up pretty badly over the month. The novella I was working on happened to have a character with an umlaut, which meant the program crashed every time I navigated through that characters name.&lt;/p&gt;
&lt;p&gt;This ended up being a very interesting problem. I use Pango to both render the lines of text but also to handle navigating. So when the user uses the right arrow, I use Pango# to determine how many pixels to move over.&lt;/p&gt;
&lt;p&gt;Unlike Gtk#, Pango# doesn't deal with character indexes from C#. It appears to give (and require) UTF-8 encoding. So, the third character in a string of "ééééé" (according to C#) is actually character index 6 according to Pango#. This took me a while to figure out, mainly because I would have never guessed UTF-8 encoding, but it seems to work.&lt;/p&gt;
&lt;h1&gt;Unicode&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Reworked how cursor movement and caret rendering took into account with how Pango works with Unicode characters. +Changed&lt;/li&gt;
&lt;li&gt;Better handling of trailing glyph edges while navigating to reduce the jumping of a single character while moving. +Changed&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Releases&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/dmoonfire/mfgames-gtkext-texteditor-cil/releases/tag/v0.2.0"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
  </entry>
</feed>
