List Info

Thread: "ocaml_beginners"::[] How to get the geometry of a X terminal ?




"ocaml_beginners"::[] How to get the geometry of a X terminal ?
country flaguser name
France
2008-02-28 07:45:58

Hi !

I see there is a "Terminal interface" part in the Unix module.
However I've no idea how to get currently set "columns" and "lines" used by "xterm" on my linux.

Any light ?

Thanks

Fabrice

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] How to get the geometry of a X terminal ?
country flaguser name
United States
2008-02-28 10:43:19

On Thu, Feb 28, 2008 at 02:45:58PM +0100, Fabrice Marchant wrote:
> I see there is a "Terminal interface" part in the Unix module.
> However I've no idea how to get currently set "columns" and "lines"
> used by "xterm" on my linux.

The Unix terminal interface is much lower-level -- it lets you control
line speed, character echo, etc.

You can use xterm escape sequences to do what you want.
They're documented in /usr/share/doc/xterm/ctlseqs.*, but many are
xterm-specific (they don't work in gnome-terminal for example).

If you run
echo -e "e[18t"
then xterm will respond with a line of the form
ESC [ 8 ; height ; width t
It generates this line as if it were typed input, so it can then be read by
your program on stdin. Doing this with printf and scanf in OCaml is
left as an exercise

--
Eric Cooper e c c c m u . e d u

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] How to get the geometry of a X terminal ?
country flaguser name
United Kingdom
2008-02-28 11:20:42

On Thu, Feb 28, 2008 at 02:45:58PM +0100, Fabrice Marchant wrote:
> I see there is a "Terminal interface" part in the Unix module.
> However I've no idea how to get currently set "columns" and "lines"
> used by "xterm" on my linux.

Please use OCaml curses: http://www.nongnu.org/ocaml-tmk/

Rich.

--
Richard Jones
Red Hat

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] How to get the geometry of a X terminal ?
country flaguser name
France
2008-02-29 02:04:42

> You can use xterm escape sequences to do what you want.
> They're documented in /usr/share/doc/xterm/ctlseqs.*, but many are
> xterm-specific (they don't work in gnome-terminal for example).
>
> If you run
> echo -e "e[18t"
> then xterm will respond with a line of the form
>; ESC [ 8 ; height ; width t
> It generates this line as if it were typed input, so it can then be read by
> your program on stdin. Doing this with printf and scanf in OCaml is
> left as an exercise

Many thanks for your help.

Ah yes, screen scraping ! I discovered this technique one year ago on this list :
http://tech.groups.yahoo.com/group/ocaml_beginners/message/7423

Regards,

Fabrice

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] How to get the geometry of a X terminal ?
country flaguser name
France
2008-02-29 02:09:01

> > However I've no idea how to get currently set "columns" and "lines"
> > used by "xterm" on my linux.
>
> Please use OCaml curses: http://www.nongnu.org/ocaml-tmk/
>
> Rich.

Thanks a lot.

You promised to write a curses binding. So you have done it !
I impatiently wait for the announced debian package.

Regards,

Fabrice

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] How to get the geometry of a X terminal ?
country flaguser name
United Kingdom
2008-02-29 17:19:41

On Fri, Feb 29, 2008 at 09:09:01AM +0100, Fabrice Marchant wrote:
> > > However I've no idea how to get currently set "columns" and "lines"
> > > used by "xterm" on my linux.
> >
> > Please use OCaml curses: http://www.nongnu.org/ocaml-tmk/
> >
> > Rich.
>
> Thanks a lot.
>;
> You promised to write a curses binding. So you have done it !
> I impatiently wait for the announced debian package.

It's been in Debian (and Fedora for that matter) for a good 6 months
or more.

Rich.

--
Richard Jones
Red Hat

__._,_.___
.

__,_._,___
[1-6]

about | contact  Other archives ( Real Estate discussion Medical topics )