-
Notifications
You must be signed in to change notification settings - Fork 269
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
Conversation
class CustomOptionView extends View | ||
|
||
@content: -> | ||
@div class: "customOptionView", => |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, gotcha. 😁
There was a problem hiding this comment.
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
Looking good 👍 Thanks for writing this, I'll definitely be taking advantage of it! |
Thanks, I will go back and make some of those changes when I get a chance. |
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' |
There was a problem hiding this comment.
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
.
Whoa. Just realized my view was out of sync while reviewing this. Sorry if my comments are completely off now. |
Thanks for reviewing @smashwilson and @EntilZha for making this new drop down. |
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 != '') |
There was a problem hiding this comment.
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...
Finally got some time to play with this. Can we change the order of operations when hitting 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 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? |
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: 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. |
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 I'll also check this new version out. I'm pretty impressed already. |
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... |
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. 😭 |
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? |
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:' |
There was a problem hiding this comment.
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
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()) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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! |
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:
⌘-i
run will use these options, which by default revert to the current behavior that⌘-i
has⌘-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