mirror of
https://github.com/atom/atom.git
synced 2026-02-19 02:44:29 -05:00
Add config for font zooming when Ctrl+Scrolling
This commit is contained in:
@@ -128,3 +128,7 @@ module.exports =
|
||||
cr:
|
||||
type: ['boolean', 'string']
|
||||
default: '\u00a4'
|
||||
zoomFontWhenCtrlScrolling:
|
||||
type: 'boolean'
|
||||
default: process.platform isnt 'darwin'
|
||||
description: 'Increase/decrease the editor font size when pressing the Ctrl key and scrolling the mouse up/down.'
|
||||
|
||||
@@ -482,22 +482,21 @@ TextEditorComponent = React.createClass
|
||||
|
||||
# Only scroll in one direction at a time
|
||||
{wheelDeltaX, wheelDeltaY} = event
|
||||
|
||||
# Ctrl+MouseWheel adjusts font size.
|
||||
if event.ctrlKey and atom.config.get('editor.zoomFontWhenCtrlScrolling')
|
||||
if wheelDeltaY > 0
|
||||
atom.workspace.increaseFontSize()
|
||||
else if wheelDeltaY < 0
|
||||
atom.workspace.decreaseFontSize()
|
||||
event.preventDefault()
|
||||
return
|
||||
|
||||
if Math.abs(wheelDeltaX) > Math.abs(wheelDeltaY)
|
||||
# Scrolling horizontally
|
||||
previousScrollLeft = editor.getScrollLeft()
|
||||
editor.setScrollLeft(previousScrollLeft - Math.round(wheelDeltaX * @scrollSensitivity))
|
||||
event.preventDefault() unless previousScrollLeft is editor.getScrollLeft()
|
||||
return
|
||||
else if event.ctrlKey and (process.platform isnt 'darwin')
|
||||
# Ctrl+MouseWheel adjusts font size.
|
||||
currentFontSize = atom.config.get("editor.fontSize")
|
||||
if wheelDeltaY > 0
|
||||
amount = 1
|
||||
else if wheelDeltaY < 0
|
||||
amount = -1
|
||||
atom.config.set("editor.fontSize", currentFontSize + amount)
|
||||
event.preventDefault()
|
||||
return
|
||||
else
|
||||
# Scrolling vertically
|
||||
@mouseWheelScreenRow = @screenRowForNode(event.target)
|
||||
|
||||
Reference in New Issue
Block a user