Skip to content

Commit

Permalink
Add custom render settings on a per-minimal basis
Browse files Browse the repository at this point in the history
Initiate the work for #396
  • Loading branch information
abe33 committed Oct 30, 2015
1 parent b514baf commit 4eed31a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
32 changes: 22 additions & 10 deletions lib/minimap.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ class Minimap
config: 'editor.scrollPastEnd'
value: @scrollPastEnd
})
subs.add atom.config.observe 'minimap.charHeight', (@charHeight) =>
subs.add atom.config.observe 'minimap.charHeight', (@configCharHeight) =>
@emitter.emit('did-change-config', {
config: 'minimap.charHeight'
value: @charHeight
value: @getCharHeight()
})
subs.add atom.config.observe 'minimap.charWidth', (@charWidth) =>
subs.add atom.config.observe 'minimap.charWidth', (@configCharWidth) =>
@emitter.emit('did-change-config', {
config: 'minimap.charWidth'
value: @charWidth
value: @getCharWidth()
})
subs.add atom.config.observe 'minimap.interline', (@interline) =>
subs.add atom.config.observe 'minimap.interline', (@configInterline) =>
@emitter.emit('did-change-config', {
config: 'minimap.interline'
value: @interline
value: @getInterline()
})

subs.add @adapter.onDidChangeScrollTop =>
Expand Down Expand Up @@ -305,22 +305,34 @@ class Minimap
# Returns the height of a line in the {Minimap} in pixels.
#
# Returns a {Number}.
getLineHeight: -> @charHeight + @interline
getLineHeight: -> @getCharHeight() + @getInterline()

# Returns the width of a character in the {Minimap} in pixels.
#
# Returns a {Number}.
getCharWidth: -> @charWidth
getCharWidth: -> @charWidth ? @configCharWidth

setCharWidth: (charWidth) ->
@charWidth = Math.floor(charWidth)
@emitter.emit('did-change-config')

# Returns the height of a character in the {Minimap} in pixels.
#
# Returns a {Number}.
getCharHeight: -> @charHeight
getCharHeight: -> @charHeight ? @configCharHeight

setCharHeight: (charHeight) ->
@charHeight = Math.floor(charHeight)
@emitter.emit('did-change-config')

# Returns the space between lines in the {Minimap} in pixels.
#
# Returns a {Number}.
getInterline: -> @interline
getInterline: -> @interline ? @configInterline

setInterline: (interline) ->
@interline = Math.floor(interline)
@emitter.emit('did-change-config')

# Returns the index of the first visible row in the {Minimap}.
#
Expand Down
20 changes: 20 additions & 0 deletions spec/minimap-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -482,3 +482,23 @@ describe 'Stand alone minimap', ->

expect(minimap.getScrollTop()).toEqual(10)
expect(scrollSpy).toHaveBeenCalled()

it 'has rendering properties that can overrides the config values', ->
minimap.setCharWidth(8.5)
minimap.setCharHeight(10.2)
minimap.setInterline(10.6)

expect(minimap.getCharWidth()).toEqual(8)
expect(minimap.getCharHeight()).toEqual(10)
expect(minimap.getInterline()).toEqual(10)
expect(minimap.getLineHeight()).toEqual(20)

it 'emits a config change event when a value is changed', ->
changeSpy = jasmine.createSpy('did-change')
minimap.onDidChangeConfig(changeSpy)

minimap.setCharWidth(8.5)
minimap.setCharHeight(10.2)
minimap.setInterline(10.6)

expect(changeSpy.callCount).toEqual(3)

0 comments on commit 4eed31a

Please sign in to comment.