Hide and disable REPL

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Hide and disable REPL

David Anthoff

Hi,

 

is there a way to switch off the REPL and then on again, from a task?

 

Specifically, I want to start a julia instance and pass a script in with the –L parameter that will open a socket, listen for connections and the process messages from that socket. This server listening code is all wrapped in @async macro calls. So when I start things this way, julia shows the REPL and at the same time listens for incoming messages. I can use the REPL etc. This is exactly what I want.

 

But when I receive a message, I want to temporarily switch the REPL off, i.e. it should visually disappear while I process that message, and then I want to switch it back on once I’m done processing that message.

 

Can that be done somehow?

 

Thanks,

David

 

--

David Anthoff

University of California, Berkeley

 

http://www.david-anthoff.com

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hide and disable REPL

David Anthoff
Bump, it would be great if someone could point me to some approach for this. We are getting an integrated terminal ready in VS Code, and this is the one piece missing right now.

Thanks,
David

On Thursday, June 23, 2016 at 5:00:22 PM UTC-7, David Anthoff wrote:

Hi,

 

is there a way to switch off the REPL and then on again, from a task?

 

Specifically, I want to start a julia instance and pass a script in with the –L parameter that will open a socket, listen for connections and the process messages from that socket. This server listening code is all wrapped in @async macro calls. So when I start things this way, julia shows the REPL and at the same time listens for incoming messages. I can use the REPL etc. This is exactly what I want.

 

But when I receive a message, I want to temporarily switch the REPL off, i.e. it should visually disappear while I process that message, and then I want to switch it back on once I’m done processing that message.

 

Can that be done somehow?

 

Thanks,

David

 

--

David Anthoff

University of California, Berkeley

 

<a href="http://www.david-anthoff.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.david-anthoff.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHPDijM7QgcCRbDWt_-VR5r_HnDGg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.david-anthoff.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHPDijM7QgcCRbDWt_-VR5r_HnDGg&#39;;return true;">http://www.david-anthoff.com

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hide and disable REPL

Isaiah Norton
Can you explain the setup further -- Where is the REPL running? How are you interacting with it? If I take "I want to temporarily switch the REPL off, i.e. it should visually disappear" literally then it seems like a strange thing to do, so I may be missing something

If you *do* want to hide the terminal window (if any) the REPL is (may be) running in, that's going to be very hard to do generally and across platforms (on Windows under Console you can use GetActiveWindow or GetActiveConsole, but on real pty platforms the process doesn't necessarily know anything about the terminal it is connected to beyond termcap and i/o).

On Thu, Nov 3, 2016 at 7:41 PM, <[hidden email]> wrote:
Bump, it would be great if someone could point me to some approach for this. We are getting an integrated terminal ready in VS Code, and this is the one piece missing right now.

Thanks,
David


On Thursday, June 23, 2016 at 5:00:22 PM UTC-7, David Anthoff wrote:

Hi,

 

is there a way to switch off the REPL and then on again, from a task?

 

Specifically, I want to start a julia instance and pass a script in with the –L parameter that will open a socket, listen for connections and the process messages from that socket. This server listening code is all wrapped in @async macro calls. So when I start things this way, julia shows the REPL and at the same time listens for incoming messages. I can use the REPL etc. This is exactly what I want.

 

But when I receive a message, I want to temporarily switch the REPL off, i.e. it should visually disappear while I process that message, and then I want to switch it back on once I’m done processing that message.

 

Can that be done somehow?

 

Thanks,

David

 

--

David Anthoff

University of California, Berkeley

 

http://www.david-anthoff.com

 


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hide and disable REPL

David Anthoff

Ah, I should have been clearer. I just want to hide the prompt temporarily.

 

The complete setup is slightly more complicated, but you can imagine just the following: start a normal julia REPL. Then include a file that will start a server listening on some socket. This server is all async, so as soon as the server is started, the prompt appears again and one can use this REPL window in the normal way. Now some other process connects to the socket, and sends some code that this server will eval. Before the server evals this code, I would like it to switch off the prompt, then eval the code, then switch the prompt on again.

 

The setup is that VS Code starts a new julia process, and shows the normal julia REPL in a terminal emulation within VS Code. This instance is running the server I just described. The julia VS Code extension that will send code to this REPL window if a user hits Ctrl+Enter in any of the open editor windows.

 

Not sure this is much clearer, let me know if you need more info!

 

Best,

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Isaiah Norton
Sent: Thursday, November 3, 2016 8:38 PM
To: [hidden email]
Subject: Re: [julia-users] Re: Hide and disable REPL

 

Can you explain the setup further -- Where is the REPL running? How are you interacting with it? If I take "I want to temporarily switch the REPL off, i.e. it should visually disappear" literally then it seems like a strange thing to do, so I may be missing something

 

