help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to detect terminal type?


From: E. Joshua Rigler
Subject: Re: How to detect terminal type?
Date: 10 Jan 2003 12:17:05 -0700

I'd forgotten that gshow only returns via stderror.  

I don't see why you feel your suggested fix is "ugly" though.  The
"computer" command is a built-in command, so it should work fine either
way (says the man who has never, ever, ever tried to use Octave under
windows).  I mean something like that has to be implemented at some
level, so it might as well be you who does it :^).  I suspect this will
be far from the ugliest hack you need to do to get a complex software
package to work under both *nix and windows.  Good luck!

-EJR


On Fri, 2003-01-10 at 11:27, Peter Brinkmann wrote:
> Joshua, Miquel,
> Thanks for your prompt reply! Unfortunately, neither gshow nor gget will
> work for my purposes.
> 
> My current situation is this: I'm developing educational software under
> Linux, but it also has to work under Windows because that's what most of
> my students are using. I was hoping to be able to write some code that
> automatically detects, remembers, and resets the terminal type, like
> 
>       terminal_type=get_terminal_type();      % remember terminal type
>       gset terminal postscript
>       ... create postscript output
>       gset(['terminal ' terminal_type]);      % reset terminal type
> 
> Now it appears that this won't work because gshow only displays its result
> but doesn't return a value, and gget only works under *nix, in which
> case I already know the result.
> 
> I'm afraid I'll have to do something like
> 
>       gset terminal postscript
>       ... create postscript output
>       if running_under_unix
>               gset('terminal x11')
>       else
>               gset('terminal windows')
>       end
> 
> This is ugly, but I don't see a better solution.
> 
> So, my new question is, what's the best way to detect whether my code is
> running under *nix or Windows? I guess I could look at the result of
> computer(), but I don't know what kind of result it returns when running
> under Windows. Can I detect Windows by checking whether
>       findstr(computer(),'windows')
> returns a nonzero value, or how should I go about this?
> Thanks,
>       Peter
> 
> 
> 
> On Fri, 2003-01-10 at 09:21, Peter Brinkmann wrote:
> > Hi!
> > How can I detect the current terminal type?
> > I'm asking because I sometimes need to change the terminal type
> > in order to export plots to encapsulated PostScript, using a
> > command like
> >     gset terminal postscript
> > On my Linux box, I can reset the terminal with a command like
> >     gset terminal x11
> > The problem is that this doesn't work under Windows. So, what
> > I'd like to do is the following:
> >     1. Detect and remember the current terminal type.
> >     2. Export stuff to PostScript.
> >     3. Reset the terminal type to what it was before.
> > Is this possible at all?
> > Thanks,
> >     Peter
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
-- 
E. Joshua Rigler <address@hidden>



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]