Meta+ and meta- change the editor font size

This commit is contained in:
Nathan Sobo
2012-05-09 10:57:25 -06:00
parent f2f44b9ab6
commit 5b7ea95a11
3 changed files with 17 additions and 1 deletions

View File

@@ -409,3 +409,14 @@ describe "RootView", ->
rootView.editors()[0].remove()
expect(document.title).toBe rootView.project.getPath()
describe "font size adjustment", ->
it "increases/decreases font size when increase/decrease-font-size events are triggered", ->
fontSizeBefore = rootView.getFontSize()
rootView.trigger 'increase-font-size'
expect(rootView.getFontSize()).toBe fontSizeBefore + 1
rootView.trigger 'increase-font-size'
expect(rootView.getFontSize()).toBe fontSizeBefore + 2
rootView.trigger 'decrease-font-size'
expect(rootView.getFontSize()).toBe fontSizeBefore + 1
rootView.trigger 'decrease-font-size'
expect(rootView.getFontSize()).toBe fontSizeBefore

View File

@@ -2,6 +2,8 @@ window.keymap.bindKeys '*'
'meta-s': 'save'
'meta-w': 'close'
'alt-meta-i': 'show-console'
'meta-+': 'increase-font-size'
'meta--': 'decrease-font-size'
right: 'move-right'
left: 'move-left'

View File

@@ -28,7 +28,7 @@ class RootView extends View
extensions: null
extensionStates: null
fontSize: null
fontSize: 18
initialize: ({ pathToOpen }) ->
@extensions = {}
@@ -57,6 +57,9 @@ class RootView extends View
@project.setPath(path) unless @project.getRootDirectory()
@setTitle(path)
@on 'increase-font-size', => @setFontSize(@getFontSize() + 1)
@on 'decrease-font-size', => @setFontSize(@getFontSize() - 1)
afterAttach: (onDom) ->
@focus() if onDom