﻿<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="text" xml:lang="en">MfGames Commands CIL</title>
  <link type="application/atom+xml" href="https://d.moonfire.us/tags/mfgames-commands-cil/atom.xml" rel="self" />
  <link type="text/html" href="https://d.moonfire.us/tags/mfgames-commands-cil/" rel="alternate" />
  <updated>2026-05-12T17:42:15Z</updated>
  <id>https://d.moonfire.us/tags/mfgames-commands-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>A pile of packages</title>
    <link rel="alternate" href="https://d.moonfire.us/blog/2013/07/03/pile-of-package/" />
    <updated>2013-07-03T05:00:00Z</updated>
    <id>https://d.moonfire.us/blog/2013/07/03/pile-of-package/</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="gtk-sharp" scheme="https://d.moonfire.us/tags/" label="Gtk#" />
    <category term="mfgames-cil" scheme="https://d.moonfire.us/tags/" label="MfGames CIL" />
    <category term="mfgames-commands-cil" scheme="https://d.moonfire.us/tags/" label="MfGames Commands CIL" />
    <category term="mfgames-languages-cil" scheme="https://d.moonfire.us/tags/" label="MfGames Languages CIL" />
    <category term="mfgames-gtkext-cil" scheme="https://d.moonfire.us/tags/" label="MfGames.GtkExt CIL" />
    <content type="html">&lt;p&gt;In the process of cleaning up and getting &lt;a href="http://mfgames.com/author-intrusion/"&gt;Author Intrusion&lt;/a&gt; ready for release, I ended up making quite a few distinct libraries and projects. These are very small, focused assemblies, but I think they have the potential of being useful in themselves.&lt;/p&gt;
&lt;p&gt;&lt;!--more--&gt;&lt;/p&gt;
&lt;h1&gt;Philosophy&lt;/h1&gt;
&lt;p&gt;My influential development came from the Unix world. I like things that "do one thing" that are designed to be chained with other things. In effect, most programs are just a composite of lots of different little things.&lt;/p&gt;
&lt;p&gt;These packages follow much of the same philosophy. While I &lt;em&gt;could&lt;/em&gt; write them as part of Author Intrusion, there were advantages of separating them. The biggest is reuse. A good example is the &lt;em&gt;MfGames CIL&lt;/em&gt; project. It has lots of little C# utilities that I've used in a dozen programs over the years.&lt;/p&gt;
&lt;h1&gt;Drawbacks&lt;/h1&gt;
&lt;p&gt;There are some major drawback of working with separate packages. While I tried to follow the &lt;a href="http://en.wikipedia.org/wiki/Package_Principles"&gt;Stable Dependencies Principle&lt;/a&gt;, the fact is that almost all of this is greenfield development and therefore unstable. Near the end of last week, it got really annoying when I had a bug in one code that required me to cascade the change through five different packages. Fortunately, PowerShell is very useful for handling all these things and I got a pretty solid workflow when it came to those final packages.&lt;/p&gt;
&lt;p&gt;The other is overhead. Projects require overhead. Not just a website on my site or a reposotiroy in GitHub, but (if done right), documentation, examples, and unit tests. What could be a bullet point in one program (implemented a command pattern) becomes something major when it is a command pattern library.&lt;/p&gt;
&lt;h1&gt;Projects&lt;/h1&gt;
&lt;p&gt;These are the projects I worked with or created in the process. I'm using the GitHub links for these, mainly because those pages have more information than the ones on Moonfire Games (documentation takes time).&lt;/p&gt;
&lt;h2&gt;&lt;a href="https://github.com/dmoonfire/mfgames-cil/"&gt;MfGames CIL&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Over the years, I've had a little "catch all" library for the things I happen to write. I released about ten years ago, but mostly had local development since.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Settings management class to handle keeping track of settings for the various plugins, window positions, and everything else.&lt;/li&gt;
&lt;li&gt;A hierarchical path classes. I arrange a lot like a directory tree so I wrote a common framework for working with them. So, the window settings are stored underneath "/GUI/Gtk/Windows/Main Window" where plugin settings are "/Plugins/NHunspell".&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This package was bumped to version 4.0.1.0 in the process of getting Author Intrusion out. The rest of the packages are version 0.1.0.0 since they are very unstable.&lt;/p&gt;
&lt;h2&gt;&lt;a href="https://github.com/dmoonfire/mfgames-languages-cil/"&gt;MfGames Languages CIL&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is actually a new package and created at the last minute. While .NET has a lot of functions for working with languages in general, there are some limitations when it comes to switching locale. More importantly, I'm going to want a system that handles constructed languages (conlangs) which the built-in locale system can't really handle.&lt;/p&gt;
&lt;p&gt;I'm not entirely sure if this will be that useful, but my gut feeling is that it will be needed. Eventually, I plan on including a lot more in there including name generators and word identification.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A rough word tokenizer. I'm using this to handle control-arrow movements, deleting and selecting by word. Eventually, the undo/redo will use it so if you type "word" and undo it will undo the entire word instead of just the "d".&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;&lt;a href="https://github.com/dmoonfire/mfgames-commands-cil/"&gt;MfGames Commands CIL&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is actually week four of this release. A command pattern basically is a way of handling interactions with the user. Instead of inserting a "w" in a buffer and handling the results, I create an object that says to insert "w". The main reason is that my code becomes more separated in logic (the command object handles inserting "w") but also simplifies code for undoing and redoing.&lt;/p&gt;
&lt;p&gt;Eventually, this will also let me serialize the undo/redo so I can save, quit the program, come back, and still be able to undo where I left off.&lt;/p&gt;
&lt;p&gt;The problem was that both the text editor and Author Intrusion both had command patterns, but they were incompatible with each other. Creating a library meant that I could reuse the logic (a good thing) and just handle the differences.&lt;/p&gt;
&lt;p&gt;I also made a text editing project out of this that takes a core set of commands and wraps them in composite commands. It sounds complicated, but take pressing return in the middle of a paragraph. Instead of having a split paragraph command, it is really a combination of:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Insert a new line below.&lt;/li&gt;
&lt;li&gt;Copy the text to the right of the cursor into the new line.&lt;/li&gt;
&lt;li&gt;Delete the text to the right of the cursor from the first line.&lt;/li&gt;
&lt;li&gt;Position the cursor at the beginning of the new line.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It works out better than I describe it, but mainly I can do a lot with just six core functions. And that makes it easier to implement than every possible keyboard input or action a user could do.&lt;/p&gt;
&lt;h2&gt;&lt;a href="https://github.com/dmoonfire/mfgames-gtkext-cil/"&gt;MfGames GtkExt CIL&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The last project was Gtk# extension for things I use while developing. While Gtk# isn't as pretty as WPF or most Windows, it has something I like: cross-platform support. It also doesn't have as rich of a widget set of most toolkits, so I gathered it here.&lt;/p&gt;
&lt;p&gt;The biggest part is the text editor. I created a text editing widget that doesn't work on a single text buffer (like most editors do). So, the entire novel isn't in a single string. Instead, it is managed line by line. This means I don't have to have an entire 600k word serial in memory at the same time, which is a good thing.&lt;/p&gt;
&lt;p&gt;I expect to see a lot of churn in this last project for a few years.&lt;/p&gt;
</content>
  </entry>
</feed>
