From 69df046cb0752766d27795ba9a27ed59db80ccf8 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 21 Jan 2014 14:34:15 -0700 Subject: [PATCH] Move font size increase/decrease to the Workspace model --- spec/workspace-spec.coffee | 14 ++++++++++++++ spec/workspace-view-spec.coffee | 17 ----------------- src/workspace-view.coffee | 10 +++------- src/workspace.coffee | 7 +++++++ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index f264f1a75..937069482 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -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 diff --git a/spec/workspace-view-spec.coffee b/spec/workspace-view-spec.coffee index 17c0d87a3..d13ca3323 100644 --- a/spec/workspace-view-spec.coffee +++ b/spec/workspace-view-spec.coffee @@ -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) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 3bf9cb2ba..f0a819cf4 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -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() diff --git a/src/workspace.coffee b/src/workspace.coffee index 923840683..21663bb59 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -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?()