sdether / josh.js

Toolkit for building a bash-like shell in the browser, including full readline support
http://sdether.github.com/josh.js/
Apache License 2.0
390 stars 76 forks source link

cannot create multiple shells in the same page? [solved] #23

Closed stevenseeley closed 10 years ago

stevenseeley commented 10 years ago

I seem to not be able to render a shell and parse input if another shell variable is created. see http://jsfiddle.net/LHJLd/

basically I do this...

var shell = Josh.Shell({ history: history, shell_panel_id: "shell-panel-0", shell_view_id: "shell-view-0" }); shell.activate(); var shell1 = Josh.Shell({ history: history, shell_panel_id: "shell-panel-1", shell_view_id: "shell-view-1"});

and then in the html body:

shell 0
<div id="shell-panel-1">
  <div>shell 1</div>
  <div id="shell-view-1"></div>
</div>
sdether commented 10 years ago

@net-ninja sorry for the slow reply. i'm currently out of town, but will get back to you next week. I was pretty sure I had multiple shells working on a single page, but if it's not working, it's certainly a bug and I will take care of it

stevenseeley commented 10 years ago

bump, I still care about this. @sdether did you end up getting it working?

stevenseeley commented 10 years ago

This works, never mind! (sorry)

sdether commented 10 years ago

Glad you got it working. I was just troubleshooting myself, since it's certainly not as simple as it should be. I tried the fiddle and couldn't get it load the libraries properly. Trying to set up locally, i then realized that you have to also define input_id in the config, since each shell needs its own input div.

Overall, doing multiple shells is annoyingly complicated. It should really be a matter of a using a container ID and then classes to find the view and input.

Readline also has a mode for attaching to an element, so that it activates/deactivates on focus, but that doesn't currently work with Shell, so you have to manage activation/deactivation by yourself, since in the default Shell implementation, Readline binds to the window and takes over all input on activation, which means only one Shell can be active.