Re: [Factor-talk] Reading clipboard in a Factor script ?

2016-11-10 Thread Georg Simon
Using

[ main 0 exit ] with-ui

where ```main``` is my application I get what I need.

Thank you

Am Thu, 10 Nov 2016 16:35:43 +0100
schrieb Jon Harper :

> You need to initialize the UI. the with-ui (
> http://docs.factorcode.org/content/word-with-ui%2Cui.html ) word does
> that. Note that with-ui setups an event loop and doesn't finish until
> the event-loop exists (when you close the last window), so you can
> call exit directly to force it to exit.
> Maybe you could minimize the UI initialization and not setup the
> event-loop by looking at the with-ui word implementation and calling
> the correct words, but that would be harder.
> 
> Jon
> 
> On Thu, Nov 10, 2016 at 4:00 PM, Georg Simon 
> wrote:
> 
>  [...]  


--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Reading clipboard in a Factor script ?

2016-11-10 Thread Jon Harper
It should work with my suggestion, I had tested it on ubuntu :

#! /home/jon/factor/factor

USING: ui.clipboards ui io namespaces kernel system ;

 "B4: " print clipboard get [ clipboard-contents print ] when* flush
[ "AF: "  print clipboard get clipboard-contents print flush 0
exit ] with-ui

Cheers

Jon

On Thu, Nov 10, 2016 at 4:55 PM, Georg Simon  wrote:

> Am Thu, 10 Nov 2016 07:32:52 -0800
> schrieb John Benediktsson :
>
> My platform is Linux. Trying
> ---
> USING:
> namespaces prettyprint ui.backend.gtk ui.clipboards
> ;
> init-clipboard clipboard get clipboard-contents .
> ---
> I get
> ---
> (process:6199): Gtk-CRITICAL **: IA__gtk_clipboard_get_for_display:
> assertion 'display != NULL' failed
>
> (process:6199): Gtk-CRITICAL **: IA__gtk_clipboard_get_for_display:
> assertion 'display != NULL' failed
>
> (process:6199): Gtk-CRITICAL **: IA__gtk_clipboard_wait_for_text:
> assertion 'clipboard != NULL' failed f
> ---
> Will try Jon's suggestion now.
>
> > Right now they are commingled and clipboard use typically requires
> > the UI to be initialized.
> >
> > But this works, for example on Mac as a script:
> >
> > USING: io namespaces ui.backend.cocoa ui.clipboards ;
> >
> > init-clipboard clipboard get clipboard-contents .
> >
> > What platform are you trying to make this work on?
>
> 
> --
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Reading clipboard in a Factor script ?

2016-11-10 Thread Georg Simon
Am Thu, 10 Nov 2016 07:32:52 -0800
schrieb John Benediktsson :

My platform is Linux. Trying
---
USING:
namespaces prettyprint ui.backend.gtk ui.clipboards
;
init-clipboard clipboard get clipboard-contents .
---
I get
---
(process:6199): Gtk-CRITICAL **: IA__gtk_clipboard_get_for_display:
assertion 'display != NULL' failed

(process:6199): Gtk-CRITICAL **: IA__gtk_clipboard_get_for_display:
assertion 'display != NULL' failed

(process:6199): Gtk-CRITICAL **: IA__gtk_clipboard_wait_for_text:
assertion 'clipboard != NULL' failed f
---
Will try Jon's suggestion now.

> Right now they are commingled and clipboard use typically requires
> the UI to be initialized.
> 
> But this works, for example on Mac as a script:
> 
> USING: io namespaces ui.backend.cocoa ui.clipboards ;
> 
> init-clipboard clipboard get clipboard-contents .
> 
> What platform are you trying to make this work on?

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Reading clipboard in a Factor script ?

2016-11-10 Thread Jon Harper
You need to initialize the UI. the with-ui (
http://docs.factorcode.org/content/word-with-ui%2Cui.html ) word does that.
Note that with-ui setups an event loop and doesn't finish until the
event-loop exists (when you close the last window), so you can call exit
directly to force it to exit.
Maybe you could minimize the UI initialization and not setup the event-loop
by looking at the with-ui word implementation and calling the correct
words, but that would be harder.

Jon

On Thu, Nov 10, 2016 at 4:00 PM, Georg Simon  wrote:

> In the Listener
>
> ```clipboard get clipboard-contents```
>
> leaves the clipboard content on the stack.
>
> In a Factor script I get an error. Because UI is not running I think.
>
> Is there a way to read the clipboard content in a Factor script ?
>
> Georg
>
> 
> --
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Reading clipboard in a Factor script ?

2016-11-10 Thread John Benediktsson
Right now they are commingled and clipboard use typically requires the UI
to be initialized.

But this works, for example on Mac as a script:

USING: io namespaces ui.backend.cocoa ui.clipboards ;

init-clipboard clipboard get clipboard-contents .

What platform are you trying to make this work on?



On Thu, Nov 10, 2016 at 7:00 AM, Georg Simon  wrote:

> In the Listener
>
> ```clipboard get clipboard-contents```
>
> leaves the clipboard content on the stack.
>
> In a Factor script I get an error. Because UI is not running I think.
>
> Is there a way to read the clipboard content in a Factor script ?
>
> Georg
>
> 
> --
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> ___
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Reading clipboard in a Factor script ?

2016-11-10 Thread Georg Simon
In the Listener

```clipboard get clipboard-contents```

leaves the clipboard content on the stack.

In a Factor script I get an error. Because UI is not running I think.

Is there a way to read the clipboard content in a Factor script ?

Georg

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Questions of a newcomer

2016-11-10 Thread petern
Hi Chris,

On 2016-11-10 11:03, Chris Double wrote:
> With that I see what you are seeing. Both numbers print out after the
> last thread finishes. It looks like it's buffering in this case. If I
> add a 'flush' then I see them printed after 5 seconds then 10 seconds:
> 
> -8<-
> USING: fry prettyprint kernel io namespaces sequences io.launcher
> io.directories io.encodings.utf8 io.files io.files.info io.pathnames
> concurrency.messaging threads math tools.threads accessors calendar ;
> IN: script
> 
> self '[ "bash -c \"sleep 10\"" run-process drop 1 _ send ] "1" spawn
> self '[ "bash -c \"sleep 5\"" run-process drop 2 _ send ] "2" spawn
> receive . flush
> receive . flush
> clear
> -8<-
> 
> Could this fix your issue?

Indeed that's it. Thanks for your help, I should be able to finish it 
from this point :)

-- 

   Peter Nagy


--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Questions of a newcomer

2016-11-10 Thread Chris Double
On Thu, Nov 10, 2016 at 10:00 PM,   wrote:
> Any
> more ideas why? Is run-process blocking everyone? Is there some FFI call
> like you mentioned? Where could I start to debug this on my own?

The only difference to what you are doing and what my test did was
you're running as a script. So I tried this:

-8<-
USING: fry prettyprint kernel io namespaces sequences io.launcher
io.directories io.encodings.utf8 io.files io.files.info io.pathnames
concurrency.messaging threads math tools.threads accessors calendar ;
IN: script

self '[ "bash -c \"sleep 10\"" run-process drop 1 _ send ] "1" spawn
self '[ "bash -c \"sleep 5\"" run-process drop 2 _ send ] "2" spawn
receive .
receive .
clear
-8<-


With that I see what you are seeing. Both numbers print out after the
last thread finishes. It looks like it's buffering in this case. If I
add a 'flush' then I see them printed after 5 seconds then 10 seconds:

-8<-
USING: fry prettyprint kernel io namespaces sequences io.launcher
io.directories io.encodings.utf8 io.files io.files.info io.pathnames
concurrency.messaging threads math tools.threads accessors calendar ;
IN: script

self '[ "bash -c \"sleep 10\"" run-process drop 1 _ send ] "1" spawn
self '[ "bash -c \"sleep 5\"" run-process drop 2 _ send ] "2" spawn
receive . flush
receive . flush
clear
-8<-

Could this fix your issue?

-- 
http://bluishcoder.co.nz

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Distributed Messaging Fixes

2016-11-10 Thread Chris Double
I was working through my factor-articles document [1] to update with a
recent Factor version and hit some issues with the distributed
messaging functionality. I've done a pull request here:

https://github.com/factor/factor/pull/1744

The issue was that for distributed messaging it really requires a
global server to exist to allow receiving messages from other nodes.
Past changes moved to having the server created as a threaded server
stored in a namespace. I've reverted back to a global and adjusted the
test.

The test uses a hard coded port - I couldn't work out how to do a
random port with a threaded server.

[1] https://bluishcoder.co.nz/factor-articles.pdf

-- 
http://bluishcoder.co.nz

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Questions of a newcomer

2016-11-10 Thread petern
Hi John,

On 2016-11-08 22:38, John Benediktsson wrote:
> There are a lot of ways to solve the problem, but without knowing more
> about what you're looking for, I'll just leave these here.

I spent the last half hour reading your code, running it and examining 
the vocabularies. Very helpful, thank you for your time!

-- 

   Peter Nagy


--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Questions of a newcomer

2016-11-10 Thread petern
Hi Chris,

On 2016-11-08 23:58, Chris Double wrote:
> I tried to duplicate the basics of your code with the following:
> 
> self '[ "bash -c \"sleep 10\"" run-process drop 1 _ send ] "1" spawn
> self '[ "bash -c \"sleep 5\"" run-process drop 2 _ send ] "2" spawn
> receive
> 
> This will spawn two threads that run a bash 'sleep'. The 'receive'
> blocks until the shortest sleep finishes and if you run another
> 'receive' then it blocks until the longer one completes. This should
> be what your code does too. Are you sure the git commands aren't all
> completing at the same time?

After a simple test you are right, the threads send the message at the 
same time. I'm still left wondering why. There's e.g. 10 threads running 
a `(thread on stack here) "git pull" run-process "pulled" send`. Now the 
git output comes to stdout intermixed and only after all threads 
finished with the run-process do they get time to send the message. Any 
more ideas why? Is run-process blocking everyone? Is there some FFI call 
like you mentioned? Where could I start to debug this on my own?

> 
> Note the use of the 'fry' quotation to avoid having to curry and swap
> later to pass the 'self' around btw.

Yes looks much cleaner, thanks. I am avoiding fry and locals and similar 
helpers for now to train the shuffling/composing more.

Thank you for your answer, much appreciated.

-- 

   Peter Nagy


--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk