2017-04-25T01:49:44Z via Identi.ca Web CC: Public
2017-04-23T09:38:43Z via Identi.ca Web To: Public CC:Today, I spent some time investigating terminal UI libraries. You know, the kind of library that lets you draw coloured text to your terminal, and tells you which key the user pressed. Turns out, it's a lot messier than I imagined.
curses is the grandaddy, of course. It supports Every Terminal Ever, it's available on every platform, it's wicked-smart about updating the screen, what's not to like? Well, because it supports Every Terminal Ever, the API has this odd fascination with colour-pairs instead of just setting foreground and background colours. It doesn't support mouse-drag events, or any mouse events past column 224, or keyboard events involving the Alt modifier, or the true-colour output that some terminals support these days. And on top of everything else, the API is weird and archaic to modern eyes—definitely a product of its era.
But curses gets its wide compatibility from terminfo, right? So we'll just write to the libterminfo API and build our own abstractions on top. We'll lose the cleverness of curses, but we'll get the features we want, right? Right? Unfortunately, terminfo has a weird dynamic-typing thing going on: for a given terminal, a given capability can be a boolean, integer, string, or a string-template, and you just have to assume what it's going to be, you can't query it, so you don't want to venture too far outside the well-known capabilities terminfo defines. Worse, terminfo doesn't support as much as you'd like. Some keys have regular and shifted capabilies (for example, "key_left" and "key_sleft" for the Left arrow and Shift-Left respectively), most do not. Terminfo supports ~60 function keys, so typically Shift-F1 is mapped to F13 (or F11), Ctrl-F1 to F25 (or F21), etc. There's a sequence for mouse input, but it assumes details of the traditional xterm mouse protocol, so you're stuck with the 224-column limit.
Most other libraries are built on top of curses, or are just designed to support very basic formatting and positioning, so they're not much good for the general case of full-screen terminal applications.
One library that seems to be well designed is libtermkey - it only deals with input, but it deals with it the right way: you feed in bytes, you get out UTF-8 strings, key symbols with modifiers, or mouse events (autodetecting what protocol is in use). Unfortunately, libtermkey is officially deprecated, although it does see minor development work.
libtermkey's official replacement is libtickit, by the same author. Unfortunately, that library has only just (in early April 2017) reach version 0.1, and is not yet widely available. Time will tell whether it becomes the One True Text UI library.
Claes Wallin (韋嘉誠) likes this.
2017-04-08T01:37:41Z via Identi.ca Web To: Public CC:“So my name is Tim, and I’ll be your first interviewer today…” Tim is making every effort to be cheery. His ears stick out a bit, and in his dark-brown hoodie and cream shirt, perched expectantly at the table, he resembles something of a pine marten. You like pine martens, and therefore Tim as well.
2017-01-22T09:27:04Z via Identi.ca Web To: Public CC:Where some people get in a writing mood by maximizing their Word window, or dragging out their old Smith-Corona, I like to set my terminal to full-screen mode and crank up the font-size until my target line-length just about fits on the screen.
Right now, I'm using Envy Code R, which is one of those monospaced fonts designed to look good at a very specific pixel height, which is a lot smaller than it happens to be in my full-screen terminal right now. It's a very weird mixture of stubby, blocky glyphs rendered lovingly, crisply in super-high resolution, an incongruity that feels appropriate for a display that uses an LCD panel and 3D acceleration to emulate a VT220.
Alex Jordan likes this.
2017-01-15T08:17:23Z via Identi.ca Web To: Public CC:It's been a long time since I did any photography, but on Thursday I went on a photo-walk around a new park that opened last year (on the site of the old commercial wharves) and found some things I liked:
2017-01-08T01:11:48Z via Identi.ca Web To: Public CC:I forget where I found it, but somebody pointed me to a YouTube playlist called "Category Theory for Programmers", and I'm about half-way through it (up to the end of lecture 5.2, Algebraic Data Types).
Having dabbled in Rust and read some blog-posts about Haskell, I already knew some of this stuff (like the existence of sum and product types, or Void and unit), but having them all described with all the connections between them is kind of blowing my mind. For example, I knew algebraic data types were "algebraic" because they're a bit like "addition" and "multiplication", but the video pulls out a whole bunch of high-school algebra, translates it into data-type notation and shows that it not just works, but that it's actually useful things a programmer would recognise.
It's a long series of videos—it seems like a university professor recorded an entire semester's worth of lectures—but I'm more than happy to have spent the time to watch them on my Christmas holidays.
der.hans shared this.
2016-12-31T10:51:31Z via Identi.ca Web To: Public CC:I've been a tea-drinker for years, but having experienced tepid and room-temperature tea, the idea of "iced tea" sounded thoroughly revolting. But, my parents had a bottle of peach-flavoured ice-tea, and it wasn't too bad, so I decided to try making my own.
In particular, I filled a mug with boiling water, dropped a tea-bag into it, waited 4 minutes (my usual span) then took the tea-bag out and dissolved a teaspoon of honey into it. Finally, I stuck it in the fridge for a few hours.
When it was cold, I pulled it out, sprinkled some ice-cubes into it, and... ugh. Not as disgusting as room-temperature tea, but still quite bitter. Maybe it needs more honey?
I normally have tea with milk and no sugar, but I assume milk in iced tea Just Wouldn't Work; I've never heard of anybody ever trying it.
2016-11-16T02:47:56Z via Identi.ca Web To: Public CC:How To Be A White Person Right After Trump Got Elected
"Just remember that purely political violence is the tool of the fascist, and that you can’t employ it without becoming one to some degree. So don’t beat up Red Hats or Paleocons or even Steve Bannon. It might feel satisfying, but at this stage its moral justification bears very little scrutiny."
2016-11-06T12:31:37Z via Identi.ca Web CC: Public
After years of inactivity, on yesterday's public holiday I took some time to tinker with my Python parser library, Omega. Previous tinkerings had been cut short by the usual backtracking-parser flaw where a syntax error in the input causes it to wildly backtrack out to unrelated parts of the grammar and you get some stupid error message like "expected EOF, found trailing data at offset 1".
So, this time I implemented the "cut" operator that prevents backtracking, so you get more relevant error messages, much closer to the source of the problem. The other classic problem with PEG/Packrat parsers is crazy memory usage, as they cache all the parser states they might backtrack to but probably never will - and because "cut" prevents backtracking, it's also a signal to the parser to discard old parser states, freeing up a bunch of memory. So, it's a double win!
The paper where I first read about "cut" suggested that cuts be automatically inserted as an optimisation pass, but I don't support optimisation passes yet so right now I've just been sprinkling them around manually, and it's working pretty well.
I really do need optimization passes, though: not just for "cut", I also need to transform the simpler parts of the parser into regexes that I can hand off to Python's (C-implemented) regex engine, rather than doing all the matching myself.. my current approach is simple, but it's not doing me any speed favours. :/
2016-08-21T12:06:01Z via Identi.ca Web To: Public CC:So, I'm watching the Larry Wall keynote from the Curry On 2016 programming language conference, about Perl 6:
Man, every time I read about Perl 6, I get really enthusiastic about the community and the ideas and the features (PEG parsers as a core language feature! Gradual typing! Custom operators! Every binary operator can be used for folding! Deploy on the JVM or their custom VM!) but then I go look at some tutorials and there's a million special-case syntaxes for different things and I start worrying about what happens when you mix and match them (for example: $ for scalars, @ for arrays, OK. What happens if you put the "wrong" sigil on a variable name? Are they separate name-spaces? Are there terrible DWIM defaults like Perl 5?).
I really want to like Perl 6, but it's just so... Perly.
Face likes this.
2016-07-30T09:12:24Z via Identi.ca Web To: Public CC:"From Monkey Island to Broken Age": The lead programmer of Broken Age, who also worked on the Monkey Island Special Edition games and the remastered releases of Day of the Tentacle and Grim Fandango, talks about the technology and implementation details of 2D point-and-click adventure games.
2016-06-21T09:30:32Z via Identi.ca Web To: Public CC:I had a wheezy cough this morning so I stayed home from work; rather than lounge around playing video games I decided I would try to wrap my head around a VT220+ terminal emulator state-machine in Rust.
As it turns out, just mapping out the standards documents where these things are defined is more than a day's work, let alone when your head's a bit fluffy. Maybe this is one of those things that should wait for retirement...
2016-05-28T01:23:46Z via Identi.ca Web To: Public CC:Time rolls on, and ideas and tastes froth and roll.
When I was younger, I was overwhelmed by all the ideas in the world, but I found a few that were fresh and exciting and that I enjoyed studying and learning about. Other ideas surfaced around me, but I figured I'd get around to investigating them sooner or later. Some of them evaporated before I got to them, some of them were replaced by more, newer ideas.
And now, mid-life, I feel I've got a good grasp of some of the basics, and I'm ready to stretch myself and start exercising these ideas and practicing them... but already, I notice there's not as many fellow practitioners as once there were, and the few really visible examples are the old-before-their-time people who write Kids Today Value Style Over Substance diatribes and hunker down trying to prevent the things they love from changing at all, ever.
I hope I'm not one of those people, I don't want to be one of those people, I can still find new ideas I'm interested in and want to explore even if they're rarer than they once were... but honestly, I'm worried.
2016-04-10T13:47:39Z via Identi.ca Web To: Public CC:When I was a kid, I had an Apple II+. It only handled upper-case characters, with inverse and (for special occasions) blinking. I was super-jealous of my friend with an IBM XT, with a ridiculously fancy character set that included card suits and Greek letters.
Somewhere I learned that newer Apple II models than mine had a thing called MouseText, whose purpose wasn't entirely obvious, but it was yet more fancy characters I didn't have access to. I felt more frustrated, but eventually I got my own PC-compatible and had all the fancy glyphs I could use, and moved on with my life.
But recently, I came across a TrueType font based on the old Apple II character ROM, which happened to include MouseText characters in the Unicode Private Use Area. And the Wikipedia article on MouseText (because of course there's a Wikipedia article on MouseText) mentions it was added to allow "simple text user interfaces resembling the Macintosh graphical user interface", which makes sense since the Apple II was much more limited than Macintosh hardware, but GUIs were all the rage in 1984. And even more conveniently, the Internet Archive happens to have a scan of the Developer's Handbook for the Apple II MouseText Toolkit!
So here I am, at quarter-to-midnight, with a line of mysterious glyphs pasted into Vim, shuffling them around and trying to shape them into something resembling the poorly-reproduced, ten-times-photocopied pictures in a thirty-year-old book, finally living out my childhood fantasy of making weird shapes into slick and professional-looking (for the time) displays...
You know, this probably wouldn't be the best excuse if I wind up late to work tomorrow.
2016-03-28T10:47:08Z via Identi.ca Web To: Public CC:Holy crap, a new Hectic City mix from The Kleptones:
joeyh likes this.
2016-03-13T21:40:15Z via Identi.ca Web To: Public CC:Some shower thoughts:
It's a common thing in hip-hop to use spoken-word samples that naturally fit the tempo of the track (for example). That works surprisingly often because (apparently) the syllable-tempo of spoken English falls more or less into the "danceable" range.
But there's languages with very different syllable-tempos; Spanish tends to run much faster, for example. But is it exactly twice as fast? Do hip-hop artists in Spanish-speaking countries have to stretch their speech samples to fit the music, or do they make the music faster to match? Or maybe it all winds up in some obscure timing signature like 7/4 so that everything fits?
2015-12-29T11:59:10Z via Identi.ca Web To: Public CC:Spending some holiday time on a pleasantly futile project; trying to figure out how to implement a DEC VT100 terminal emulator.
I'm beginning to understand why nobody, not even xterm, bothers to implement the VT100's "double width characters" feature, and I'm sorely tempted to pretend it doesn't exist.