If you *do* want to hide the terminal window (if any) the REPL is (may be) running in, that's going to be very hard to do generally and across platforms (on Windows under Console you can use GetActiveWindow or GetActiveConsole, but on real pty platforms the process doesn't necessarily know anything about the terminal it is connected to beyond termcap and i/o).

 

On Thu, Nov 3, 2016 at 7:41 PM, <[hidden email]> wrote:

Bump, it would be great if someone could point me to some approach for this. We are getting an integrated terminal ready in VS Code, and this is the one piece missing right now.

 

Thanks,

David



On Thursday, June 23, 2016 at 5:00:22 PM UTC-7, David Anthoff wrote:

Hi,

 

is there a way to switch off the REPL and then on again, from a task?

 

Specifically, I want to start a julia instance and pass a script in with the –L parameter that will open a socket, listen for connections and the process messages from that socket. This server listening code is all wrapped in @async macro calls. So when I start things this way, julia shows the REPL and at the same time listens for incoming messages. I can use the REPL etc. This is exactly what I want.

 

But when I receive a message, I want to temporarily switch the REPL off, i.e. it should visually disappear while I process that message, and then I want to switch it back on once I’m done processing that message.

 

Can that be done somehow?

 

Thanks,

David

 

--

David Anthoff

University of California, Berkeley

 

http://www.david-anthoff.com

 

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hide and disable REPL

David Anthoff
Bump, any help would really be appreciated. We are very, very close to releasing an amazing new version of the julia extension for VS Code, this is pretty much the only thing holding that release back right now.

Thanks,
David

On Friday, November 4, 2016 at 10:28:16 AM UTC-7, David Anthoff wrote:

Ah, I should have been clearer. I just want to hide the prompt temporarily.

 

The complete setup is slightly more complicated, but you can imagine just the following: start a normal julia REPL. Then include a file that will start a server listening on some socket. This server is all async, so as soon as the server is started, the prompt appears again and one can use this REPL window in the normal way. Now some other process connects to the socket, and sends some code that this server will eval. Before the server evals this code, I would like it to switch off the prompt, then eval the code, then switch the prompt on again.

 

The setup is that VS Code starts a new julia process, and shows the normal julia REPL in a terminal emulation within VS Code. This instance is running the server I just described. The julia VS Code extension that will send code to this REPL window if a user hits Ctrl+Enter in any of the open editor windows.

 

Not sure this is much clearer, let me know if you need more info!

 

Best,

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Isaiah Norton
Sent: Thursday, November 3, 2016 8:38 PM
To: [hidden email]
Subject: Re: [julia-users] Re: Hide and disable REPL

 

Can you explain the setup further -- Where is the REPL running? How are you interacting with it? If I take "I want to temporarily switch the REPL off, i.e. it should visually disappear" literally then it seems like a strange thing to do, so I may be missing something

 

If you *do* want to hide the terminal window (if any) the REPL is (may be) running in, that's going to be very hard to do generally and across platforms (on Windows under Console you can use GetActiveWindow or GetActiveConsole, but on real pty platforms the process doesn't necessarily know anything about the terminal it is connected to beyond termcap and i/o).

 

On Thu, Nov 3, 2016 at 7:41 PM, <[hidden email]> wrote:

Bump, it would be great if someone could point me to some approach for this. We are getting an integrated terminal ready in VS Code, and this is the one piece missing right now.

 

Thanks,

David



On Thursday, June 23, 2016 at 5:00:22 PM UTC-7, David Anthoff wrote:

Hi,

 

is there a way to switch off the REPL and then on again, from a task?

 

Specifically, I want to start a julia instance and pass a script in with the –L parameter that will open a socket, listen for connections and the process messages from that socket. This server listening code is all wrapped in @async macro calls. So when I start things this way, julia shows the REPL and at the same time listens for incoming messages. I can use the REPL etc. This is exactly what I want.

 

But when I receive a message, I want to temporarily switch the REPL off, i.e. it should visually disappear while I process that message, and then I want to switch it back on once I’m done processing that message.

 

Can that be done somehow?

 

Thanks,

David

 

--

David Anthoff

University of California, Berkeley

 

<a href="http://www.david-anthoff.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.david-anthoff.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHPDijM7QgcCRbDWt_-VR5r_HnDGg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.david-anthoff.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHPDijM7QgcCRbDWt_-VR5r_HnDGg&#39;;return true;">http://www.david-anthoff.com

 

 

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hide and disable REPL

c.d. mclean

do you know of there are analogs of your process flow
in other VS Code extensions, say the python extension
for VS Code ... ?

it seems that perhaps another VS Code implementation
would have had to also cross this bridge ... ?

