Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions keymaps/ink.cson
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@
'.platform-win32 atom-text-editor:not([mini]),
.platform-linux atom-text-editor:not([mini])':
'ctrl-i ctrl-c': 'inline-results:clear-all'

'atom-overlay .ink':
't': 'inline-results:toggleTree'
'enter': 'native!'
'tab': 'native!'
'shift-tab': 'native!'
25 changes: 19 additions & 6 deletions lib/editor/result.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Result
createView: (opts) ->
{content, fade, loading} = opts
@view = document.createElement 'div'
@view.setAttribute 'tabindex', '0'
@view.classList.add 'ink', 'result'
switch @type
when 'inline'
Expand All @@ -62,7 +63,7 @@ class Result
# @view.style.pointerEvents = 'auto'
@view.addEventListener 'mousewheel', (e) ->
e.stopPropagation()
# clicking on it will bring the current result to the top of the stack
# clicking on it will bring the focus the result
@view.addEventListener 'click', =>
@view.parentNode.parentNode.appendChild @view.parentNode

Expand All @@ -73,6 +74,11 @@ class Result
if content? then @setContent content, opts
if loading then @setContent views.render(span 'loading icon icon-gear'), opts

focus: () ->
# move current result to the top of the stack
@view.parentNode.parentNode.appendChild @view.parentNode
@view.querySelector('.tree').focus()

setContent: (view, {error, loading}={}) ->
@loading = loading
while @view.firstChild?
Expand All @@ -90,14 +96,11 @@ class Result
@marker.result = @
mark = item: @view, stable: true
switch @type
when 'inline' then mark.type = 'overlay'; mark.class = 'no-pointer-events'
when 'inline' then mark.type = 'overlay'; mark.class = ['no-pointer-events', 'ink']
when 'block' then mark.type = 'block'; mark.position = 'after'
@editor.decorateMarker @marker, mark
@disposables.add @marker.onDidChange (e) => @checkMarker e

toggleTree: ->
trees.toggle $(@view).find('> .tree')

remove: ->
if @loading then return
@view.classList.add 'ink-hide'
Expand Down Expand Up @@ -179,14 +182,24 @@ class Result
rs = @forLines ed, sel.getHeadBufferPosition().row, sel.getTailBufferPosition().row
rs.map (r) -> r.toggleTree()

@focusCurrent: ->
ed = atom.workspace.getActiveTextEditor()
for sel in ed.getSelections()
rs = @forLines ed, sel.getHeadBufferPosition().row, sel.getTailBufferPosition().row
rs.map (r) -> r.focus()

@toggleTree: ->
trees.toggle document.activeElement

# Commands

@activate: ->
@subs = new CompositeDisposable
@subs.add atom.commands.add 'atom-text-editor:not([mini])',
'inline:clear-current': (e) => @removeCurrent e
'inline-results:clear-all': => @removeAll()
'inline-results:toggle': => @toggleCurrent()
'inline-results:focus': => @focusCurrent()
'inline-results:toggleTree': => @toggleTree()

@deactivate: ->
@subs.dispose()
2 changes: 1 addition & 1 deletion lib/tree.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ views = require './util/views'

module.exports =
treeView: (head, children, {expand}) ->
view = views.render div 'ink tree', [
view = views.render div {class: 'ink tree', 'tabindex': '0'}, [
span 'icon icon-chevron-right open'
div 'header gutted', head
div 'body gutted', children
Expand Down
21 changes: 16 additions & 5 deletions styles/ink.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ atom-text-editor {
pointer-events: none;
}

atom-overlay:last-child .ink.inline {
background-color: contrast(@syntax-background-color,
darken(@syntax-background-color, 4%),
lighten(@syntax-background-color, 4%));
}

atom-text-editor::shadow {
div.block-notify .region {
background: @background-color-info;
Expand Down Expand Up @@ -80,19 +86,24 @@ atom-text-editor::shadow {
position: relative;
left: 10px;

:focus {
> .icon:before {
text-shadow: 2px 2px 0 @background-color-info;
}
}

pointer-events: auto;

&.error {
color: @text-color-error;
border-left: 2px solid @background-color-error;
}

background: contrast(@syntax-background-color,
darken(@syntax-background-color, 4%),
lighten(@syntax-background-color, 4%));
background: @syntax-background-color;
border-left: 2px solid @background-color-info;
border-right: 2px solid @syntax-background-color;

border-right: 2px solid contrast(@syntax-background-color,
darken(@syntax-background-color, 4%),
lighten(@syntax-background-color, 4%));
border-radius: 3px;

padding: 0px 5px 0px 5px;
Expand Down