Start work on options for tab bar vertical margins
Create the option, now need to implement it.
This commit is contained in:
parent
7dc3184f31
commit
f3977da8f3
@ -815,6 +815,17 @@ opt('tab_bar_margin_width', '0.0',
|
|||||||
long_text='The margin to the left and right of the tab bar (in pts)'
|
long_text='The margin to the left and right of the tab bar (in pts)'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
opt('tab_bar_margin_height', '0.0 0.0',
|
||||||
|
option_type='tab_bar_margin_height', ctype='!tab_bar_margin_height',
|
||||||
|
long_text='''
|
||||||
|
The margin above and below the tab bar (in pts). The first number is the
|
||||||
|
margin between the edge of the OS Window and the tab bar and the second
|
||||||
|
number is the margin between the tab bar and the contents of the current
|
||||||
|
tab.
|
||||||
|
'''
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
opt('tab_bar_style', 'fade',
|
opt('tab_bar_style', 'fade',
|
||||||
choices=('fade', 'hidden', 'powerline', 'separator'), ctype='!tab_bar_style',
|
choices=('fade', 'hidden', 'powerline', 'separator'), ctype='!tab_bar_style',
|
||||||
long_text='''
|
long_text='''
|
||||||
|
|||||||
9
kitty/options/parse.py
generated
9
kitty/options/parse.py
generated
@ -14,9 +14,9 @@ from kitty.options.utils import (
|
|||||||
edge_width, env, font_features, hide_window_decorations, kitten_alias, macos_option_as_alt,
|
edge_width, env, font_features, hide_window_decorations, kitten_alias, macos_option_as_alt,
|
||||||
macos_titlebar_color, optional_edge_width, parse_map, parse_mouse_map, resize_draw_strategy,
|
macos_titlebar_color, optional_edge_width, parse_map, parse_mouse_map, resize_draw_strategy,
|
||||||
scrollback_lines, scrollback_pager_history_size, symbol_map, tab_activity_symbol, tab_bar_edge,
|
scrollback_lines, scrollback_pager_history_size, symbol_map, tab_activity_symbol, tab_bar_edge,
|
||||||
tab_bar_min_tabs, tab_fade, tab_font_style, tab_separator, tab_title_template, to_cursor_shape,
|
tab_bar_margin_height, tab_bar_min_tabs, tab_fade, tab_font_style, tab_separator,
|
||||||
to_font_size, to_layout_names, to_modifiers, url_prefixes, url_style, window_border_width,
|
tab_title_template, to_cursor_shape, to_font_size, to_layout_names, to_modifiers, url_prefixes,
|
||||||
window_size
|
url_style, window_border_width, window_size
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -1149,6 +1149,9 @@ class Parser:
|
|||||||
def tab_bar_edge(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
def tab_bar_edge(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||||
ans['tab_bar_edge'] = tab_bar_edge(val)
|
ans['tab_bar_edge'] = tab_bar_edge(val)
|
||||||
|
|
||||||
|
def tab_bar_margin_height(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||||
|
ans['tab_bar_margin_height'] = tab_bar_margin_height(val)
|
||||||
|
|
||||||
def tab_bar_margin_width(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
def tab_bar_margin_width(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||||
ans['tab_bar_margin_width'] = positive_float(val)
|
ans['tab_bar_margin_width'] = positive_float(val)
|
||||||
|
|
||||||
|
|||||||
15
kitty/options/to-c-generated.h
generated
15
kitty/options/to-c-generated.h
generated
@ -525,6 +525,19 @@ convert_from_opts_tab_bar_edge(PyObject *py_opts, Options *opts) {
|
|||||||
Py_DECREF(ret);
|
Py_DECREF(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
convert_from_python_tab_bar_margin_height(PyObject *val, Options *opts) {
|
||||||
|
tab_bar_margin_height(val, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
convert_from_opts_tab_bar_margin_height(PyObject *py_opts, Options *opts) {
|
||||||
|
PyObject *ret = PyObject_GetAttrString(py_opts, "tab_bar_margin_height");
|
||||||
|
if (ret == NULL) return;
|
||||||
|
convert_from_python_tab_bar_margin_height(ret, opts);
|
||||||
|
Py_DECREF(ret);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
convert_from_python_tab_bar_style(PyObject *val, Options *opts) {
|
convert_from_python_tab_bar_style(PyObject *val, Options *opts) {
|
||||||
tab_bar_style(val, opts);
|
tab_bar_style(val, opts);
|
||||||
@ -945,6 +958,8 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) {
|
|||||||
if (PyErr_Occurred()) return false;
|
if (PyErr_Occurred()) return false;
|
||||||
convert_from_opts_tab_bar_edge(py_opts, opts);
|
convert_from_opts_tab_bar_edge(py_opts, opts);
|
||||||
if (PyErr_Occurred()) return false;
|
if (PyErr_Occurred()) return false;
|
||||||
|
convert_from_opts_tab_bar_margin_height(py_opts, opts);
|
||||||
|
if (PyErr_Occurred()) return false;
|
||||||
convert_from_opts_tab_bar_style(py_opts, opts);
|
convert_from_opts_tab_bar_style(py_opts, opts);
|
||||||
if (PyErr_Occurred()) return false;
|
if (PyErr_Occurred()) return false;
|
||||||
convert_from_opts_tab_bar_min_tabs(py_opts, opts);
|
convert_from_opts_tab_bar_min_tabs(py_opts, opts);
|
||||||
|
|||||||
@ -138,6 +138,16 @@ tab_bar_style(PyObject *val, Options *opts) {
|
|||||||
opts->tab_bar_hidden = PyUnicode_CompareWithASCIIString(val, "hidden") == 0 ? true: false;
|
opts->tab_bar_hidden = PyUnicode_CompareWithASCIIString(val, "hidden") == 0 ? true: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
tab_bar_margin_height(PyObject *val, Options *opts) {
|
||||||
|
if (!PyTuple_Check(val) || PyTuple_GET_SIZE(val) != 2) {
|
||||||
|
PyErr_SetString(PyExc_TypeError, "tab_bar_margin_height is not a 2-item tuple");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
opts->tab_bar_margin_height.outer = PyFloat_AsDouble(PyTuple_GET_ITEM(val, 0));
|
||||||
|
opts->tab_bar_margin_height.inner = PyFloat_AsDouble(PyTuple_GET_ITEM(val, 1));
|
||||||
|
}
|
||||||
|
|
||||||
#define read_adjust(name) { \
|
#define read_adjust(name) { \
|
||||||
if (PyFloat_Check(al)) { \
|
if (PyFloat_Check(al)) { \
|
||||||
opts->name##_frac = (float)PyFloat_AsDouble(al); \
|
opts->name##_frac = (float)PyFloat_AsDouble(al); \
|
||||||
|
|||||||
22
kitty/options/types.py
generated
22
kitty/options/types.py
generated
@ -7,7 +7,7 @@ from kitty.conf.utils import KeyAction
|
|||||||
import kitty.conf.utils
|
import kitty.conf.utils
|
||||||
from kitty.constants import is_macos
|
from kitty.constants import is_macos
|
||||||
import kitty.constants
|
import kitty.constants
|
||||||
from kitty.options.utils import KeyDefinition, KeyMap, MouseMap, MouseMapping, SequenceMap
|
from kitty.options.utils import KeyDefinition, KeyMap, MouseMap, MouseMapping, SequenceMap, TabBarMarginHeight
|
||||||
import kitty.options.utils
|
import kitty.options.utils
|
||||||
from kitty.rgb import Color
|
from kitty.rgb import Color
|
||||||
import kitty.rgb
|
import kitty.rgb
|
||||||
@ -403,6 +403,7 @@ option_names = ( # {{{
|
|||||||
'tab_activity_symbol',
|
'tab_activity_symbol',
|
||||||
'tab_bar_background',
|
'tab_bar_background',
|
||||||
'tab_bar_edge',
|
'tab_bar_edge',
|
||||||
|
'tab_bar_margin_height',
|
||||||
'tab_bar_margin_width',
|
'tab_bar_margin_width',
|
||||||
'tab_bar_min_tabs',
|
'tab_bar_min_tabs',
|
||||||
'tab_bar_style',
|
'tab_bar_style',
|
||||||
@ -530,6 +531,7 @@ class Options:
|
|||||||
tab_activity_symbol: typing.Optional[str] = None
|
tab_activity_symbol: typing.Optional[str] = None
|
||||||
tab_bar_background: typing.Optional[kitty.rgb.Color] = None
|
tab_bar_background: typing.Optional[kitty.rgb.Color] = None
|
||||||
tab_bar_edge: int = 3
|
tab_bar_edge: int = 3
|
||||||
|
tab_bar_margin_height: TabBarMarginHeight = TabBarMarginHeight(outer=0, inner=0)
|
||||||
tab_bar_margin_width: float = 0
|
tab_bar_margin_width: float = 0
|
||||||
tab_bar_min_tabs: int = 2
|
tab_bar_min_tabs: int = 2
|
||||||
tab_bar_style: choices_for_tab_bar_style = 'fade'
|
tab_bar_style: choices_for_tab_bar_style = 'fade'
|
||||||
@ -811,10 +813,10 @@ if is_macos:
|
|||||||
defaults.map.append(KeyDefinition(False, KeyAction('edit_config_file'), 8, False, 44, ()))
|
defaults.map.append(KeyDefinition(False, KeyAction('edit_config_file'), 8, False, 44, ()))
|
||||||
defaults.mouse_map = [
|
defaults.mouse_map = [
|
||||||
MouseMapping(0, 0, -2, False, KeyAction('mouse_click_url_or_select')),
|
MouseMapping(0, 0, -2, False, KeyAction('mouse_click_url_or_select')),
|
||||||
MouseMapping(0, 1, -2, True, KeyAction('mouse_click_url_or_select')),
|
|
||||||
MouseMapping(0, 1, -2, False, KeyAction('mouse_click_url_or_select')),
|
MouseMapping(0, 1, -2, False, KeyAction('mouse_click_url_or_select')),
|
||||||
MouseMapping(0, 5, -1, True, KeyAction('mouse_click_url')),
|
MouseMapping(0, 1, -2, True, KeyAction('mouse_click_url_or_select')),
|
||||||
MouseMapping(0, 5, -1, False, KeyAction('mouse_click_url')),
|
MouseMapping(0, 5, -1, False, KeyAction('mouse_click_url')),
|
||||||
|
MouseMapping(0, 5, -1, True, KeyAction('mouse_click_url')),
|
||||||
MouseMapping(2, 0, -1, False, KeyAction('paste_selection')),
|
MouseMapping(2, 0, -1, False, KeyAction('paste_selection')),
|
||||||
MouseMapping(0, 0, 1, False, KeyAction('mouse_selection', (0,))),
|
MouseMapping(0, 0, 1, False, KeyAction('mouse_selection', (0,))),
|
||||||
MouseMapping(0, 6, 1, False, KeyAction('mouse_selection', (2,))),
|
MouseMapping(0, 6, 1, False, KeyAction('mouse_selection', (2,))),
|
||||||
@ -822,18 +824,18 @@ defaults.mouse_map = [
|
|||||||
MouseMapping(0, 0, 3, False, KeyAction('mouse_selection', (4,))),
|
MouseMapping(0, 0, 3, False, KeyAction('mouse_selection', (4,))),
|
||||||
MouseMapping(0, 6, 3, False, KeyAction('mouse_selection', (5,))),
|
MouseMapping(0, 6, 3, False, KeyAction('mouse_selection', (5,))),
|
||||||
MouseMapping(1, 0, 1, False, KeyAction('mouse_selection', (1,))),
|
MouseMapping(1, 0, 1, False, KeyAction('mouse_selection', (1,))),
|
||||||
MouseMapping(2, 1, -1, True, KeyAction('paste_selection')),
|
|
||||||
MouseMapping(2, 1, -1, False, KeyAction('paste_selection')),
|
MouseMapping(2, 1, -1, False, KeyAction('paste_selection')),
|
||||||
MouseMapping(0, 1, 1, True, KeyAction('mouse_selection', (0,))),
|
MouseMapping(2, 1, -1, True, KeyAction('paste_selection')),
|
||||||
MouseMapping(0, 1, 1, False, KeyAction('mouse_selection', (0,))),
|
MouseMapping(0, 1, 1, False, KeyAction('mouse_selection', (0,))),
|
||||||
MouseMapping(0, 7, 1, True, KeyAction('mouse_selection', (2,))),
|
MouseMapping(0, 1, 1, True, KeyAction('mouse_selection', (0,))),
|
||||||
MouseMapping(0, 7, 1, False, KeyAction('mouse_selection', (2,))),
|
MouseMapping(0, 7, 1, False, KeyAction('mouse_selection', (2,))),
|
||||||
MouseMapping(0, 1, 2, True, KeyAction('mouse_selection', (3,))),
|
MouseMapping(0, 7, 1, True, KeyAction('mouse_selection', (2,))),
|
||||||
MouseMapping(0, 1, 2, False, KeyAction('mouse_selection', (3,))),
|
MouseMapping(0, 1, 2, False, KeyAction('mouse_selection', (3,))),
|
||||||
MouseMapping(0, 1, 3, True, KeyAction('mouse_selection', (4,))),
|
MouseMapping(0, 1, 2, True, KeyAction('mouse_selection', (3,))),
|
||||||
MouseMapping(0, 1, 3, False, KeyAction('mouse_selection', (4,))),
|
MouseMapping(0, 1, 3, False, KeyAction('mouse_selection', (4,))),
|
||||||
MouseMapping(0, 7, 3, True, KeyAction('mouse_selection', (5,))),
|
MouseMapping(0, 1, 3, True, KeyAction('mouse_selection', (4,))),
|
||||||
MouseMapping(0, 7, 3, False, KeyAction('mouse_selection', (5,))),
|
MouseMapping(0, 7, 3, False, KeyAction('mouse_selection', (5,))),
|
||||||
MouseMapping(1, 1, 1, True, KeyAction('mouse_selection', (1,))),
|
MouseMapping(0, 7, 3, True, KeyAction('mouse_selection', (5,))),
|
||||||
MouseMapping(1, 1, 1, False, KeyAction('mouse_selection', (1,))),
|
MouseMapping(1, 1, 1, False, KeyAction('mouse_selection', (1,))),
|
||||||
|
MouseMapping(1, 1, 1, True, KeyAction('mouse_selection', (1,))),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -7,7 +7,8 @@ import os
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from typing import (
|
from typing import (
|
||||||
Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union
|
Any, Callable, Dict, Iterable, List, NamedTuple, Optional, Sequence, Tuple,
|
||||||
|
Union
|
||||||
)
|
)
|
||||||
|
|
||||||
import kitty.fast_data_types as defines
|
import kitty.fast_data_types as defines
|
||||||
@ -661,6 +662,20 @@ def macos_option_as_alt(x: str) -> int:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
class TabBarMarginHeight(NamedTuple):
|
||||||
|
outer: float = 0
|
||||||
|
inner: float = 0
|
||||||
|
|
||||||
|
|
||||||
|
def tab_bar_margin_height(x: str) -> TabBarMarginHeight:
|
||||||
|
parts = x.split(maxsplit=1)
|
||||||
|
if len(parts) != 2:
|
||||||
|
log_error(f'Invalid tab_bar_margin_height: {tab_bar_margin_height}, ignoring')
|
||||||
|
return TabBarMarginHeight()
|
||||||
|
ans = map(positive_float, parts)
|
||||||
|
return TabBarMarginHeight(next(ans), next(ans))
|
||||||
|
|
||||||
|
|
||||||
def clear_all_shortcuts(val: str, dict_with_parse_results: Optional[Dict[str, Any]] = None) -> bool:
|
def clear_all_shortcuts(val: str, dict_with_parse_results: Optional[Dict[str, Any]] = None) -> bool:
|
||||||
ans = to_bool(val)
|
ans = to_bool(val)
|
||||||
if ans and dict_with_parse_results is not None:
|
if ans and dict_with_parse_results is not None:
|
||||||
|
|||||||
@ -73,6 +73,9 @@ typedef struct {
|
|||||||
bool detect_urls;
|
bool detect_urls;
|
||||||
bool tab_bar_hidden;
|
bool tab_bar_hidden;
|
||||||
double font_size;
|
double font_size;
|
||||||
|
struct {
|
||||||
|
double outer, inner;
|
||||||
|
} tab_bar_margin_height;
|
||||||
} Options;
|
} Options;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user