Skip to content

Commit

Permalink
Fixes #17
Browse files Browse the repository at this point in the history
  • Loading branch information
zjhmale committed Mar 16, 2017
1 parent b0fd405 commit b808d24
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
| Apropos | shift + cmd/ctrl + k |
| Eval current line | shift + cmd/ctrl + e |
| Start / Refresh REPL | shift + cmd/ctrl + r |
| Send selection to REPL | shift + cmd/ctrl + x |

* ipkg highlighting
* autocompletion
Expand Down
10 changes: 8 additions & 2 deletions features.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,15 @@

### Start or Refresh REPL

`(shift + cmd/ctrl + e)`
`(shift + cmd/ctrl + r)`

![start-refresh-repl](./images/screenshots/start-refresh-repl.gif)

### Send selected text to REPL

`(shift + cmd/ctrl + x)`

![eval-line](./images/screenshots/start-refresh-repl.gif)
![send-selection-repl](./images/screenshots/send-selection-repl.gif)

### Code completion

Expand Down
Binary file added images/screenshots/send-selection-repl.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@
}, {
"command": "idris.start-refresh-repl",
"title": "Idris: start or refresh REPL",
"description": " current line"
"description": "Start REPL for currently opened file or refresh REPL when opened file is changed"
}, {
"command": "idris.send-selection-repl",
"title": "Idris: send selected text to REPL",
"description": "Send selected text to a refreshed REPL with currently opened file"
}],
"keybindings": [
{
Expand Down Expand Up @@ -203,6 +207,12 @@
"mac": "shift+cmd+r",
"when": "editorFocus && editorLangId == idris",
"command": "idris.start-refresh-repl"
},
{
"key": "shift+ctrl+x",
"mac": "shift+cmd+x",
"when": "editorFocus && editorLangId == idris",
"command": "idris.send-selection-repl"
}
],
"snippets": [{
Expand Down
3 changes: 2 additions & 1 deletion src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ let getCommands = () => {
['idris.make-lemma', runCommand(commands.makeLemma)],
['idris.apropos', runCommand(commands.apropos)],
['idris.eval-line', runCommand(commands.runREPL)],
['idris.start-refresh-repl', runCommand(commands.startREPL)]
['idris.start-refresh-repl', runCommand(commands.startREPL)],
['idris.send-selection-repl', runCommand(commands.sendREPL)]
]
}

Expand Down
33 changes: 24 additions & 9 deletions src/idris/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,34 @@ let runREPL = (uri) => {
})
}

let startup = (uri) => {
term = vscode.window.createTerminal("Idris REPL")
term.sendText("idris")
term.sendText(`:l ${uri}`)
term.show()
}

let startREPL = (uri) => {
let startup = () => {
term = vscode.window.createTerminal("Idris REPL")
term.sendText("idris")
term.sendText(`:l ${uri}`)
term.show()
}
if (term == null) {
startup()
startup(uri)
} else {
term.hide()
term.dispose()
startup()
startup(uri)
}
}

let sendREPL = (uri) => {
let editor = vscode.window.activeTextEditor
let selection = editor.selection
let text = editor.document.getText(selection)

if (term == null) {
startup(uri)
}

term.show()
term.sendText(text)
}

let addClause = (uri) => {
Expand Down Expand Up @@ -475,5 +489,6 @@ module.exports = {
apropos,
runREPL,
destroy,
startREPL
startREPL,
sendREPL
}

0 comments on commit b808d24

Please sign in to comment.