Texts- a WYSIWG editor for lovers of plain text
Sunday December 8, 2013 22:30:09


Yesterday I discovered the regretably named Texts, a WYSIWYG text editor that saves to plain text files in the Markdown formatting syntax, which is also used by innumerable sites including Github and StackOverflow.

I once used Microsoft Word for anything that wasn't program code, but as time went on I found myself on machines without Word installed. Buying Word was never worth it to me, yet alternatives such as OpenOffice felt too clumsy to be enjoyable. At some point I decided I'd be able to live using plain text files alone, particularly after I discovered Restructured Text, the primary format syntax used by Python's standard documentation tools. The cool thing about RST files was that they stayed simple text files which could be editted easily in Sublime Text and could live comfortably next to my code and in Github repositories.

However, something always felt off about using Sublime Text to write scripts or stories, probably thanks to the monospaced fonts used for viewing code. While I spent the first five years of my computer enabled life writing stories in Word Perfect and other old school word processors which had nothing but monospaced fonts, at some point using them for creative writing began to feel unnatural. My theory is that as years went by and variable width fonts became more prevelant, my brain began to recognize monospaced fonts as used for reading and writing code only, which caused them to stifle the writing process. While it's possible to use variable width fonts for Sublime Text I couldn't find an easy way to change it on a per file extension basis, meaning I'd have to change it globally and thus ruin the tool's ability to edit code.

The Texts editor on the other hand allows me to write documents with formatting options such as headers and bold text visible, which makes the experience almost as enjoyable as it was on Word. It has the added advantage of saving the files to a format that's friendly to all the programmer tools I already use, such as Git, DiffMerge or Sublime Text. It even supports saving documents in multiple types of Markdown, such as the flavor used by Github.

The only real disadvantage is it supports Markdown instead of Restructured Text- there's a lot of Python documentation that would've been really nice to edit with Texts. Markdown also is a less standardized format than its chief rival. Additionally, Texts is currently a bit rough around the edges- I can't find figure out how to activate the spell checker or exit from full screen mode. However, as its the only real tool I've ever found to scratch this particular itch I still recommend it to anyone who wants the nicities of a WYSIWYG editor but is loathe to give up the independence offered by plain text files.



Syntax highlighting for Boost Build / Bjam in Sublime Text
Saturday December 7, 2013 20:06:00

I was opening a Bjam file today and found myself thinking about how intimidating the language looks to most newcomers, until the basics of the syntax are understood. I also thought of what a drag it is to open a bjam file and see monochrome.

So, I used some of the knowledge I gained earlier when I added syntax support for Macaroni to Sublime Text and whipped up a fresh tmLanguage file which colorizes Boost Build files. Thanks to Sublime Text's easy and intuitive nature as well as several helpful tutorials it only took a few hours.

Of course, it isn't perfect- it falls apart on truly complex jam files- but it's better than nothing.

Click here to view the Github project.



Add color to Boost Build with BJolt
Wednesday November 27, 2013 15:58:25

I recently added CMake support to Macaroni after growing incredibly frustrated with how long it took to compile some apps with Boost Build on my ancient Acer Aspire One. Because CMake can generate Visual Studio project files, this meant I was able to easily work on Macaroni projects again in Visual Studio.

Unfortunately, Visual Studio 2013 seems to have be more hostile towards Macaroni than its 2008 iteration; syntax is still correctly highlighted, but the IDE adds scribbles to almost everything. Worst of all, it refuses to jump to errors in Macaroni source code when you click on them in the IDE even though it's own compiler is outputting the appropriate lines. I actually used to use VS2008 with Macaroni all the time several years ago and had a good experience, so VS2013's intolerance for mcpp files (possibly arising from the fact it's improved as a C++ IDE) is a bit sad. The end result is I stick to Sublime and the command line when writing and testing code and use VS2013 when I need the debugger.

However, not being able to click on those errors really was a bummer, and perhaps its what led me do something to improve the experience of using Boost Build on the command line. The worst part of using it today is that while Macaroni itself has colorized output, when it runs Boost Build the affair is strictly monochromatic, meaning I've gotten very good at scanning through dozens or even hundreds of lines of text to find the one or two error messages that caused the failure. It looks something like this:

So, in about two mornings worth of time last weekend I created Bjolt, which runs bjam and colorizes its output as well as formatting long lines to make them easier to read in Windows. Now it looks more like this:

So far it finds errors and warning from the Visual C++ compiler and linker, as well as error messages from Boost Test. In the future I'll probably add support for GCC and Clang (ironically Clang has beautiful colorization, but Boost Build unfortunately ruins it).

Download Bjolt here.



Solace comforts sufferers of the Windows Console
Sunday August 25, 2013 03:20:19

Here's a tool I whipped up this afternoon in order to spruce up using the Windows command line console as well as create an easy-to-grok example project for Macaroni for C++.

The Windows console has a palette of 16 colors. While it's easy to switch the foreground and background colors between the various 16 choices on the command line using the color shell command, altering the palette itself is a huge hassle and involves clicking around in Windows 95 era GUIs. Using a modified palette routinely introduces other hassles as the colors may not work for all programs. Finally, there's no way to switch between palettes in an active session, and when you're juggling multiple command line sessions the ability to switch to a unique color scheme is crucial to maintaining sanity.

There are several pretty decent Windows command prompt replacements out there, but none ever clicked for me personally. So I always find myself using the standard command prompt and hating the lack of colors (and tabs, but I didn't write a program to fix that so we won't discuss that today).

Coding Solace

I went looking around for a program to change the built in palette of colors from the command line and found a tool called consattr which seemed to do exactly what I needed, but alas it didn't work in Windows Vista onward (I think- the page is a bit out of date). However, the author derelict did include a note on a Windows API call named “SetConsolePalette”, which lead me to a source file from catch22.net that included a note referencing a new Vista API called SetConsoleScreenBufferEx, and at that point I figured writing a program myself might not be that difficult.

The big trick, as usual, was mitigating the pathological edge case bugs that seem to exist in all Windows APIs (the call to change the color palette moves the window for some reason, so code had to be written to move it back), but with a little bit of Googling and elbow grease I got it done in a few hours.

Even though Solace is Windows only, I hope it might serve as a decent example of how to use Macaroni as it is both simple enough to understand but also manages to accomplish something worth doing. A unique thing about the project's code is that I tried to keep all of the source to one single file, though I did move some external project declarations out as it seemed like better practice. The cool thing is this all worked without any changes to Macaroni, which is not something I could have said two years or even a year ago. Every C++ translation unit necessary to create Solace, including the two main functions for each exe file, comes from a single Macaroni source file. Though it's kind of a cheat to say this since it generates a Boost Build script,the entire project's build configuration is only 15 lines long.

Using Solace

Solace works by writing all the colors used by the current palette to stdout. They can then be scooped up into a file which can be loaded later.

The file format is just the palette index, an equals sign, and the three RGB values seperated by spaces and ending with a newline.

Once you create a few color schemes you like, it's easy to write a batch file like the following to load them:

 solace-load coffee.solace
color 07

Put that in a file called “coffee.bat” somewhere in your path and you've got a quick way to put a color scheme into effect whenever you need it. Make a few of these and the color experience approaches something usually seen only on Linux or OSX.





<---2015-01-10 18:53:08 history 2013-08-11 23:45:43--->



-All material © 2007 Tim Simpson unless otherwise noted-