in #rlworkbench
Yesterday I spent most of the day working on rlworkbench. Specifically I worked on navigation in the editor. That includes how to move the cursor and how to view different parts of a document.
After being inspired by the Canon Cat I have decided to experiment with making the only cursor movement mechanism be LEAP-like. With LEAP you press a key, and while holding it down, type a search pattern. That will move the cursor to the next match of that pattern. For example, if I want to move the cursor to the beginning of this sentence, I can do <leap-down>For<leap-up>. That will put the cursor on the F. It's kind of like an incremental search but using a quasimode (a mode that is active only while a certain action, like holding down a key, is sustained).
Getting this mechanism to work was a struggle. Not because it is complex, but because I'm doing this in C. C is a new language to me, and also a much lower level language than I'm used to. I find that I can not easily implement the ideas that come to mind because they are at a much higher level and they don't yet translate immediately to the level of C. At times, I felt like a terrible programmer. I felt like I could never get this to work, and that I should probably quit programming altogether because I'm not cut out for the task.
Part of my frustration came from having ideas in my head that I wanted to turn into reality, and that the distance between the ideas and they becoming reality was huge. The distance became even bigger because I have chosen to do this project in C.
That begs the question, is C the right choice? Many things that I do in this project are experiments. I'm not sure if the ideas that I have will turn out to be amazing features. I must experiment and iterate. And that is slowed down by implementing this in C. However, the reason that I do this in C is because previous experiments have shown that I probably need C for this sort of application.
I think that I have to accept that things move slowly while I build up my knowledge of C. Once I have good enough primitives in C, experimenting with new features should not be as hard.
Another trick that I decided to try to overcome the feeling of an immense gap between my ideas and reality was to start using the editor. Then improve on the things that hurt the most and also make sure that those improvements were inline with my big ideas.
So that's what I did today. I wanted to add a section to the README that described some features of rlworkbench. How should I move the cursor to the correct location so that I could start typing? The only mechanism available was LEAP-like. The idea that you type where you want to go. But this didn't work for me now. I wasn't quite sure where I wanted to insert it. My urge was to start scrolling to find the appropriate place. And rlworkbench lacked scrolling.
Actually, I tried to implement scrolling yesterday. And failed. Perhaps mainly because I could not decide if the cursor should always be visible in the screen area or not. I believe that most applications today allow the cursor to be outside the visible screen area. From an editing point of view, I find this confusing. What happens then I press a key to insert a character? It will hopefully be inserted, but I don't know where. But it is also weird to move the cursor as part of a scroll. I decided to move forward by allowing the cursor to be outside the screen.
I think that scrolling is probably a useful feature. But it might be useful to also try to forget current patterns and think about more efficient ways of getting to where you want to go. One such way might be navigating between headers. The README has headers. Instead of scrolling through the whole document, I can move between headers. I can do that with the LEAP-like navigation by moving to a pattern that matches # at the beginning of a line. It will be sort of like reviewing table of contents and deciding where to insert the new section.
Speaking of table of contents. Another idea for the LEAP-like navigation, or type where you want to go, is to introduce a syntax that says "search for pattern in this part". What if we wrote the pattern "h in TOC" or something to that extent. That could open a TOC document that could then be searched.
Scrolling will still be useful though. For example, if a section is really large, how to get to the middle using table of contents? Not possible. So we could go to the beginning of the section via the table of contents and then scroll a few pages to get to the middle. Once we see on screen where we want to go, we can move there quickly with the LEAP-like navigation.
I will end this note here and move on to actually editing the README. I just need one more addition to the LEAP-like navigation so that I can get to where I want to make the edit.
What is Rickard working on and thinking about right now?
Every month I write a newsletter about just that. You will get updates about my current projects and thoughts about programming, and also get a chance to hit reply and interact with me. Subscribe to it below.