Thread overview
Testing if a file is connected to a terminal
Dec 17, 2015
Shriramana Sharma
Dec 17, 2015
Jakob Ovrum
Dec 17, 2015
Adam D. Ruppe
Dec 17, 2015
Jakob Ovrum
Dec 17, 2015
Shriramana Sharma
Dec 17, 2015
Adam D. Ruppe
December 17, 2015
Is there a canonical way to test in D whether stdout/stderr (or in general, a std.stdio.File) refers to a terminal or not?

https://www.google.co.in/search?q=terminal&sitesearch=dlang.org/phobos turns out nothing.

I knew of C's (or rather POSIX's) isatty, and after some digging I found isatty defined under core.sys.posix.unistd, and I suppose I can just pass to it the output of std.stdio.File.getFP.

Is there any other way to do the desired test? Or is this the recommended way?

-- 
Shriramana Sharma, Penguin #395953
December 17, 2015
On Thursday, 17 December 2015 at 03:38:31 UTC, Shriramana Sharma wrote:
> Is there a canonical way to test in D whether stdout/stderr (or in general, a std.stdio.File) refers to a terminal or not?
>
> https://www.google.co.in/search?q=terminal&sitesearch=dlang.org/phobos turns out nothing.
>
> I knew of C's (or rather POSIX's) isatty, and after some digging I found isatty defined under core.sys.posix.unistd, and I suppose I can just pass to it the output of std.stdio.File.getFP.
>
> Is there any other way to do the desired test? Or is this the recommended way?

We don't have any terminal functionality in Phobos at this time, so using isatty directly is the way to go.

There are some terminal libraries on Github (like consoled) but I have to say I think they're uninspiring in terms of quality and presentation.

December 17, 2015
On Thursday, 17 December 2015 at 03:59:27 UTC, Jakob Ovrum wrote:
> There are some terminal libraries on Github (like consoled) but I have to say I think they're uninspiring in terms of quality and presentation.

Can you be any more specific about that?
December 17, 2015
On Thursday, 17 December 2015 at 04:05:57 UTC, Adam D. Ruppe wrote:
> On Thursday, 17 December 2015 at 03:59:27 UTC, Jakob Ovrum wrote:
>> There are some terminal libraries on Github (like consoled) but I have to say I think they're uninspiring in terms of quality and presentation.
>
> Can you be any more specific about that?

Where's the reference documentation?
December 17, 2015
Jakob Ovrum wrote:

> Where's the reference documentation?

There's a README: http://code.dlang.org/packages/consoled, and the source does seem to have DDoc comments...

-- 
Shriramana Sharma, Penguin #395953
December 17, 2015
On Thursday, 17 December 2015 at 05:01:15 UTC, Jakob Ovrum wrote:
> Where's the reference documentation?

In the source...

but yeah, good point. I'm working on writing docs for a lot of my stuff. Terminal is still completely messed up

http://arsdnet.net/arsd/terminal.html

cgi is meh but there: http://arsdnet.net/arsd/cgi.html

simpledisplay is the one I've spent the most time on so far: http://arsdnet.net/arsd/simpledisplay.html


I'm pretty happy with how terminal.d works, but indeed the docs are still awful.