Skip to content

Commit

Permalink
Clean up for the merge into master
Browse files Browse the repository at this point in the history
  • Loading branch information
archaeron committed Oct 24, 2015
1 parent 5fae7db commit 32b9389
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 60 deletions.
24 changes: 12 additions & 12 deletions lib/idris-controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class IdrisController
editor = target.model
uri = editor.getURI()

successHandler = ({ responseType, msg }) =>
successHandler = ({ responseType, msg }) ->
options =
split: 'right'
searchAllPanes: true
Expand All @@ -359,20 +359,20 @@ class IdrisController
.subscribe successHandler, @displayErrors

apropos: ({ target }) =>
editor = target.model
uri = editor.getURI()
editor = target.model
uri = editor.getURI()

successHandler = ({ responseType, msg }) =>
options =
split: 'right'
searchAllPanes: true
successHandler = ({ responseType, msg }) ->
options =
split: 'right'
searchAllPanes: true

atom.workspace.open "idris://apropos", options
atom.workspace.open "idris://apropos", options

@model
.load uri
.filter ({ responseType }) -> responseType == 'return'
.subscribe successHandler, @displayErrors
@model
.load uri
.filter ({ responseType }) -> responseType == 'return'
.subscribe successHandler, @displayErrors

displayErrors: (err) =>
@messages.show()
Expand Down
22 changes: 22 additions & 0 deletions lib/utils/dom.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@ createCodeElement = ->
pre.style.webkitFontFeatureSettings = '"liga"'
pre

fontOptions = ->
fontSize = atom.config.get 'language-idris.panelFontSize'
fontSizeAttr = "#{fontSize}px"
enableLigatures = atom.config.get 'language-idris.panelFontLigatures'
webkitFontFeatureSettings =
if enableLigatures
'"liga"'
else
'"inherit"'

fontFamily = atom.config.get 'language-idris.panelFontFamily'
if fontFamily != ''
fontFamily
else
'"inherit"'

'font-size': fontSizeAttr
'-webkit-font-feature-settings': webkitFontFeatureSettings
'font-family': fontFamily


module.exports =
joinHtmlElements: joinHtmlElements
createCodeElement: createCodeElement
fontOptions: fontOptions
36 changes: 12 additions & 24 deletions lib/views/apropos-view.coffee
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
Cycle = require '@cycle/core'
CycleDOM = require '@cycle/dom'
highlighter = require '../utils/highlighter'
Rx = require 'rx-lite'
{ fontOptions } = require '../utils/dom'

fontOptions = () ->
fontSize = atom.config.get 'language-idris.panelFontSize'
fontSizeAttr = "#{fontSize}px"
enableLigatures = atom.config.get 'language-idris.panelFontLigatures'
webkitFontFeatureSettings =
if enableLigatures
'"liga"'
else
'"inherit"'

fontFamily = atom.config.get 'language-idris.panelFontFamily'
if fontFamily != ''
fontFamily
else
'"inherit"'

'font-size': fontSizeAttr
'-webkit-font-feature-settings': webkitFontFeatureSettings
'font-family': fontFamily
styles = fontOptions()

AproposCycle =
# highlight : forall a.
Expand All @@ -47,7 +31,7 @@ AproposCycle =
className: 'idris-panel-view'
},
[
CycleDOM.h 'input', { type: 'text', className: 'native-key-bindings idris-repl-input-field' }, 'toggle'
CycleDOM.h 'input', { type: 'text', className: 'native-key-bindings idris-repl-input-field' }, ''
CycleDOM.h 'div', aproposAnswer
]

Expand All @@ -72,10 +56,14 @@ AproposCycle =
.flatMap (line) ->
escapedLine = line.replace(/"/g, '\\"')
options.model.apropos escapedLine
.map (e) ->
code: e.msg[0]
highlightInformation: e.msg[1]
.startWith {}
.map (e) ->
code: e.msg[0]
highlightInformation: e.msg[1]
.catch (e) ->
Rx.Observable.just
code: e.message
highlightInformation: e.highlightInformation
.startWith { }

class AproposView
constructor: (params) ->
Expand Down
26 changes: 2 additions & 24 deletions lib/views/repl-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,7 @@ Cycle = require '@cycle/core'
CycleDOM = require '@cycle/dom'
highlighter = require '../utils/highlighter'
Rx = require 'rx-lite'

fontOptions = () ->
fontSize = atom.config.get 'language-idris.panelFontSize'
fontSizeAttr = "#{fontSize}px"
enableLigatures = atom.config.get 'language-idris.panelFontLigatures'
webkitFontFeatureSettings =
if enableLigatures
'"liga"'
else
'"inherit"'

fontFamily = atom.config.get 'language-idris.panelFontFamily'
if fontFamily != ''
fontFamily
else
'"inherit"'

'font-size': fontSizeAttr
'-webkit-font-feature-settings': webkitFontFeatureSettings
'font-family': fontFamily
{ fontOptions } = require '../utils/dom'

styles = fontOptions()

Expand Down Expand Up @@ -82,7 +63,7 @@ REPLCycle =
className: 'idris-panel-view'
},
[
CycleDOM.h 'input', { type: 'text', className: 'native-key-bindings idris-repl-input-field' }, 'toggle'
CycleDOM.h 'input', { type: 'text', className: 'native-key-bindings idris-repl-input-field' }, ''
CycleDOM.h 'div', { className: 'idris-repl-lines' }, lines
]

Expand All @@ -95,9 +76,6 @@ REPLCycle =
DOM: REPLCycle.view responses.CONTENT
CONTENT: input

# driver : forall a.
# IdrisModel -> Observable String ->
# Observable (List { a | code : String, highlightInformation : highlightInformation })
driver:
(options) ->
DOM: CycleDOM.makeDOMDriver options.hostElement
Expand Down

0 comments on commit 32b9389

Please sign in to comment.