Re: [CM] Snd: getting a prompt on stdout

2016-03-20 Thread bil

That output goes through string_to_stdout in
snd-xen.c, I think (it's watched for via
g_io_channel_unix_get_fd in snd-gmain.c).
Snd used to have a print-hook for stuff like
this, but it didn't get used for years, so
I removed it.  I could add a hook to
string_to_stdout to add a prompt, if you like.
I think you could change string_to_stdout
to

 fprintf(stdout, "%s\n> ", msg);

or something like that to get a prompt,
but I haven't tried it.

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] Snd: getting a prompt on stdout

2016-03-19 Thread Kjetil Matheussen
I think it would be a good idea to add "s7webserver", which is found in s7,
to snd.
(or something similar)  Using s7webserver, you have two programs, snd and,
s7repl.
These two programs communicate via web sockets.

It has the following advantages when using a(n) snd  repl:
* You don't have to start snd inside emacs, and you don't have to restart
the repl
   when you restart snd. You can start and stop the repl at any time, and
you can start
   and stop snd at any time.
* Simple to set prompt
* You can control snd from another machine or from a web browser. In the
s7webserver directory
   there is also a javascript program (in addition to the repl program),
which is started by
   loading "s7webserver_repl.html" in a web browser, and then you have a(n)
snd repl
   in a web browser.

Radium has used s7webserver for a long time like this, so it should be
stable.

I just made a couple of quick changes to snd to support this:
http://folk.uio.no/~ksvalast/xen.c.diff
http://folk.uio.no/ksvalast/makefile.diff

Recipe (untested):

cd snd
./configure
wget http://folk.uio.no/~ksvalast/xen.c.diff
wget http://folk.uio.no/ksvalast/makefile.diff
patch -p1 
make
cd ..
make -j8


On Fri, Mar 18, 2016 at 2:11 PM,  wrote:

> I added stdin-prompt to Snd, and tried it out briefly in the gtk version:
>
> /home/bil/cl/ ./snd
> (+ 1 2)
> 3
> (set! (stdin-prompt) ">>>")
> ">>>"
>
>> (+ 1 2)

>>> 3
>
>> (exit)

>>>
> I haven't yet tried it in emacs -- please let me know
> of any problems.
>
>
> (The sourceforge cvs version may be messed up --
> I'm getting "transport endpoint" errors which I'll
> need to track down).
>
>
> ___
> Cmdist mailing list
> Cmdist@ccrma.stanford.edu
> https://cm-mail.stanford.edu/mailman/listinfo/cmdist
>
>
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Snd: getting a prompt on stdout

