Move font size increase/decrease to the Workspace model

This commit is contained in:
Nathan Sobo 2014-01-21 14:34:15 -07:00
parent d491007da8
commit 69df046cb0
4 changed files with 24 additions and 24 deletions

View File

@ -179,3 +179,17 @@ describe "Workspace", ->
expect(workspace.activePaneItem.getUri()).toBe 'b'
workspace.reopenItemSync()
expect(workspace.activePaneItem.getUri()).toBe 'file1'
describe "::increase/decreaseFontSize()", ->
it "increases/decreases the font size without going below 1", ->
atom.config.set('editor.fontSize', 1)
workspace.increaseFontSize()
expect(atom.config.get('editor.fontSize')).toBe 2
workspace.increaseFontSize()
expect(atom.config.get('editor.fontSize')).toBe 3
workspace.decreaseFontSize()
expect(atom.config.get('editor.fontSize')).toBe 2
workspace.decreaseFontSize()
expect(atom.config.get('editor.fontSize')).toBe 1
workspace.decreaseFontSize()
expect(atom.config.get('editor.fontSize')).toBe 1

View File

@ -168,23 +168,6 @@ describe "WorkspaceView", ->
expect(workspaceView2.title).toBe "#{item.getTitle()} - #{atom.project.getPath()}"
workspaceView2.remove()
describe "font size adjustment", ->
it "increases/decreases font size when increase/decrease-font-size events are triggered", ->
fontSizeBefore = atom.config.get('editor.fontSize')
atom.workspaceView.trigger 'window:increase-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 1
atom.workspaceView.trigger 'window:increase-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 2
atom.workspaceView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore + 1
atom.workspaceView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe fontSizeBefore
it "does not allow the font size to be less than 1", ->
atom.config.set("editor.fontSize", 1)
atom.workspaceView.trigger 'window:decrease-font-size'
expect(atom.config.get('editor.fontSize')).toBe 1
describe "window:toggle-invisibles event", ->
it "shows/hides invisibles in all open and future editors", ->
atom.workspaceView.height(200)

View File

@ -44,7 +44,7 @@ class WorkspaceView extends View
@delegatesProperty 'fullScreen', 'destroyedItemUris', toProperty: 'model'
@delegatesMethods 'open', 'openSync', 'openSingletonSync', 'reopenItemSync',
'saveActivePaneItem', 'saveActivePaneItemAs', 'saveAll', 'destroyActivePaneItem',
'destroyActivePane', toProperty: 'model'
'destroyActivePane', 'increaseFontSize', 'decreaseFontSize', toProperty: 'model'
@version: 4
@ -104,12 +104,8 @@ class WorkspaceView extends View
@command 'application:open-your-stylesheet', -> ipc.sendChannel('command', 'application:open-your-stylesheet')
@command 'window:run-package-specs', => ipc.sendChannel('run-package-specs', path.join(atom.project.getPath(), 'spec'))
@command 'window:increase-font-size', =>
atom.config.set("editor.fontSize", atom.config.get("editor.fontSize") + 1)
@command 'window:decrease-font-size', =>
fontSize = atom.config.get "editor.fontSize"
atom.config.set("editor.fontSize", fontSize - 1) if fontSize > 1
@command 'window:increase-font-size', => @increaseFontSize()
@command 'window:decrease-font-size', => @decreaseFontSize()
@command 'window:focus-next-pane', => @focusNextPane()
@command 'window:focus-previous-pane', => @focusPreviousPane()

View File

@ -138,6 +138,13 @@ class Workspace extends Model
destroyActivePane: ->
@activePane?.destroy()
increaseFontSize: ->
atom.config.set("editor.fontSize", atom.config.get("editor.fontSize") + 1)
decreaseFontSize: ->
fontSize = atom.config.get("editor.fontSize")
atom.config.set("editor.fontSize", fontSize - 1) if fontSize > 1
# Private: Removes the item's uri from the list of potential items to reopen.
itemOpened: (item) ->
if uri = item.getUri?()