💾 Archived View for zaibatsu.circumlunar.space › ~krixano › phlog › 111518_EdsInfluenceOnEdimCoder.t… captured on 2020-09-24 at 01:35:29.
-=-=-=-=-=-=-
------------------------------------------------------------ Ed's Influence on EdimCoder ------------------------------------------------------------ Both Ed and Vim have a great influence on how I decided to have EdimCoder behave. Below I describe the various ways in which EdimCoder was influenced by both Ed and Vim (admittedly, Vim not as much as Ed). Line Editor Probably the *most* apparent influence is the fact that both EdimCoder and Ed are line editors. I haven't exactly explained what a line editor really is previously, or why it's important to the history of text editors and computers. A line editor's primary way of manipulating text is through lines (hence it's name). This means a line editor moves lines, deletes lines, replaces lines, duplicates lines, etc. Another important factor is that the "cursor" is only positioned at a line, it doesn't take into account what column the cursor is on. Line editors like Ed and Ex were command line interfaces (like REPL's) where you type in a command and the program will take the action on the text file determined by the command. Therefore, you can type in a command like this in Ed: > g/re/p And that will take an action on the file (as represented by the command). What this specific action does is actually where the name "grep" comes from... this command searches globally (find's every instance of) the specified pattern (a regex in between the slashes, in this case "re") and prints all of the lines that have that pattern in it - this is what the grep program does. One major reason why text editors like Ed and Ex used a REPL-like (or cli-like) experience was because they were used on teletypes - computers that used a typewriter as their display. With typewriters, things are printed out to paper, so there's no way to erase characters and there's no way to move a cursor freely and modify what's already printed to paper. However, once screens were being used, screen line editors came into existence (maybe I'll write more about this in another phlog post). The Commands Of course, if Edim is related to Ed in that they are both line editors, then they would probably use the same or similar commands - and this is true. While Edim isn't nearly as feature rich as Ed quite yet, Edim takes many commands from Vim and Ed, along with the names/characters they use. In both Ed and Edim, "i" is used to insert a line or lines before a specified line. "a" is used to insert after. As Vim is a descendant of Ed, Vim behaves in a similar fasion (although, not exactly the same). While Ed and EdimCoder share a lot of commands, they also share a similar, but not quite the same, syntax. Commands are usually represented by one character. In Ed, commands work on the current line. This also holds true for EdimCoder. However, EdimCoder allows you to also specify a line # to run the command on. For example, I can write "i" to insert before current line, or "i5" to insert before line 5. But, these are where the similarities between the two stop when it comes to command syntax. The Internal Data Structure for the Buffer Another influence of Ed on EdimCoder is the data structure used to store the text in memory. This has been discussed in a previous phlog post. Ed, Vim, and EdimCoder all store the text in memory as a dynamic array (or vector for C++ people) of strings. This is different from other text editors that may use Gap Buffers (Emacs), Ropes (VSCode), or Piece Tables (Word). Readline's Influence Readline can be considered a line editor, but it's a different type. Readline is what's used by default on Linux (as far as I'm aware) when a terminal program asks for input, including your shell. It lets you type in one line (hence the name line editor). It also allows you to move the cursor left and right and input text in the middle or beginning of text you've already typed. It also provides other features like history (pressing the up and down arrows). Because we are no longer on teletypes, Edim utilizes functionality that is similar to this. Edim implements it's own readline alternative for this (as written about in the previous phlog post). This allows for better portability (it works on Windows!) and the easier addition of functionality in the future. While this is not like Ed, this does provide similar functionality to Vim and is a much needed improvement over Ed's functionality. Thanks for reading this phlog post! I'm going to be writing another one very soon that will talk about a different type of editor's eventual influence on EdimCoder.