Questions about windows support

James Miller james at
Thu Feb 23 03:38:52 PST 2012

On 23 February 2012 19:41, H. S. Teoh <hsteoh at> wrote:
> On Thu, Feb 23, 2012 at 06:02:30PM +1300, James Miller wrote:
> [...]
>> And I've been playing with trying to write my own terminal emulator. I
>> actually kinda have one working, in C. I just need to wrap all the C
>> code in functions and do all the interesting stuff in D.
> [...]
>> But I have plans for it, including some cool graphical stuff. I'm
>> using clutter to render everything, so I can do all sorts of things
>> with it, but to start with, I'd like to be able to display pictures
>> inline, so you can do `cat my_pic.jpg` and rather throwing masses of
>> garbage at you, it renders the picture, I might have to write my own
>> cat to do so however...
> [...]
> Now *that* is an excellent idea!
> Perhaps there's a way of detecting JPEG or PNG output, say some kind of
> magic number detection ala /usr/bin/file. Buffer the first few bytes at
> output at the start of new lines, and if it looks like a JPEG file,
> buffer the rest of the output instead of displaying it immediately, and
> if after reading more input it does appear to be a valid JPEG file, then
> display it as an image.  Otherwise flush the buffer and display it as
> text.
> To prevent problems with false positives causing output not to appear,
> you could use a timer: if the data type can't be determined within, say,
> 1/20 of a second, then skip the detection and display the output as
> text. Presumably if you do cat my_pic.jpg more than just the first few
> bytes will come out in the first 1/20 of a second, so it will pretty
> much reliably detect image data.
> Or you can do it the easy way by having a dedicated escape sequence that
> switches to image mode, and write a wrapper for cat that outputs this
> sequence when it detects image data in its output. The danger though is
> that you might get stuck in image mode if cat crashes before the image
> data is completely spooled, in that case it'll be like the ole DOS days
> when you got stuck in VGA mode when it has dropped back to the DOS
> prompt, and typing only produces line noise on the screen. :P
> T
> --
> This is a tpyo.

I was thinking about both of those options and came to pretty much the
same conclusions. What would be cool would be to add in new STD* file
descriptors (ala STDIN, STDOUT, etc) that are dedicated to
presentation (also means that you can output things to the terminal
while running a pipe), however that would also require shell support
(to set the correct FDs on the child process) and I'm not writing a
terminal /and/ shell (yet).

Otherwise, I think having the terminal take note of what is going on
in the shell would solve the stuck mode problem, (which i encountered
accidentally by putting my terminal into alt_charset mode) just have
it notice if the current process is a shell or not and basically say
"Shells can't be in image mode". It would probably require grabbing

The other advantage of using an escape sequence is that assuming that
it can read fast enough, then it could easily be extended to all sorts
of things, video for example. Displays a small video in the terminal,
so you can check that the video is what you actually want, don't
replace an actual movie player, that would be silly. you could also
have things like syntax highlighting for supported files.

As you can probably tell, I am less than enamored by the current
terminal/shell line-up we have, I just think that there is so much
more we could do with modern tech, and it doesn't need to even be
incompatible with older systems!

More information about the Digitalmars-d mailing list