Diamond text editor now has many new features, including backups. Here is a run-down.
Yeah, it’s been a while. Life keeps getting in the way of actually writing something here. I’m also migrating from BlueHost.com through HostGator.com to inMotion hosting service. That gets its own blog post once complete. Despite all of that, a lot of code has changed in the repo. Just be sure you choose the diamond-themes branch.
Themes work really well. Not perfect, but really well. Perfect would be instant coloring. I can seemingly get that to happen even with large source files if the syntax is set on a tab before the file is loaded. It appears the QPlainTextEdit class is smart enough to only paint the visible rows first. The problem is I haven’t unwound the MainWindow class object creation far enough to stop a segment fault crash with autoload enabled. If I set the syntax before setting the document in the tab during program load there is some “resource not yet available” segment fault death that happens. I’ve sped things up as fast as I can for right now without causing that problem.
So, let’s review my original ideas:
- Themes
- A decent default font
- EDT numeric keypad emulation
- Compiling
- COBOL syntax
The first three are basically done. Part of me wants to add custom background and foreground colors for selected text; but living with default white text on blue background for now.
You can import/export and even change color themes. There are even an acceptable number of “default” themes built in.
Sorry I had to use my phone for that shot. Have I mentioned the screen shot utility built into Ubuntu 20.04 LTS completely sucks? Eventually someone will set up a site where all of you dear people can upload your personal favorite themes along with screen shots. It should encourage wider use of the editor. Everyone wants their own personal theme.
Do you think I spent all of this time just sitting here going “oooh look at the colors?” Silly Wabbit!
As part of improving overall performance, Overlord now holds all of the syntax highlighting. You have the option of preloading your favorite. Whenever an editor needs a syntax it asks Overlord for it. We only bite the bullet loading the JSON once.
There are three new check boxes on the right. One for enabling EDT. Another for Astyle on Save and finally one for to enabled backup versions. You will notice I have a field to enter the Maximum number of backup versions to keep and allow you to choose a directory other than the default for said backups.
I’ve used a lot of editors over the years. Far too many editors on wanna-be-a-real-computer-some-day x86 based platforms just create one backup with a ~ or # or something like that at the end of the name in the exact same directory as the original file. This “one” backup tends to be created either the moment you open the file for editing or just in front of your last save. If you are a save-early-save-often type developer these backups are Fahrvergnugen useless. Adding insult to injury, on any brand new project you always end up with half a dozen of these files getting into your source control until someone takes the time to both delete them from source control and create an ignore file.
Backups and file versioning
I come from an OpenVMS background. FILES-11 Records Management System had file versioning built in. Every time you saved a file it created a new version. You could have versions from 1-32767. You could PURGE all older versions and rename the current version back to 1 to start the numbering process all over again. In short, on a real platform, it is very difficult to “lose” something. We had this long before we had source control systems. When you combine file versioning with source control, it takes a very deliberate and stupid thing to “lose” a file.
We didn’t have to create utilities to manage these versions either. The PURGE command had a /KEEP=nn qualifier. If you only wanted the last 6 versions of any file on a backup tape, you just purged down the entire drive with /KEEP=6 before running the backup.
Some PC based editors try to implement the central backup directory. There are varying levels of success with it. I like what Emacs did with their backups. They mungify the full path and stick a version on the end. This keeps main.cpp from Project A from pushing main.cpp from Project B backups off the end of your keep chain. I kinda ripped that off but changed it a bit.
When you have a file open in the current tab you can choose View->Backups and
Yeah, the names don’t all appear the same here because I was doing battle with just how to do this. Eventually those will purge off or I will just recreate the directory.
Backups became very important to me while I was working on the Astyle interface. Let’s just say there were a few zero length styles that wiped out my buffer and the file on disk which of course hadn’t been checked into Git for hours. When you open a backup file you should note the tiny change to the status line.
Ordinary files will have Write listed where ReadOnly is.
There is one issue I haven’t decided about fixing. There is code in Diamond to always set a last directory value based on the file you just opened. When you open a backup file that gets set to your backup directory. I haven’t decided if it is worth blocking that in the code or not. I found it annoying when getting all of this working. Now that it is working I have to wonder just how many times one will open a backup file and shouldn’t I make it a wee bit painful? You are opening the backup because you did something stupid. Shouldn’t there be a bit of a price to re-enforce you learning not to do that again?
I cannot make this work the way I want without making changes to QKeySequence and then creating CsPlainTextEdit from the QPlainTextEdit source code and getting that accepted into the project. It is too big of a chunk for right now. I’m not proud of the code I had to write to get EDT functionality into this editor, but it does make a quite usable editor. It’s not perfect. There are a few minor issues.
You will note I had to put a radio button box for Delete Word. The built in help text tied to the HELP key on the keypad kind of explains this. QKeySequence really only deals with strings. Ctrl+, Alt+, DEL is a different key sequence than Alt+, Ctrl+, DEL. QKeyEvent deals with a binary modifier block and a binary key value. With QKeySequence order is important but QKeyEvent simply doesn’t care. I have to fix that little piece before rewriting plain text edit so it can support editor states. Putting it bluntly, those of you with a “proper” keyboard won’t be able to use this right now.
Honestly, even if I did have this set up for you to enter a key sequence, I don’t think Qt has mapping values for a proper keypad. I know you can make it work in Emacs if you mod the terminal. Modifying the terminal definition is against my religion though. I just used the Scroll Lock and cussed about it every time I hit the wrong key. Until I had to log back into a proper computer and edit source code I had almost adapted. All it took was about twenty minutes on there and two decades of muscle memory returned. I was completely useless in Emacs because I kept hitting NumLock for GOLD. That’s pretty much why you are getting this editor. My level of pain got too high.
All of those non-standard GOLD key functions on the right must be tied to a single keystroke sans any modifiers. I really liked GOLD = for goto line in Emacs so I ripped that off. You will notice the last one is GOLD A for Astyling a buffer.
All of this functionality is checked in if you wish to pull the branch down and build it to try things out for yourself. I’m currently working at adding a Debian build procedure to the source base so I can install this on multiple machines without having to local build Copperspice followed by Diamond.
Hopefully I will have the energy to document my attempts at getting Copperspice to build on OpenSuSE Leap 15.2. So far it has not gone well. Of the RPM based distros, OpenSuSE is the one I find least offensive so that is the one I use when I have to use an RPM.
Oh! You probably noticed the Clipboard option. I needed a method of validating the EDT “append to paste buffer” functionality so the clipboard viewer got added.
There is no GOLD-7 [command] implementation in this. Yes, back in the day I used it a lot. Some of the functions could be useful today, but I had to draw the line somewhere. The GOLD-ENTER [subs] function isn’t implemented either. When you hit it you see the advanced search and replace dialog. Honestly, I had to look up what that key combination actually did. I had never used it in all my years on EDT. It was always soooo much easier to hit GOLD-7 and type
SUBST!OLD-STRING!NEW-STRING!QUERY
With the SUBSTITUTE command I also had the options of REST, WHOLE, SEL instead of QUERY. If I was ever going to implement the command window it would be to bring in this functionality, but I have more important priorities right now.
As long as I’m talking about “not done” I should mention FILL isn’t done. I have no plans. I remember using it pre-wordwrap days typing up documentation. This editor has word wrap and spell check. I realize the critical difference was FILL was a hard wrap. A newline character was physically placed at the end of each line. This was for various things like printers and Usenet newsgroups with fixed column limits. If someone really needs that today I guess they can join the project and add it in.
My personal view is that creating a Debian of the current functionality is more important than any additional features at this point. I dabbled with OpenSuSE contemplating an RPM as well. I’ve always managed to duck out of RPM creation, not so much when it comes to DEB creation. When you only do it once every few years it always takes a while to get back into.
I don’t enjoy doing it. Well, that’s not actually true. I always get asked to do the convoluted sh*t.
We need to create a package that is going to create a user account and install all of this in to run like a Kiosk. It will also include a tool to completely remove the installation.
Typical client request
I’ve never created a need to know nothing straight forward hard coded install directory tree DEB. This is completely uncharted territory for me. I may actually have completely empty pre and post install files.