Loading ...
Sorry, an error occurred while loading the content.

How to get the geometry of a X terminal ?

Expand Messages
  • Fabrice Marchant
    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
    Message 1 of 6 , Feb 28, 2008
    • 0 Attachment
      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
    • Eric Cooper
      ... 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
      Message 2 of 6 , Feb 28, 2008
      • 0 Attachment
        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
      • Richard Jones
        ... Please use OCaml curses: http://www.nongnu.org/ocaml-tmk/ Rich. -- Richard Jones Red Hat
        Message 3 of 6 , Feb 28, 2008
        • 0 Attachment
          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
        • Fabrice Marchant
          ... Many thanks for your help. Ah yes, screen scraping ! I discovered this technique one year ago on this list :
          Message 4 of 6 , Feb 29, 2008
          • 0 Attachment
            > 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
          • Fabrice Marchant
            ... 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
            Message 5 of 6 , Feb 29, 2008
            • 0 Attachment
              > > 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
            • Richard Jones
              ... It s been in Debian (and Fedora for that matter) for a good 6 months or more. Rich. -- Richard Jones Red Hat
              Message 6 of 6 , Feb 29, 2008
              • 0 Attachment
                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
              Your message has been successfully submitted and would be delivered to recipients shortly.