~ cdm



On Monday, November 14, 2016 at 1:27:18 PM UTC-8, [hidden email] wrote:
Bump, any help would really be appreciated. We are very, very close to releasing an amazing new version of the julia extension for VS Code, this is pretty much the only thing holding that release back right now.

Thanks,
David

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hide and disable REPL

Steven G. Johnson
In reply to this post by David Anthoff


On Friday, November 4, 2016 at 1:28:16 PM UTC-4, David Anthoff wrote:


The complete setup is slightly more complicated, but you can imagine just the following: start a normal julia REPL. Then include a file that will start a server listening on some socket. This server is all async, so as soon as the server is started, the prompt appears again and one can use this REPL window in the normal way. Now some other process connects to the socket, and sends some code that this server will eval. Before the server evals this code, I would like it to switch off the prompt, then eval the code, then switch the prompt on again.


Base.Terminals.clear(Base.active_repl.t); sleep(10)

will clear the REPL window (including prompt) for 10 seconds.  Instead of sleep(10), you can do wait(c) where c is a Condition variable that gets notified by the server thread once it is ready.  See http://docs.julialang.org/en/latest/stdlib/parallel/?highlight=wait
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hide and disable REPL

David Anthoff
In reply to this post by c.d. mclean

I think most of them just have the code pasted into the REPL. That would work for us as well, but then we can’t do things like eval code in the context of a specific module.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of cdm
Sent: Monday, November 14, 2016 6:27 PM
To: julia-users <[hidden email]>
Subject: Re: [julia-users] Re: Hide and disable REPL

 

 

do you know of there are analogs of your process flow

in other VS Code extensions, say the python extension

for VS Code ... ?

 

it seems that perhaps another VS Code implementation

would have had to also cross this bridge ... ?

 

~ cdm

 



On Monday, November 14, 2016 at 1:27:18 PM UTC-8, [hidden email] wrote:

Bump, any help would really be appreciated. We are very, very close to releasing an amazing new version of the julia extension for VS Code, this is pretty much the only thing holding that release back right now.

 

Thanks,

David

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hide and disable REPL

David Anthoff
In reply to this post by Steven G. Johnson

That deletes everything, but really I just want to hide the current prompt. So say this is how the console looks:

````

julia> println(5)

5

julia>function foo(x)

   println(x)

````

So in this case the users is in the middle of entering something new into the REPL (i.e. the definition of foo). Assume that at this point my background task receives a message. I then want to be able to delete line 3+5, and position the cursor on column 1 line 3. Then I’ll execute the code that was sent to the server. Once that is finished, I want to print line 3+4, as it was before I hid the current prompt, again, starting at whatever the current cursor position is.

 

For example, say the background task received some code that printed “Foooooo” to the console, then I want the console to look like this, immediately after that code was executed:

````

julia> println(5)

5

Foooooo

julia>function foo(x)

   println(x)

````

I.e. the user could continue editing the stuff that he/she was working on before the background task briefly took over.

 

Thanks,

David

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Steven G. Johnson
Sent: Tuesday, November 15, 2016 5:29 AM
To: julia-users <[hidden email]>
Subject: Re: [julia-users] Re: Hide and disable REPL

 



On Friday, November 4, 2016 at 1:28:16 PM UTC-4, David Anthoff wrote:

 

The complete setup is slightly more complicated, but you can imagine just the following: start a normal julia REPL. Then include a file that will start a server listening on some socket. This server is all async, so as soon as the server is started, the prompt appears again and one can use this REPL window in the normal way. Now some other process connects to the socket, and sends some code that this server will eval. Before the server evals this code, I would like it to switch off the prompt, then eval the code, then switch the prompt on again.

 

Base.Terminals.clear(Base.active_repl.t); sleep(10)

 

will clear the REPL window (including prompt) for 10 seconds.  Instead of sleep(10), you can do wait(c) where c is a Condition variable that gets notified by the server thread once it is ready.  See http://docs.julialang.org/en/latest/stdlib/parallel/?highlight=wait

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hide and disable REPL

c.d. mclean

it seems like some of the client.jl code

   https://github.com/JuliaLang/julia/blob/master/base/client.jl


should provide the foundation ...


maybe something around active_repl_backend or some active_repl
switching.

also from code comments:

atreplinit(f)
Register a one-argument function to be called before the REPL interface is initialized in
interactive sessions; this is useful to customize the interface.


hopefully, helpful in the slightest ...



On Tuesday, November 15, 2016 at 2:51:35 PM UTC-8, David Anthoff wrote:

That deletes everything, but really I just want to hide the current prompt. 

<SNIP>

I.e. the user could continue editing the stuff that he/she was working on before the background task briefly took over.

 

Thanks,

David


Loading...