-
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
Changes from all commits
a33bc0e
909c41c
f088d4c
f1074d2
6c9005e
e9a8426
6c8d01a
ae86934
bad05dd
5be1c21
1e85635
e7e1733
0bf623f
d25dc44
b41aab9
f1c5a59
8b320e1
ab71393
00414e9
ff2a5b9
44c3a4f
264eae4
c9f3fd5
b1a3810
b05c9f5
c9353f4
8b2e31c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import sys, os | ||
|
||
print "CWD:{0}".format(os.getcwd()) | ||
print "ARGS:{0}".format(sys.argv[1:]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{View} = require 'atom' | ||
|
||
module.exports = | ||
class ScriptOptionsView extends View | ||
|
||
@content: -> | ||
@div => | ||
@div class: 'overlay from-top panel', outlet: 'scriptOptionsView', => | ||
@div class: 'panel-heading', 'Configure Run Options' | ||
@div class: 'panel-body padded native-key-bindings', => | ||
@div class: 'block', => | ||
@label 'Current Working Directory:' | ||
@input type: 'text', class: 'editor mini editor-colors ', outlet: 'inputCwd' | ||
@div class: 'block', => | ||
@label 'Command Arguments:' | ||
@input type: 'text', class: 'editor mini editor-colors', outlet: 'inputCommandArgs' | ||
@div class: 'block', => | ||
@label 'Program Arguments:' | ||
@input type: 'text', class: 'editor mini editor-colors', outlet: 'inputScriptArgs' | ||
@div class: 'block', => | ||
@button class: 'btn btn-primary inline-block-tight', click: 'close', 'Close' | ||
@button class: 'btn btn-success inline-block-tight', click: 'run', 'Run' | ||
|
||
initialize: (run_options) -> | ||
atom.workspaceView.command "script:run-options", => @runOptions() | ||
atom.workspaceView.command "script:close-options", => @toggleScriptOptions('hide') | ||
atom.workspaceView.command "script:save-options", => @saveOptions() | ||
atom.workspaceView.prependToTop(this) | ||
@toggleScriptOptions('hide') | ||
@run_options = run_options | ||
|
||
runOptions: -> | ||
@toggleScriptOptions() | ||
|
||
|
||
toggleScriptOptions: (command) -> | ||
if command? | ||
if command == 'show' | ||
@scriptOptionsView.show() | ||
if command == 'hide' | ||
@scriptOptionsView.hide() | ||
else | ||
@scriptOptionsView.toggle() | ||
|
||
saveOptions: => | ||
@run_options.cmd_cwd = @inputCwd.val() | ||
@run_options.cmd_args = (item for item in @inputCommandArgs.val().split(' ') when item != '') | ||
@run_options.script_args = (item for item in @inputScriptArgs.val().split(' ') when item != '') | ||
atom.emit 'script:update-options', run_options: @run_options | ||
|
||
close: -> | ||
if @hasParent() then @detach() | ||
|
||
close: -> | ||
atom.workspaceView.trigger "script:close-options" | ||
run: -> | ||
atom.workspaceView.trigger "script:save-options" | ||
atom.workspaceView.trigger "script:close-options" | ||
atom.workspaceView.trigger "script:run" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = | ||
class ScriptOptions | ||
cmd_cwd: null | ||
cmd_args: [] | ||
script_args: [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
ScriptView = require './script-view' | ||
ScriptOptionsView = require './script-options-view' | ||
ScriptOptions = require './script-options' | ||
|
||
module.exports = | ||
scriptView: null | ||
scriptOptionsView: null | ||
|
||
activate: (state) -> | ||
@scriptView = new ScriptView(state.scriptViewState) | ||
@scriptView = new ScriptView(state.scriptViewState, new ScriptOptions()) | ||
@scriptOptionsView = new ScriptOptionsView(new ScriptOptions()) | ||
|
||
deactivate: -> | ||
@scriptView.close() | ||
@scriptOptionsView.close() | ||
|
||
serialize: -> | ||
scriptViewState: @scriptView.serialize() | ||
scriptOptionsViewState: @scriptOptionsView.serialize() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,6 @@ | |
"version": "2.2.0", | ||
"private": false, | ||
"description": "Run code in Atom!", | ||
"activationEvents": [ | ||
"script:run" | ||
], | ||
"author": "Kyle Kelley <rgbkrk@gmail.com>", | ||
"contributors": [ | ||
"Kyle Kelley <rgbkrk@gmail.com>", | ||
|
@@ -20,7 +17,8 @@ | |
"cormullion <cormullion@mac.com>", | ||
"Andy Hayden <andyhayden1@gmail.com>", | ||
"jbtule <jay+code@tuley.name>", | ||
"Johan Bruning <johan@taquito.nl>" | ||
"Johan Bruning <johan@taquito.nl>", | ||
"Pedro Rodriguez <ski.rodriguez@gmail.com>" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll be moving you near the top after this gets merged. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll actually move you up higher since |
||
], | ||
"repository": "https://github.com/rgbkrk/atom-script", | ||
"keywords": [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
@import "ui-variables"; | ||
@import "ui-mixins"; | ||
|
||
.headerView { | ||
.header-view { | ||
position: fixed; | ||
width: 100%; | ||
z-index:10; | ||
|
@@ -41,7 +41,7 @@ | |
} | ||
} | ||
|
||
.scriptView { | ||
.script-view { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for standardizing the CSS class name on the viewer. |
||
overflow: scroll; | ||
height: 300px; | ||
margin-bottom: 0px; | ||
|
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?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