Writing Has Never Been Better
Editing Overhaul
It may not look like much but adding word wrapping was… interesting. Some very early design decisions almost drove me to completely rewriting the editing system but that’s almost always a mistake.
The first time I approached this problem every “fix” created three more bugs and I was chasing them around my source code like roaches.
It became quite apparent that I was taking the wrong approach but through the process it forced me to stop and think about what else I could do.
I needed to find where I could patch in a new interface with as little glue code as necessary.
The Problem
From the start I tied how I store, edit, and render the text all together. It was never smart but it worked because how the text was edited was how it was being rendered was the same.
When wrapping text, I need to add in extra lines without adding the actual newline character generated by pressing “Enter”.
What it comes down to is this: I made assumptions that for every line, there was a newline character.
The Solution
I decided that I needed to split up the data for storing, editing, and rendering. Which is pretty much everything. Everything needed to be updated.
Rewrite time!
No! I will never rewrite my code!
I figured the best way to handle the problem was to not touch the code that already exists. It works, and took me forever to write so lets just plug into a few points so I can extract the data I need and later convert it back to what the program expects.
As luck would have it, I had already done a lot of the work when I added the ability to undo and redo while editing text. All I needed to do was capture the data I pushed onto the stack and apply it to the data being edited.
And just like that I overhauled my data storage.
Since I could (or at least should be able to) trust the data from the undo system I used it to convert back to the format the editing and rendering systems expected.
The Best Part
Unlike my first attempt, where my “fixes” created more and more bugs, this attempt discovered previously hidden or difficult to track down bugs.
While I can’t be certain how long it would have taken, I know it’d take much longer than a week to rewrite the entire editing system.
In one special occasion I noticed a source code commit that resulted in less lines being added than were removed.
Anytime a code base gets smaller an angel gets their wings.
But Wait! There’s More!
Besides the obvious of using a variable width typeface a whole slew of new fixes, tweaks and improvements to the editing system has been committed and a bunch more are in the works.
Since editing is so important to get right, I’m super excited that the whole process has gotten smoother and more straight forward. I know there’s a few cases where I’ll be able to rework and remove the old code and make it even better in time.
I’m even more excited that I was able to do all this without rewriting any code. Rewrites are so expensive to do and it’s so easy to start adding nice-to-haves with the goal of simplifying things that only end up being just as restrictive as the code that was replaced.
Instead, there’s a really good chance I’ll be able to publish a solid update with some neat features soon instead of being delayed at least another month.
Get LINK!
LINK!
Notes on an endless landscape
Status | On hold |
Category | Tool |
Author | hovershrimp |
Tags | Creative, Game Design, Management, Minimalist, planning, productivity |
More posts
- Finding the CoreMay 20, 2022
- Let's Get Wild at the LINK! JAMboreeMar 22, 2022
- Open Sourcing LINK! version 0.8 Alpha 1Jan 30, 2022
- Something Big is HappeningJan 04, 2022
- The Operation Was a Success!Dec 18, 2021
- Lift and Separate, User InputDec 10, 2021
- Refactoring is Better with MetatablesDec 03, 2021
- Images Were a MistakeNov 29, 2021
Leave a comment
Log in with itch.io to leave a comment.