Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customized run option #74

Merged
merged 27 commits into from
Apr 3, 2014
Merged

Conversation

EntilZha
Copy link
Collaborator

Pull request for feature which allows customization of script run options. Encapsulates some from these issues:
#32
#6
#5

Encapsulated in this pull request is:

  1. Additional code to create variable options for current working directory, command arguments, and script arguments. These are saved per view.
  2. ⌘-i run will use these options, which by default revert to the current behavior that ⌘-i has
  3. ⌘-shift-i runs ⌘-i, then opens the options dialog where changes can be made to the options. These options persist through runs of ⌘-i and ⌘-shift-i for a particular window.

Todo

  • Make the UI cleaner/more intuitive/easier. Perhaps some autosaving, collapsing the close/save into one button, ideas?
  • Make the options persist past the lifetime of the view via the filesystem somehow
  • Other stuff?

@EntilZha EntilZha mentioned this pull request Mar 17, 2014
class CustomOptionView extends View

@content: ->
@div class: "customOptionView", =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny style note - CSS classes are usually dash-separated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer that as well, but followed the convention of the css already there to have views camel case and everything else dash-separated.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, gotcha. 😁

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'm the one that added the crappy camel casing the in css file. forgot what language/file i was working with 😄 feel free to update those in the css as well as yours to use the dash separation

@smashwilson
Copy link
Collaborator

Looking good 👍 Thanks for writing this, I'll definitely be taking advantage of it!

@EntilZha
Copy link
Collaborator Author

Thanks, I will go back and make some of those changes when I get a chance.

@EntilZha
Copy link
Collaborator Author

Went ahead and made those quick changes, each in their own commit.

@@ -6,3 +6,4 @@
'cmd-i': 'script:run'
'ctrl-w': 'script:close-view'
'ctrl-c': 'script:kill-process'
'shift-cmd-i': 'script:options'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer to call this run-options.

@rgbkrk
Copy link
Member

rgbkrk commented Mar 17, 2014

Whoa. Just realized my view was out of sync while reviewing this. Sorry if my comments are completely off now.

@rgbkrk
Copy link
Member

rgbkrk commented Mar 17, 2014

Thanks for reviewing @smashwilson and @EntilZha for making this new drop down.

@rgbkrk
Copy link
Member

rgbkrk commented Mar 17, 2014

Adding image for the sake of having it in the same PR:

@rgbkrk
Copy link
Member

rgbkrk commented Mar 17, 2014

This is going to bug me, but it's really a nitpick. In the display it reads out as "Script Arguments" though we're not limited to scripting languages (e.g. Go).

The only other thing that's missing from the dropdown (which could be added in another PR) is the command to run.

saveOptions: =>
@options.cmd_cwd = @customOptionView.inputCwd.val()
@options.cmd_args = (item for item in @customOptionView.inputCommandArgs.val().split(' ') when item != '')
@options.script_args = (item for item in @customOptionView.inputScriptArgs.val().split(' ') when item != '')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only issue with splitting on space is that some args have to come in as one whole argument (the code itself being one). Then again, what else could we do? This probably is the best we're going to be able to do from a single text box.

The only other options is to populate new text boxes to each take additional args (click a +, etc.). That would probably get ugly fast. Hmm...

@rgbkrk
Copy link
Member

rgbkrk commented Mar 17, 2014

Finally got some time to play with this. Can we change the order of operations when hitting ⌘-shift-i?

IMO, the script should only run after configuring the options so we don't give people side effects from running their script sans arguments.

On a different note, the script:toggle-options won't open unless the bottom viewer is open. I think this is an artifact of how we're instantiating.


This lack of backspace ability is so frustratingly hilarious! You have to full on exit Atom to reset the settings. Maybe in the meantime we can have a clear button that just clears all the text fields?

@EntilZha
Copy link
Collaborator Author

I read through the comments and like last time made the changes in more or less their own commits. I think I hit on all your feedback, but let me know if I missed something.

On the command args, I think I agree, there is not much better we can do other than assume that space division will work. I tested it with selection of text to run and it runs fine.

