💾 Archived View for zaibatsu.circumlunar.space › ~krixano › phlog › 112118_EdimCodersImprovementsOve… captured on 2020-09-24 at 01:57:11.
⬅️ Previous capture (2020-09-24)
-=-=-=-=-=-=-
------------------------------------------------------------ EdimCoder's Improvements Over Ed ------------------------------------------------------------ While EdimCoder takes a lot of inspiration from Ed, it also makes several improvements over Ed. Before we move onto detailing a new type of editor that was used in the past, I've decided to go over these improvements. Prompts and Colors One Improvement made over Ed is that EdimCoder utilizes prompts and colors to distinguish file text from the editor's user interface. Additionally, prompts give useful information and are especially helpful to new users. I made the choice to include both colors and prompts for the reasons above, but also because EdimCoder no longer needs to be restricted by the hardware that was used when Ed was created/used (namely, teletypes). Because screens can display characters much quicker now than in the past, showing prompts and colors should no longer be a bother considering speed. The SubEditor Many command-based editors have a SubEditor. This is the line editor that you use to type in a command or a line. Therefore, subeditors work similarly to how readline and linenoise work. Previously we discussed how EdimCoder created it's own alternative to readline that is portable across Windows, Linux, and perhaps in the future, others. This readline alternative is the SubEditor. It provides the means of editing the command line or the line you are currently typing to insert, append, prepend, or replace in the file. EdimCoder made several improvements to it's subeditor over Ed. These include the ability to move the cursor left/right so it's positioned in the middle of the text of the current line, and the ability to add text in the middle/beginning of the line where the cursor is currently positioned. Additionally, the Home, End, and Delete keys also work. And finally, the Tab key always inserts a tab character, but will display as 4 spaces instead of a tab so that the tab stops of the terminal aren't used. Context One of the problems I considered while creating EdimCoder was how someone could make sure they have the context of what they are writing in mind. This means you should have a good idea of where you are currently doing an operation, making sure you are doing the *right* operation, and where in the file the operation is happening. Therefore, I have came up with a few different features that help you get an idea of all of these things. Firstly, the simplest is always showing the current line number you are on while doing an operation and showing the current line number in the command prompt. Additionally, there is a 1 character gutter that shows the current operation you are applying to the line number you are currently on. This character is often the same as the command you used. I have provided the different characters that may be shown below: a - for inserting lines after a line A - for inserting chars at beginning of line i - for inserting lines before a line I - for inserting chars at end of line x - for deleting line ^ - the line *was* moved up - meaning it was previously in a position lower than it currently is. V - the line *was* moved down - meaning it was previously in a position lower than what it currently is. r - the line is being replaced R - a given subset of the line is being replaced (replacing chars with chars) Whenever you are inserting, deleting, or moving lines, ^ and V are used to show the effects those commands have on the other lines of the file. In most instances only the first moved line is shown. For example, inserting one line before another will show that the line being inserted before was moved down one line number to accommodate for the insertion. Therefore, 'V' will be shown in the gutter of that line after you are done with the insertion operation. The next feature is a very simple one. EdimCoder will display the line before and the line after the line(s) you are currently operating on to give more context on where in the file the operation is happening. The final feature is incomplete and only works for *few* files because it is programming-language aware. The feature is the ability to show an outline of the file (using the 'info' command). This outline currently works with C, C/C++ Headers, and Markdown files. This provides more context as well as, in the future, the ability to more easily jump to these locations and do operations *on* these "objects" (for example, doing an operation on a function or section). Bookmarks This is a recent addition. EdimCoder has the ability to store line numbers and line ranges in bookmarks (which are basically like variables). Then, you can use these bookmarks in any of the operations. Here's an example of creating a bookmark, then using it in the Print operation: d 5:25 fGetInput P #fGetInput This will set lines 5 through 25 to the 'fGetInput' bookmark. Then, when passed into the Print operation, it will print out lines 5 through 25. In the future, different types of bookmarks will be provided. More on this in a future post. Command Modes EdimCoder also has different modes - currently 3 modes (but more in the future). Ed can be thought of as having 2 modes, command and input. EdimCoder has the same modes, plus an additional one: the preview mode. The preview mode acts similar to 'pg' (or less but being less screen-oriented) and accepts commands that tell it whether you want to view the previous or next page. EdimCoder will be getting at least one additional mode in the future. More on this in a future post. Canceling Current Operation EdimCoder lets you cancel the current operation by pressing Ctrl-X. This will revert back to what the text was before the operation ever happened. Buffers EdimCoder has one more improvement over Ed - this one I consider to be a big improvement. EdimCoder has the ability to open multiple files/buffers and easily switch between them. The current line, outline, and other information is kept per-buffer. Continually Improving While EdimCoder currently offers many advantages and improvements over Ed, it is continually improving. There are various other ideas that will be implemented in the future (hints: input suspension, outline bookmarks, relative lines, relative and static bookmarks, default bookmarks, ...). Thanks for reading this post. Hopefully I will have the next post out soon, which will talk about a different type of editor used in the past and how it's ideas can be used in EdimCoder.