Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zoom command. #2978

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions background_scripts/commands.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ Commands =
"nextFrame",
"mainFrame",
"Marks.activateCreateMode",
"Marks.activateGotoMode"]
"Marks.activateGotoMode",
"zoom"]
vomnibarCommands:
["Vomnibar.activate",
"Vomnibar.activateInNewTab",
Expand Down Expand Up @@ -231,7 +232,8 @@ Commands =
"closeOtherTabs",
"enterVisualLineMode",
"toggleViewSource",
"passNextKey"]
"passNextKey",
"zoom"]

defaultKeyMappings =
"?": "showHelp"
Expand Down Expand Up @@ -410,6 +412,8 @@ commandDescriptions =
"Marks.activateCreateMode": ["Create a new mark", { noRepeat: true }]
"Marks.activateGotoMode": ["Go to a mark", { noRepeat: true }]

zoom: ["Zoom in or out"]

Commands.init()

root = exports ? window
Expand Down
7 changes: 7 additions & 0 deletions content_scripts/mode_normal.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ NormalModeCommands =
nextStrings = nextPatterns.split(",").filter( (s) -> s.trim().length )
findAndFollowRel("next") || findAndFollowLink(nextStrings)

zoom: (count, options) ->
factor = parseFloat options.registryEntry.options.factor ? "1.1"
factor = Math.pow factor, count
factor = 1.0 / factor unless options.registryEntry.options.out
document.body.style.zoom = "#{parseFloat(document.body.style.zoom or 1.0) / factor}"
HUD.showForDuration "Zoom: #{Math.round(100 * parseFloat document.body.style.zoom) / 100}", 1500

focusInput: (count) ->
# Focus the first input element on the page, and create overlays to highlight all the input elements, with
# the currently-focused element highlighted specially. Tabbing will shift focus to the next input element.
Expand Down