The backspace bug is annoying. I made a post on the atom discussion forums asking about this, hopefully get some sort of resolution there:
http://discuss.atom.io/t/input-text-element-cant-backspace/4981

Starting to look a little more polished now I think. cmd-shft-i should now pull up options whether or not script is already run and does not run the script. Everything else works as before I believe.

@rgbkrk
Copy link
Member

rgbkrk commented Mar 17, 2014

Thanks for addressing these and refactoring this through all our reviews. Love this new view. I'll try to see who I can reach about keybindings in subviews and dig through Atom's source (grepping through /Applications/Atom.app/Contents/).

I'll also check this new version out. I'm pretty impressed already.

@EntilZha
Copy link
Collaborator Author

I think that the keybinding issue actually is already resolved. I missed changing the activation events keybinding when I renamed the run options. It should work without needing script already open now.

Now to get that backspace bug fixed...

@rgbkrk
Copy link
Member

rgbkrk commented Mar 17, 2014

Sorry, I mis-spoke or wasn't clear. I meant the backspace bug when I said keybindings. The same bug is affecting copy and paste. 😭

@EntilZha
Copy link
Collaborator Author

Any luck on the keybinding bug? I haven't gotten a reply on the Atom forums and so far nothing from the feedback email. Is it worth making a clear button and then remove it once the bug is fixed?

@rgbkrk
Copy link
Member

rgbkrk commented Mar 20, 2014

Yeah, I think the clear button would be fine for now. You've got something stellar here already and we'll certainly want some way to clear before releasing this.

@label 'Command Arguments:'
@input type: 'text', class: 'editor mini editor-colors', outlet: 'inputCommandArgs'
@div class: 'block', =>
@label 'Program Arguments:'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this wording much better, thank you.

… force with .hide() or .show() still. Behavior should still be the same so far
… It instead empties the panel and says its configuring options.

To run the script, there is a run button which will save the options, close the option dialog, and run the program.

For some reason I can't get it to appear without the script window already being open
Fixed the bug where it would not run without script already being open, which was failing to rename teh activation event from script:run-options.

This now should be ready for some more review
…e script view. Currently trying to get options to pass between views
…t to persist across all views. Currently it does not, perhaps the object is copied into each view on initialization instead of referecing the same object living in script.coffee. Removed the activation events in package.json as well
… Discovered that options are not unique to a particular file, but are on an entire workspace which means they are not per file options. This needs to be addressed somehow
@EntilZha
Copy link
Collaborator Author

EntilZha commented Apr 3, 2014

Just did the rebase, let me know if that works


activate: (state) ->
@scriptView = new ScriptView(state.scriptViewState)
@scriptView = new ScriptView(state.scriptViewState, new ScriptOptions())
@scriptOptionsView = new ScriptOptionsView(new ScriptOptions())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused here. Why don't they have the same shared ScriptOptions object?

@scriptOptions = new ScriptOptions()
@scriptView = new ScriptView(state.scriptViewState, @scriptOptions)
@scriptOptionsView = new ScriptOptionsView(@scriptOptions)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the first thing I tried. My initial thought was to create 1 object as you suggested and pass it around, with both views having access to it and essentially communicating through it.

What I found though was that the object/hash being changed in one place, did not change the other. So I concluded that it must be copying the object/hash (at the same time, the same one) for use in each view, rather than passing a reference to the same object.

To work around this, I used atom.emit and atom.on, but if this could work it would be cleaner

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. I must have a fundamental misunderstanding about Javascript and CoffeeScript objects then.

I'll work with this for a bit and merge it in tonight.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I thought that passing 1 reference around would work as well. I would be interested in seeing if perhaps I just implemented it wrong

@rgbkrk
Copy link
Member

rgbkrk commented Apr 3, 2014

Looking good. Just tried this out, works like a champ.

Only thing missing from the options menu is a command option. We'll do that in a separate PR.

Nice work @EntilZha!

:shipit:

rgbkrk added a commit that referenced this pull request Apr 3, 2014
@rgbkrk rgbkrk merged commit e62d9f2 into atom-community:master Apr 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants