mirror of
https://github.com/atom/atom.git
synced 2026-02-09 14:15:24 -05:00
Add config.editor.fontSize
This commit is contained in:
@@ -9,19 +9,22 @@ class Config
|
||||
@configJsonPath = fs.join(@configDirPath, "config.json")
|
||||
@userInitScriptPath = fs.join(@configDirPath, "atom.coffee")
|
||||
|
||||
@core = {}
|
||||
@editor = {}
|
||||
|
||||
load: ->
|
||||
if fs.exists(@configJsonPath)
|
||||
userConfig = JSON.parse(fs.read(@configJsonPath))
|
||||
_.extend(this, userConfig)
|
||||
@assignDefaults()
|
||||
@requireUserInitScript()
|
||||
|
||||
assignDefaults: ->
|
||||
@core ?= {}
|
||||
_.defaults(@core, require('root-view').configDefaults)
|
||||
@editor ?= {}
|
||||
_.defaults(@editor, require('editor').configDefaults)
|
||||
|
||||
update: ->
|
||||
@trigger 'update'
|
||||
|
||||
|
||||
requireUserInitScript: ->
|
||||
try
|
||||
require @userInitScriptPath if fs.exists(@userInitScriptPath)
|
||||
|
||||
@@ -15,6 +15,10 @@ module.exports =
|
||||
class Editor extends View
|
||||
@idCounter: 1
|
||||
|
||||
@configDefaults:
|
||||
fontSize: 20
|
||||
showInvisibles: false
|
||||
|
||||
@content: (params) ->
|
||||
@div class: @classes(params), tabindex: -1, =>
|
||||
@subview 'gutter', new Gutter
|
||||
@@ -302,8 +306,9 @@ class Editor extends View
|
||||
backwardsScanInRange: (args...) -> @getBuffer().backwardsScanInRange(args...)
|
||||
|
||||
configure: ->
|
||||
@setShowInvisibles(config.editor.showInvisibles ? false)
|
||||
@setShowInvisibles(config.editor.showInvisibles)
|
||||
@setInvisibles(config.editor.invisibles)
|
||||
@setFontSize(config.editor.fontSize)
|
||||
|
||||
handleEvents: ->
|
||||
config.on "update.editor#{@id}", => @configure()
|
||||
@@ -394,7 +399,6 @@ class Editor extends View
|
||||
afterAttach: (onDom) ->
|
||||
return if @attached or not onDom
|
||||
@attached = true
|
||||
@subscribeToFontSize()
|
||||
@calculateDimensions()
|
||||
@hiddenInput.width(@charWidth)
|
||||
@setSoftWrapColumn() if @activeEditSession.getSoftWrap()
|
||||
@@ -612,19 +616,17 @@ class Editor extends View
|
||||
autosave: ->
|
||||
@save() if @getPath()?
|
||||
|
||||
subscribeToFontSize: ->
|
||||
return unless rootView = @rootView()
|
||||
@setFontSize(rootView.getFontSize())
|
||||
rootView.on "font-size-change.editor#{@id}", => @setFontSize(rootView.getFontSize())
|
||||
|
||||
setFontSize: (fontSize) ->
|
||||
setFontSize: (@fontSize) ->
|
||||
if fontSize?
|
||||
@css('font-size', fontSize + 'px')
|
||||
return unless @attached
|
||||
@calculateDimensions()
|
||||
@updatePaddingOfRenderedLines()
|
||||
@updateLayerDimensions()
|
||||
@requestDisplayUpdate()
|
||||
|
||||
getFontSize: -> @fontSize
|
||||
|
||||
newSplitEditor: ->
|
||||
new Editor { editSession: @activeEditSession.copy() }
|
||||
|
||||
|
||||
@@ -15,21 +15,21 @@ TextMateTheme = require 'text-mate-theme'
|
||||
|
||||
module.exports =
|
||||
class RootView extends View
|
||||
@configDefaults: {}
|
||||
|
||||
@content: ->
|
||||
@div id: 'root-view', tabindex: -1, =>
|
||||
@div id: 'horizontal', outlet: 'horizontal', =>
|
||||
@div id: 'vertical', outlet: 'vertical', =>
|
||||
@div id: 'panes', outlet: 'panes'
|
||||
|
||||
@deserialize: ({ projectPath, panesViewState, extensionStates, fontSize }) ->
|
||||
@deserialize: ({ projectPath, panesViewState, extensionStates }) ->
|
||||
rootView = new RootView(projectPath, extensionStates: extensionStates, suppressOpen: true)
|
||||
rootView.setRootPane(rootView.deserializeView(panesViewState)) if panesViewState
|
||||
rootView.setFontSize(fontSize) if fontSize > 0
|
||||
rootView
|
||||
|
||||
extensions: null
|
||||
extensionStates: null
|
||||
fontSize: 20
|
||||
title: null
|
||||
|
||||
initialize: (pathToOpen, { @extensionStates, suppressOpen } = {}) ->
|
||||
@@ -53,7 +53,6 @@ class RootView extends View
|
||||
projectPath: @project?.getPath()
|
||||
panesViewState: @panes.children().view()?.serialize()
|
||||
extensionStates: @serializeExtensions()
|
||||
fontSize: @getFontSize()
|
||||
|
||||
handleEvents: ->
|
||||
@on 'toggle-dev-tools', => atom.toggleDevTools()
|
||||
@@ -77,8 +76,15 @@ class RootView extends View
|
||||
else
|
||||
@setTitle("untitled")
|
||||
|
||||
@command 'window:increase-font-size', => @setFontSize(@getFontSize() + 1)
|
||||
@command 'window:decrease-font-size', => @setFontSize(@getFontSize() - 1)
|
||||
@command 'window:increase-font-size', =>
|
||||
config.editor.fontSize += 1
|
||||
config.update()
|
||||
|
||||
@command 'window:decrease-font-size', =>
|
||||
if config.editor.fontSize > 1
|
||||
config.editor.fontSize -= 1
|
||||
config.update()
|
||||
|
||||
@command 'window:focus-next-pane', => @focusNextPane()
|
||||
@command 'window:save-all', => @saveAll()
|
||||
@command 'window:toggle-invisibles', =>
|
||||
@@ -242,12 +248,5 @@ class RootView extends View
|
||||
@project.destroy()
|
||||
super
|
||||
|
||||
setFontSize: (newFontSize) ->
|
||||
newFontSize = Math.max(1, newFontSize)
|
||||
[oldFontSize, @fontSize] = [@fontSize, newFontSize]
|
||||
@trigger 'font-size-change' if oldFontSize != newFontSize
|
||||
|
||||
getFontSize: -> @fontSize
|
||||
|
||||
saveAll: ->
|
||||
editor.save() for editor in @getEditors()
|
||||
|
||||
Reference in New Issue
Block a user