Friday, November 14, 2014

Text Editor Project Started

With a long weekend holiday here, I finally bit the bullet and started work on building a new text editor for myself. This comes after years of trialling different solutions - including giving some of the latest newfangled web-tech based ones out there a second chance with an open mind (in the end, a combination of critical quirky flaws and horrid colour schemes inducing eye pain - including one nasty bout of red-eyed discomfort for a few hours) as replacements or "secondaries"... Unfortunately, nothing is quite cutting it anymore :/

So, introducing "Nippy" - a PyQt + QScintilla based text editor, heavily inspired by Notepad++


Currently, there's not much to see. It's only a single-document text editor window right now, with a lexer hardcoded to treat everything as Python code, and with no session storage. But at least I can use it to load up any of the code for my Python-based projects, and use it for some simple coding tasks (bookmarks, duplicate-lines, move up/down, go to line, tab-based indentation, and file open/save all work, with the rest provided by QScintilla already - in other words, the bare basics I need from an editor to do stuff; a working function list + find in files + multiple tabs would just make things easier).



It takes everything I like/love about it over every other editor out there (i.e. single click to add bookmarks in the margin, Find in Files, Function List in file order), without any of the stuff I hate/don't need (i.e. mainly "code folding", "strip trailing spaces", and "maximum line length indicator"), and solving many of the irritations that had started getting quite disruptive (i.e. hard to read tabs due to nasty gray fill, no autodetect for indentation type, the newfangled builtin Function List collapsing in on itself at the slightest provocation and missing far too many of the functions in Blender's code, that freaking "do you want to reload" prompt, and automatic deletion/removal of tabs if the files couldn't be found on load - terrible if you switch between branches).

Perhaps the final nail in the coffin though was the fact that it was getting hard trying to use this to manage 3-7 simultaneous projects (several long-term ongoing, others short throwaways, and others "on hold" for now). Notably:
1) It was hard being able to switch between two groups of them during the day without constantly refocussing the tab bar to the right region,
2) Keeping all the relevant files + bookmarks safe from accidental corruption (aka being purged) by an ill-timed branch switch was getting harder and harder
3) My ability to quickly jump to a reference file for a project without struggling for ages to reframe/reorganise the tab bar to get all the relevant files within easy access (remember, closing a tab loses the references loaded up for another project, so that's not convenient) was declining with each additional file open

Now, from all that I've been able to tell, nothing out there solves any of these problems at all.
* Geany solves the line-detection problem but introduces dozens of its own (i.e. GTK, even worse tab management, a function list I need to patch and recompile to force it to do appearance-ordered but which still annoyingly groups by type, Go to Line as a non-blocking field on a toolbar - this turns out to be incredibly annoying, and a slightly depressing colour scheme)

* Atom and Lighttable - The newfangled editors I mentioned earlier...
   Lighttable is the slightly better behaved of the two, but critically, its autocomplete tendencies/popups are really annoying. It can remember sessions, but it doesn't load them readily on startup, and needs to be manually maximised every time, following its slow startup animation.
   Atom - though the hipper of the two - is worse behaved - critically, all the fonts are completely blurry/fuzzy, I cannot find any themes for this which are not low contrast + eye wateringly ugly, it doesn't remember session state at all (and has no way of doing so) it forcibly strips trailing spaces and converts things to space-based indentation (with no way to turn off).

  Oh, and one other thing about these two "web based" editors - they cannot seem to pop up a colour swatch when you've clearly got code describing a colour selected

* Sublime Text - I should probably lump this one in with the web-based ones above, since it's practically of the same breed, just a few years older and with less web-internals. Having said that, it too has the same problems. But the dealbreaker for me was that it could not be trusted to not mangle whitespace. Notably, during the period I trialled it, it worked fine for the first 3 or so commits/small projects I did. On the last one though, everything looked fine until I had committed the code - for whatever reason, it had done something funky with the indentation on the lines I'd changed. Loading the file again in itself, there was still no indication that anything was wrong - but on every other editor, and the commit logs, and on other people's machines, the evidence was as clear as day that the whitespace had gone haywire there. So, SublimeText is out, as it cannot be trusted to only do as I tell it to, and not to randomly corrupt my work as it sees pleased to do.

* Vim - Generally dependable and ok in a pinch, but I'd have to be lying if I said that that style of working was good for my productivity. The truth is: it feels clunky, and like trying to instruct an alien via a time-delayed proxy on how you'd like to trim your toenails using an industrial-strength sander (oh, and did I mention that that alien has a temper, and will sometimes just do its own thing, until you switch it back into 'normal' mode :P)

* IDE's - Every IDE out there is practically the same in the sense that they assume that:
   1) Your project is small enough that trawling the entire codebase to build up its index is near instantaneous,
   2) Your project is small enough that displaying all the files in a tree view makes sense, and that displaying files in a tree view is good
   3) You only work on a single project. And, you won't need/want to keep many files open for whatever reasons.
   4) Navigating around your files is not that important/much of a problem. If you're lucky, you may get a symbol list (i.e. Eclipse has one, but it's often stuck/pinned up in a tiny pane that isn't easily moved/liberated for easier use)
   5) You don't mind bringing down/locking up your dev environment if your code goes under, and can't be easily revived
   6) You're happy waiting through a long winded splash screen reindexing and booting up a gazillion plugins - 'cause modular plugins with a complicated dependency/deployment architecture around them are cool

* CodeBubbles - The only thing out there that transcends all this is the CodeBubbles prototype (and IIRC, a plugin for Visual Studio, last I heard), which allows users to arrange snippets of code around on an infinite canvas, grouped by what they're related to and so forth. It's an insanely cool idea, but breaking down the strong association to files as units of code is something which doesn't sit that nicely IMO, especially when you've got many languages still expecting/requiring such a mapping.

* All the other countless, nameless editors out there. They generally sit between the IDE's and Geany here, but generally all are either butt ugly, or missing limbs here and there.


For many years now (close to 10), I've been a Notepad++ user. In fact, for 6 of those, I used a particular version of Notepad++ (4.x to be precise), and have only migrated to a newer version for the past year as I couldn't easily get hold of a copy of the old one. Despite the bugs in that old version though (notably, a lock up if you forget to enter a type filer for the Find in Files, and the function list getting amnesia if you leave any unclosed " or ' lying around), at least they were known quantities

No comments:

Post a Comment