Script package, show panel without triggering build


#1

Hello,

Still trying to setup the script package (also using it to learn about atom, javaScript, coffee etc).
By default, to show the script panel you need to execute your file or selection.

My goal:
I would like to be able to display that panel by default when opening Atom without having to build anything.

It seems that the panel creation, file execution and result display is all wrapped under one command : ctrl-shift-b.
But looking at the project, I can’t really find what it does when ctrl-shift-b is pressed.

It probably has to create a new atom-panel in the atom-panel-container 'bottom’ then attach the script view and finally display the output of the build withing the view

But I don’t think I have to manually do that, I should be able (if the code is well written) to call some parts of it to only initialize the script view. What I was able to find is script.js and activate(), this could be the “wrapper” for ctrl-shift-b
If it is, I don’t need the entire content since I don’t want to do the file/selected content execution and display the build output.

My javaScript and coffee knowledge being equal to 0 :sweat_smile:
I don’t know if this all doable directly in the init.coffee or if I actually need to edit the script package to add few things.
Could someone help me edit the code to add a new command that would open and initialize the view without building ?
That way I can add some code in my .coffee

atom.commands.dispatch(atom.xxxxxxxx, 'script-view:initialize')

Thanks :nerd_face:


#2

I can probably help you with this, but I’ll have to do a little reading of the package code. By default, the package isn’t able to make more content than the script that’s run, and it won’t create a view without you running code. Is it possible to hack? Probably. But why would you want to see an empty space with no content that would just take up screen real estate that could be used by your code file? I probably don’t understand because I would never want to have a giant empty box in my editor window.


#3

For me the console/output view (for my setup) is a major UI element and like any major UI element, you might want to have it visible by default.
For recording purposes I don’t like to have a UI element popping on my screen the first time I build especially if it sits there for the rest of the time.
Also, it doesn’t have to be huge depending on how you set it up and that’s also why I asked for the toggle so I can easily reduce/expand without having the element disappearing from my screen.

I hope this will make more sense to you :slight_smile: and that you will be able to help me.
In the end, it’s just matter of preference.


#4

From what I know of the package, having used it a bit and looked at the code, it does not have the ability to behave the way you want it to. I would suggest that you try out one of the packages that has that kind of display behavior (process-palette and termination are two such packages) and see what works best for your needs. termination just gives you a terminal inside Atom, while process-palette lets you set up any command line instruction you want and run it from a command within Atom, which means that you can assign keybindings, menu items, or tool bar buttons to different prewritten commands. If you’re recording, that seems like a great way to store your instructions so that you don’t have to type everything out and don’t have to edit yourself if you mess up a command. In terms of UI consistency, the process-palette output shows up in the same dock as the list of saved commands, and it is a dock, not a panel (like script uses), so you can adjust the height as much as you want.


#5

But these two packages are not what I’m looking for. If I want a regular terminal then I can use my default terminal.
I only want to be able to execute my file from within Atom and have the output printed in the view (Without having to interact with a terminal/console). The Script package is ideal and the best I’ve found so far, it does exactly what I want except I can’t initialize the view at startup.

Is the only solution making my own version of that package ?


#6

process-palette can do exactly the same thing that script does. You have to give it specific instructions, but you have much more control over what the instructions actually are. Do you need help identifying what commands to use?

And that will require learning a lot about how the package works, a package that hasn’t been updated in years and definitely would need changes to keep up with modern Atom practices. This is not an easy fix, even if the only thing you do is force it to display a 200-px-high empty box when Atom starts. That wouldn’t require all the work the package needs to be up-to-date, but the intended project is likely to be hindered by some of the things about the package that need to be changed. I’m being vague because I don’t know what all of those things are.


#7

So I managed to create my command to build the current file with process-palette.

But the Process Palette appears in the same space as the linter creating tabs.
I don’t like that the process palette shows me my available commands, I want to see my output window directly and all the time.
It has too many useless (to me) buttons everywhere.
The black background it not very nice (but can probably be changed via stylesheets)

I think the main goal of this package is to have a list of commands available. Not exactly what I’m looking for.


#8

I feel like this one would work output-panel. I can show / close / clear / toggle, it looks similar to Script.
It looks like the run function is not implemented, is it ?

The only problem with that is it shows in the same panel as Linter creating a tab …


#9

I call that space-efficiency.

No, and the package has been abandoned for a year and was never deemed complete enough to get a 1.0.0 version.


#10

You must be kidding me ! :rofl:

Do you think it would be a lot of work to create a new package combining Script and Output-panel ?
Output-panel has all the UI features
Script has the execution + display features

Interestingly, the image in the Output-panel package shows something in the view, so I guess it had to work at some point …


#11

If you want to do a decent job, probably. You would first need to understand both repos, and then which bits to combine. Any bugs encountered would be difficult for anyone to help with.


#12

Well, it looks like a new challenge :wink:
I will see what I can do.


#13

I think that it would be easier to just modify script to display itself without anything having been run in it.


#14

Probably !
but the combination of the 2 would make the best package ever :stuck_out_tongue:


#15

So from what I understand (Script package),
in script-view.js, there is the ScriptView class that creates the header (HeaderView), creates the view (ScriptView ?), populates the view with the output (showInTab) and sets the title + execution time (setHeaderAndShowExecutionTime)

This class could be broken down in 2.
ScriptViewInit class

  • header (HeaderView)
  • View creation (ScriptViewInit)

ScriptViewPopulate

  • populate the view with the output (showInTab)
  • set the title + execution time (setHeaderAndShowExecutionTime)

Then

  • Add a show command
  • connect the command with some magic here and there.

Would that be sufficient ?


#16

The first thing you need to do is make the package activate when Atom starts. Right now, it only activates when you run one of these commands, but if you delete the whole activationCommands entry, it will load when Atom opens.

Once you’ve activated it, check out atom.packages.getActivePackage('script') in your dev tools console. After that, try running this command:

atom.packages.getActivePackage('script').mainModule.scriptView.element.style.height = "500px"

You don’t need to change how the ScriptView class functions on a fundamental level. You just need to set the package up so that it will open the ScriptView before it has a runtime to observe, and make sure that the method you use doesn’t result in a second pane being created when you use script:run. After that point, you can use JavaScript and CSS to force it to look however you want.


#17

I’ve deleted the activation commands but nothing happens at startup.
The following command didn’t do anything

atom.packages.getActivePackage('script')

Did you get it to show up at startup ?


#18

Sorry about the wait. RL got in the way of me providing a quality answer. Yes, script activates on startup when I remove the activationCommands. Here’s a GitHub repo of exactly what I have on my computer right now, and the only difference is package.json.