mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
change_font_size: allow multiplying/dividing the current font size in addition to incrementing it
Fixes #8616
This commit is contained in:
@@ -158,6 +158,8 @@ Detailed list of changes
|
||||
|
||||
- Launch action: Allow using an env var that resolves to a full command-line as the program to launch (:pull:`8613`)
|
||||
|
||||
- :ac:`change_font_size` allow multiplying/dividing the current font size in addition to incrementing it (:iss:`8616`)
|
||||
|
||||
0.41.1 [2025-04-03]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -1358,7 +1358,17 @@ class Boss:
|
||||
new_size = get_options().font_size
|
||||
else:
|
||||
if increment_operation:
|
||||
new_size += (1 if increment_operation == '+' else -1) * amt
|
||||
match increment_operation:
|
||||
case '+':
|
||||
new_size += amt
|
||||
case '-':
|
||||
new_size -= amt
|
||||
case '*':
|
||||
new_size *= amt
|
||||
case '/':
|
||||
new_size /= amt
|
||||
case _:
|
||||
pass # no-op
|
||||
else:
|
||||
new_size = amt
|
||||
new_size = max(MINIMUM_FONT_SIZE, min(new_size, get_options().font_size * 5))
|
||||
|
||||
@@ -4182,6 +4182,11 @@ To setup shortcuts for specific font sizes::
|
||||
To setup shortcuts to change only the current OS window's font size::
|
||||
|
||||
map kitty_mod+f6 change_font_size current 10.0
|
||||
|
||||
To setup shortcuts to multiply/divide the font size:
|
||||
|
||||
map kitty_mod+f6 change_font_size all *2.0
|
||||
map kitty_mod+f6 change_font_size all /2.0
|
||||
''') # }}}
|
||||
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ def parse_change_font_size(func: str, rest: str) -> tuple[str, tuple[bool, str |
|
||||
c_all = vals[0].lower() == 'all'
|
||||
sign: str | None = None
|
||||
amt = vals[1]
|
||||
if amt[0] in '+-':
|
||||
if amt[0] in '+-*/':
|
||||
sign = amt[0]
|
||||
amt = amt[1:]
|
||||
return func, (c_all, sign, float(amt.strip()))
|
||||
|
||||
@@ -13,7 +13,7 @@ class SetFontSize(RemoteCommand):
|
||||
protocol_spec = __doc__ = '''
|
||||
size+/float: The new font size in pts (a positive number). If absent is assumed to be zero which means reset to default.
|
||||
all/bool: Boolean whether to change font size in the current window or all windows
|
||||
increment_op/choices.+.-: The string ``+`` or ``-`` to interpret size as an increment
|
||||
increment_op/choices.+.-.*./: The string ``+``, ``-``, ``*`` or ``/`` to interpret size as an increment
|
||||
'''
|
||||
|
||||
short_desc = 'Set the font size in the active top-level OS window'
|
||||
@@ -22,7 +22,7 @@ class SetFontSize(RemoteCommand):
|
||||
' that in kitty all sub-windows in the same OS window'
|
||||
' must have the same font size. A value of zero'
|
||||
' resets the font size to default. Prefixing the value'
|
||||
' with a :code:`+` or :code:`-` increments the font size by the specified'
|
||||
' with a :code:`+`, :code:`-`, :code:`*` or :code:`/` changes the font size by the specified'
|
||||
' amount. Use -- before using - to have it not mistaken for a option. For example:'
|
||||
' kitten @ set-font-size -- -2'
|
||||
)
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
package at
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func parse_set_font_size(arg string, payload *set_font_size_json_type) error {
|
||||
if len(arg) > 0 && (arg[0] == '+' || arg[0] == '-') {
|
||||
if len(arg) > 0 && (bytes.IndexByte([]byte{'+', '-', '/', '*'}, arg[0]) > -1) {
|
||||
payload.Increment_op = arg[:1]
|
||||
arg = arg[1:]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user