2016-03-19 Thread Kjetil Matheussen
Great. The code I posted will only work with gtk though.
In non-glib programs I think one has to
call QCoreApplication::processEvents()
at regular intervals for it to work. (At least I think it is enough to call
processEvents(), I haven't tried)


On Fri, Mar 18, 2016 at 5:42 PM,  wrote:

> I'll add the s7webserver directory to Snd.
> I'm still stuck at sourceforge, so this may
> take a day or two (the docs say if the cvs unlock
> command fails, "wait and try again later"...)
>
>
>
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Snd: getting a prompt on stdout

2016-03-19 Thread Kjetil Matheussen
On Fri, Mar 18, 2016 at 2:34 PM, Kjetil Matheussen  wrote:

> I just made a couple of quick changes to snd to support this:
> http://folk.uio.no/~ksvalast/xen.c.diff
> http://folk.uio.no/ksvalast/makefile.diff
>
> Recipe (untested):
>
> cd snd
> ./configure
> wget http://folk.uio.no/~ksvalast/xen.c.diff
> wget http://folk.uio.no/ksvalast/makefile.diff
> patch -p1  patch -p1  cp -a ../s7/s7webserver .
> cd s7webserver
> 
> make
> cd ..
> make -j8
>
>
Forgot one modified file:

wget http://folk.uio.no/ksvalast/s7webserver.cpp.diff
cd s7webserver
patch -p1 ___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Snd: getting a prompt on stdout

2016-03-19 Thread bil

I'll add the s7webserver directory to Snd.
I'm still stuck at sourceforge, so this may
take a day or two (the docs say if the cvs unlock
command fails, "wait and try again later"...)

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



[CM] Snd: getting a prompt on stdout

2016-03-19 Thread Daniel Lopez

Hi,

Is there a way to get a ready prompt on the stdin/stdout interface? The 
(set! (listener-prompt) ...) customization only seems to affect the 
prompt in the listener, inside the actual graphical window.


At the console though, while I can indeed enter things and see the 
results printed back out, the cursor always finally goes back to the 
start of a new line.


I'm trying to improve the Emacs mode and it would help to see a prompt 
for the next command to be able to detect the end of multi-line output.


(I'm using the Gtk version. I guess this might work with the no GUI 
version but I would like to have the GUI around at the same time to 
visualize waves etc.)


(I briefly wondered about using maybe:
  (hook-push read-hook (lambda (hook) (snd-print '>)))
 to manually print the arrow after each command, but then that doesn't 
seem to be working to print anything extra out in either the listener or 
console, and I suspect it wouldn't be quite right in other ways, even if 
it did.)


Thanks,
Daniel
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] Snd: getting a prompt on stdout

2016-03-19 Thread bil
I added stdin-prompt to Snd, and tried it out briefly in the gtk 
version:


/home/bil/cl/ ./snd
(+ 1 2)
3
(set! (stdin-prompt) ">>>")
">>>"

(+ 1 2)

3

(exit)


I haven't yet tried it in emacs -- please let me know
of any problems.


(The sourceforge cvs version may be messed up --
I'm getting "transport endpoint" errors which I'll
need to track down).

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] Snd: getting a prompt on stdout

2016-03-19 Thread Daniel Lopez

On 18/03/16 13:11, b...@ccrma.stanford.edu wrote:

I added stdin-prompt to Snd, and tried it out briefly in the gtk version:

/home/bil/cl/ ./snd
(+ 1 2)
3
(set! (stdin-prompt) ">>>")
">>>"

(+ 1 2)

3

(exit)


I haven't yet tried it in emacs -- please let me know
of any problems.


(The sourceforge cvs version may be messed up --
I'm getting "transport endpoint" errors which I'll
need to track down).





Works great. Thanks very much, also for doing it so fast!

Daniel

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] Snd: getting a prompt on stdout

2016-03-18 Thread Daniel Lopez

On 17/03/16 11:47, b...@ccrma.stanford.edu wrote:

That output goes through string_to_stdout in
snd-xen.c, I think (it's watched for via
g_io_channel_unix_get_fd in snd-gmain.c).
Snd used to have a print-hook for stuff like
this, but it didn't get used for years, so
I removed it.  I could add a hook to
string_to_stdout to add a prompt, if you like.
I think you could change string_to_stdout
to

  fprintf(stdout, "%s\n> ", msg);

or something like that to get a prompt,
but I haven't tried it.





Thanks Bill - I got the desired effect by editing snd_eval_stdin_str:

void snd_eval_stdin_str(const char *buf)
{
  /* we may get incomplete expressions here */
  /*   (Ilisp always sends a complete expression, but it may be broken 
into two or more pieces from read's point of view) */


  char *str = NULL;
  if (mus_strlen(buf) == 0) return;

  str = stdin_check_for_full_expression(buf);
  if (str)
{
  Xen result;
  int loc;

  redirect_everything_to(string_to_stdout, NULL);
  result = snd_catch_any(eval_str_wrapper, (void *)str, str);
  redirect_everything_to(NULL, NULL);

  loc = snd_protect(result);
  stdin_free_str();

  str = gl_print(result);
  string_to_stdout(str, NULL);

  /* DANIEL: Next two lines added */
  fprintf(stdout, ">>> ");
  fflush(stdout);

  if (str) free(str);
  snd_unprotect_at(loc);
}
}

Putting it here makes the new prompt appear only once, after the result 
and after any errors/warnings/snd-print statements that got printed out 
via the redirect_everything_to/snd_catch_any calls.


The fflush() was necessary otherwise the new prompt it doesn't appear 
until after the next console read (that confused me for a while, I can 
tell you).


Also, to make the prompt appear once at program start, I added the same 
two lines (fprintf and fflush) to g_xen_initialize(), right after where 
it calls g_init_listener(). I suppose a more uniform solution would be 
to make a new 'g_init_stdin()' function consisting of the new lines and 
call that instead.


I was going to make a patch file of these changes to proudly present to 
you but there are some other things to round out which I don't quite 
have the tenacity to fully do right now - when starting up with 
-nostdin, my hacked-in prompt spills onto stdout twice (once from 
g_xen_initialize() and once from snd_eval_stdin_str() being called once 
for some reason). And, it would also make sense if there was a built-in 
'stdin-prompt' variable, similar to 'listener-prompt', for customizing 
this. It would default to an empty string, not to disrupt the existing 
default behaviour. I attempted this but my naive copy-pasting didn't 
quite take me 100% of the way there, and to be honest my Scheme aptitude 
is still a bit weak for this kind of thing. I might have another go at a 
later date, unless you reckon these are jolly good ideas and get in 
there first!


Daniel

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist