unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* X11 bindings and shell bindings
@ 2008-09-18 12:38 Ishan Arora
  2008-09-18 13:52 ` Jon Wilson
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Ishan Arora @ 2008-09-18 12:38 UTC (permalink / raw)
  To: Guile User Mailing List

[-- Attachment #1: Type: text/plain, Size: 167 bytes --]

Hi,

Is there a procedure to get mouse position. And is there a procedure to
synchronously run a shell code and return the output as a String. Thanks.

Regards,
Ishan

[-- Attachment #2: Type: text/html, Size: 207 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X11 bindings and shell bindings
  2008-09-18 12:38 X11 bindings and shell bindings Ishan Arora
@ 2008-09-18 13:52 ` Jon Wilson
  2008-09-18 15:10   ` Ishan Arora
  2008-09-18 17:16 ` Paul Emsley
  2008-09-18 18:43 ` Andy Wingo
  2 siblings, 1 reply; 11+ messages in thread
From: Jon Wilson @ 2008-09-18 13:52 UTC (permalink / raw)
  To: Ishan Arora; +Cc: Guile User Mailing List

Hi Ishan,
  * There are guile bindings for gtk and for gnome; I don't know of any 
other X11 bindings.

  * Try (system "ls -l").  Look it up in the POSIX section in the manual.
Regards,
Jon

Ishan Arora wrote:
> Hi,
> 
> Is there a procedure to get mouse position. And is there a procedure to 
> synchronously run a shell code and return the output as a String. Thanks.
> 
> Regards,
> Ishan





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X11 bindings and shell bindings
  2008-09-18 13:52 ` Jon Wilson
@ 2008-09-18 15:10   ` Ishan Arora
  2008-09-18 17:01     ` JonWilson
  0 siblings, 1 reply; 11+ messages in thread
From: Ishan Arora @ 2008-09-18 15:10 UTC (permalink / raw)
  To: Jon Wilson; +Cc: Guile User Mailing List

[-- Attachment #1: Type: text/plain, Size: 741 bytes --]

Hi,

Thanks for the reply. I tried system. It calls the code synchronously, and
returns a number for success or failure of the command. Is there a way such
that the stdout output of the command is returned as a string? Thanks again.

Regards,
Ishan

On Thu, Sep 18, 2008 at 7:22 PM, Jon Wilson <jsw@wilsonjc.us> wrote:

> Hi Ishan,
>  * There are guile bindings for gtk and for gnome; I don't know of any
> other X11 bindings.
>
>  * Try (system "ls -l").  Look it up in the POSIX section in the manual.
> Regards,
> Jon
>
>
> Ishan Arora wrote:
>
>> Hi,
>>
>> Is there a procedure to get mouse position. And is there a procedure to
>> synchronously run a shell code and return the output as a String. Thanks.
>>
>> Regards,
>> Ishan
>>
>
>

[-- Attachment #2: Type: text/html, Size: 1296 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X11 bindings and shell bindings
@ 2008-09-18 16:08 dsmich
  2008-09-18 16:58 ` Neil Jerram
  0 siblings, 1 reply; 11+ messages in thread
From: dsmich @ 2008-09-18 16:08 UTC (permalink / raw)
  To: Ishan Arora; +Cc: Guile User Mailing List

---- Ishan Arora <ishanarora@gmail.com> wrote: 
> Hi,
> 
> Thanks for the reply. I tried system. It calls the code synchronously, and
> returns a number for success or failure of the command. Is there a way such
> that the stdout output of the command is returned as a string? Thanks again.

Try open-input-pipe in the (ice-9 popen) module.

http://www.gnu.org/software/guile/manual/html_node/Pipes.html

-Dale





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X11 bindings and shell bindings
       [not found] <cmu-lmtpd-23352-1221754132-4@mail-imap1.uio.no>
@ 2008-09-18 16:54 ` Kjetil S. Matheussen
  0 siblings, 0 replies; 11+ messages in thread
From: Kjetil S. Matheussen @ 2008-09-18 16:54 UTC (permalink / raw)
  To: guile-user


"Ishan Arora":
> And is there a procedure to
> synchronously run a shell code and return the output as a String. Thanks.
> 

Should do:

(use-modules (ice-9 rdelim))

(define (get-system-output command)
  (let ((logfilename (tmpnam)))
    (system (string-append command " > " logfilename))
    (let* ((ret "")
	   (fd (open-file logfilename "r"))
	   (line (read-line fd)))
      (while (not (eof-object? line))
	     (set! ret (string-append ret line))
	     (set! line (read-line fd)))
      (close fd)
      (system (string-append "rm " logfilename))
      ret)))





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X11 bindings and shell bindings
  2008-09-18 16:08 dsmich
@ 2008-09-18 16:58 ` Neil Jerram
  0 siblings, 0 replies; 11+ messages in thread
From: Neil Jerram @ 2008-09-18 16:58 UTC (permalink / raw)
  To: dsmich; +Cc: Guile User Mailing List

2008/9/18  <dsmich@roadrunner.com>:
> ---- Ishan Arora <ishanarora@gmail.com> wrote:
>> Hi,
>>
>> Thanks for the reply. I tried system. It calls the code synchronously, and
>> returns a number for success or failure of the command. Is there a way such
>> that the stdout output of the command is returned as a string? Thanks again.
>
> Try open-input-pipe in the (ice-9 popen) module.

That is indeed the best way, with an up to date Guile.  In case you're
stuck with an old one (1.6.x, I think) where open-input-pipe isn't
reliable, you can work around that by doing something like this:

      (system "your-command-here > temp-file.txt")
      (with-input-from-file "temp-file.txt" read-line)

  Neil




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X11 bindings and shell bindings
  2008-09-18 15:10   ` Ishan Arora
@ 2008-09-18 17:01     ` JonWilson
  0 siblings, 0 replies; 11+ messages in thread
From: JonWilson @ 2008-09-18 17:01 UTC (permalink / raw)
  To: Ishan Arora; +Cc: Guile User Mailing List

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Oh right.  My apologies for not answering the question you asked...

Ishan Arora wrote:
> Hi,
> 
> Thanks for the reply. I tried system. It calls the code synchronously, and
> returns a number for success or failure of the command. Is there a way such
> that the stdout output of the command is returned as a string? Thanks again.
> 
> Regards,
> Ishan
> 
> On Thu, Sep 18, 2008 at 7:22 PM, Jon Wilson <jsw@wilsonjc.us> wrote:
> 
>> Hi Ishan,
>>  * There are guile bindings for gtk and for gnome; I don't know of any
>> other X11 bindings.
>>
>>  * Try (system "ls -l").  Look it up in the POSIX section in the manual.
>> Regards,
>> Jon
>>
>>
>> Ishan Arora wrote:
>>
>>> Hi,
>>>
>>> Is there a procedure to get mouse position. And is there a procedure to
>>> synchronously run a shell code and return the output as a String. Thanks.
>>>
>>> Regards,
>>> Ishan
>>>
>>
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iEYEARECAAYFAkjSiYAACgkQ3y6HU3bfjw78iACfXofmVnRI0XqL09z01iiXARDy
R+sAn34o4jOWobSeRHL0szNhoYm7g7Kp
=TdCJ
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X11 bindings and shell bindings
  2008-09-18 12:38 X11 bindings and shell bindings Ishan Arora
  2008-09-18 13:52 ` Jon Wilson
@ 2008-09-18 17:16 ` Paul Emsley
  2008-09-18 18:43 ` Andy Wingo
  2 siblings, 0 replies; 11+ messages in thread
From: Paul Emsley @ 2008-09-18 17:16 UTC (permalink / raw)
  To: guile-user

Ishan Arora wrote:
> Hi,
>
> Is there a procedure to get mouse position.
I guess there may be a way via X11, but it is not clear to me.  What you 
might want to be doing is knowing the coordinates of a click in a 
canvas, which is not the same thing (and easier).


> And is there a procedure to synchronously run a shell code and return 
> the output as a String. Thanks.
;; code from thi <ttn at mingle.glug.org>
;;
;; run command and put the output into a string and return
;; it. (c.f. @code{run-command/strings})
(define (shell-command-to-string cmd)
  (with-output-to-string
    (lambda ()
      (let ((in-port (open-input-pipe cmd)))
    (let loop ((line (read-line in-port 'concat)))
      (or (eof-object? line)
          (begin
        (display line)
        (loop (read-line in-port 'concat)))))))))


Paul.






^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X11 bindings and shell bindings
  2008-09-18 12:38 X11 bindings and shell bindings Ishan Arora
  2008-09-18 13:52 ` Jon Wilson
  2008-09-18 17:16 ` Paul Emsley
@ 2008-09-18 18:43 ` Andy Wingo
  2008-09-18 19:37   ` Linas Vepstas
  2 siblings, 1 reply; 11+ messages in thread
From: Andy Wingo @ 2008-09-18 18:43 UTC (permalink / raw)
  To: Ishan Arora; +Cc: Guile User Mailing List

On Thu 18 Sep 2008 14:38, "Ishan Arora" <ishanarora@gmail.com> writes:

> Is there a procedure to get mouse position.

No, but it's relatively easy to write a minimal set of Xlib bindings,
binding only the functions you need. Griddy has some bindings:

  bzr get http://wingolog.org/bzr/griddy

Andy
-- 
http://wingolog.org/




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X11 bindings and shell bindings
  2008-09-18 18:43 ` Andy Wingo
@ 2008-09-18 19:37   ` Linas Vepstas
  2008-09-18 21:09     ` Andy Wingo
  0 siblings, 1 reply; 11+ messages in thread
From: Linas Vepstas @ 2008-09-18 19:37 UTC (permalink / raw)
  To: Andy Wingo; +Cc: Guile User Mailing List

2008/9/18 Andy Wingo <wingo@pobox.com>:
> On Thu 18 Sep 2008 14:38, "Ishan Arora" <ishanarora@gmail.com> writes:
>
>> Is there a procedure to get mouse position.
>
> No, but it's relatively easy to write a minimal set of Xlib bindings,
> binding only the functions you need. Griddy has some bindings:

Its nuts to work with X11 directly. Its not meant for that ...
its like trying to call the linux kernel directly using syscalls
and assembly language, bypassing the C library.

Among other things, X11 will give you coords relative to the
upper left of the screen, which is almost surely not what
you want -- you want coords relative to a window, the
window in which your app will be drawing.

Use gtk or gnome or kde. Open a canvas. You can get
coords that way.

--linas




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: X11 bindings and shell bindings
  2008-09-18 19:37   ` Linas Vepstas
@ 2008-09-18 21:09     ` Andy Wingo
  0 siblings, 0 replies; 11+ messages in thread
From: Andy Wingo @ 2008-09-18 21:09 UTC (permalink / raw)
  To: linasvepstas; +Cc: Guile User Mailing List

Hello!

On Thu 18 Sep 2008 21:37, "Linas Vepstas" <linasvepstas@gmail.com> writes:

> 2008/9/18 Andy Wingo <wingo@pobox.com>:
>> On Thu 18 Sep 2008 14:38, "Ishan Arora" <ishanarora@gmail.com> writes:
>>
>>> Is there a procedure to get mouse position.
>>
>> No, but it's relatively easy to write a minimal set of Xlib bindings,
>> binding only the functions you need. Griddy has some bindings:
>
> Its nuts to work with X11 directly. Its not meant for that ...

You might be right in certain cases. However there are cases in which
you need X, and Griddy is a window manager... Suffice it to say I've had
to learn much more about X than I ever wanted to ;)

Dunno what the OP wants to do tho.

Cheers,

Andy
-- 
http://wingolog.org/




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-09-18 21:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-18 12:38 X11 bindings and shell bindings Ishan Arora
2008-09-18 13:52 ` Jon Wilson
2008-09-18 15:10   ` Ishan Arora
2008-09-18 17:01     ` JonWilson
2008-09-18 17:16 ` Paul Emsley
2008-09-18 18:43 ` Andy Wingo
2008-09-18 19:37   ` Linas Vepstas
2008-09-18 21:09     ` Andy Wingo
  -- strict thread matches above, loose matches on Subject: below --
2008-09-18 16:08 dsmich
2008-09-18 16:58 ` Neil Jerram
     [not found] <cmu-lmtpd-23352-1221754132-4@mail-imap1.uio.no>
2008-09-18 16:54 ` Kjetil S. Matheussen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).