Skip to content

Commit

Permalink
Cleanup, rename command to 'fetch'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Tikhonov committed Aug 18, 2016
1 parent 89e174a commit aa3ec55
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 64 deletions.
2 changes: 1 addition & 1 deletion keymaps/sourcefetch.json
@@ -1,5 +1,5 @@
{
"atom-workspace": {
"ctrl-alt-o": "sourcefetch:toggle"
"ctrl-alt-o": "sourcefetch:fetch"
}
}
29 changes: 0 additions & 29 deletions lib/sourcefetch-view.js

This file was deleted.

38 changes: 9 additions & 29 deletions lib/sourcefetch.js
@@ -1,49 +1,29 @@
'use babel';

import SourcefetchView from './sourcefetch-view';
import { CompositeDisposable } from 'atom';
import { CompositeDisposable } from 'atom'

export default {

sourcefetchView: null,
modalPanel: null,
subscriptions: null,

activate(state) {
this.sourcefetchView = new SourcefetchView(state.sourcefetchViewState);
this.modalPanel = atom.workspace.addModalPanel({
item: this.sourcefetchView.getElement(),
visible: false
});
activate() {
this.subscriptions = new CompositeDisposable()

// Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
this.subscriptions = new CompositeDisposable();

// Register command that toggles this view
this.subscriptions.add(atom.commands.add('atom-workspace', {
'sourcefetch:toggle': () => this.toggle()
}));
'sourcefetch:fetch': () => this.fetch()
}))
},

deactivate() {
this.modalPanel.destroy();
this.subscriptions.dispose();
this.sourcefetchView.destroy();
},

serialize() {
return {
sourcefetchViewState: this.sourcefetchView.serialize()
};
this.subscriptions.dispose()
},

toggle() {
fetch() {
let editor
if (editor = atom.workspace.getActiveTextEditor()) {
let selection = editor.getSelectedText()
let reversed = selection.split("").reverse().join("")
editor.insertText(reversed)
selection = selection.split("").reverse().join("")
editor.insertText(selection)
}
}

};
8 changes: 4 additions & 4 deletions menus/sourcefetch.json
Expand Up @@ -2,8 +2,8 @@
"context-menu": {
"atom-text-editor": [
{
"label": "Toggle sourcefetch",
"command": "sourcefetch:toggle"
"label": "Fetch code",
"command": "sourcefetch:fetch"
}
]
},
Expand All @@ -15,8 +15,8 @@
"label": "sourcefetch",
"submenu": [
{
"label": "Toggle",
"command": "sourcefetch:toggle"
"label": "Fetch code",
"command": "sourcefetch:fetch"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -6,7 +6,7 @@
"keywords": [
],
"activationCommands": {
"atom-workspace": "sourcefetch:toggle"
"atom-workspace": "sourcefetch:fetch"
},
"repository": "https://github.com/atom/sourcefetch",
"license": "MIT",
Expand Down

0 comments on commit aa3ec55

Please sign in to comment.