Add align_top_left option to avoid a padding on the top/left
This commit is contained in:
parent
1e8f1f8cc6
commit
961ff8633d
@ -28,7 +28,7 @@ from .fast_data_types import (
|
||||
toggle_maximized
|
||||
)
|
||||
from .keys import get_shortcut, shortcut_matches
|
||||
from .layout import set_draw_borders_options
|
||||
from .layout import set_layout_options
|
||||
from .remote_control import handle_cmd
|
||||
from .rgb import Color, color_from_int
|
||||
from .session import create_sessions
|
||||
@ -105,7 +105,7 @@ class DumpCommands: # {{{
|
||||
class Boss:
|
||||
|
||||
def __init__(self, os_window_id, opts, args, cached_values, new_os_window_trigger):
|
||||
set_draw_borders_options(opts)
|
||||
set_layout_options(opts)
|
||||
self.clipboard_buffers = {}
|
||||
self.update_check_process = None
|
||||
self.window_id_map = WeakValueDictionary()
|
||||
|
||||
@ -558,6 +558,10 @@ value :code:`all` means all layouts. The first listed layout will be used as the
|
||||
startup layout. For a list of available layouts, see the :ref:`layouts`.
|
||||
'''))
|
||||
|
||||
o('align_top_left', False, long_text=_('''
|
||||
Align terminal to the top left corner, i.e. put padding on the bottom and right. Default is centered.
|
||||
'''))
|
||||
|
||||
o('window_resize_step_cells', 2, option_type=positive_int, long_text=_('''
|
||||
The step size (in units of cell width/cell height) to use when resizing
|
||||
windows. The cells value is used for horizontal resizing and the lines value
|
||||
|
||||
@ -18,6 +18,7 @@ all_borders = True, True, True, True
|
||||
no_borders = False, False, False, False
|
||||
draw_minimal_borders = False
|
||||
draw_active_borders = True
|
||||
align_top_left = False
|
||||
|
||||
|
||||
def idx_for_id(win_id, windows):
|
||||
@ -26,10 +27,11 @@ def idx_for_id(win_id, windows):
|
||||
return i
|
||||
|
||||
|
||||
def set_draw_borders_options(opts):
|
||||
global draw_minimal_borders, draw_active_borders
|
||||
def set_layout_options(opts):
|
||||
global draw_minimal_borders, draw_active_borders, align_top_left
|
||||
draw_minimal_borders = opts.draw_minimal_borders and opts.window_margin_width == 0
|
||||
draw_active_borders = opts.active_border_color is not None
|
||||
align_top_left = bool(opts.align_top_left)
|
||||
|
||||
|
||||
def layout_dimension(start_at, length, cell_length, decoration_pairs, left_align=False, bias=None):
|
||||
@ -86,9 +88,9 @@ def window_geometry(xstart, xnum, ystart, ynum):
|
||||
return WindowGeometry(left=xstart, top=ystart, xnum=xnum, ynum=ynum, right=xstart + cell_width * xnum, bottom=ystart + cell_height * ynum)
|
||||
|
||||
|
||||
def layout_single_window(xdecoration_pairs, ydecoration_pairs):
|
||||
xstart, xnum = next(layout_dimension(central.left, central.width, cell_width, xdecoration_pairs))
|
||||
ystart, ynum = next(layout_dimension(central.top, central.height, cell_height, ydecoration_pairs))
|
||||
def layout_single_window(xdecoration_pairs, ydecoration_pairs, left_align=False):
|
||||
xstart, xnum = next(layout_dimension(central.left, central.width, cell_width, xdecoration_pairs, left_align=align_top_left))
|
||||
ystart, ynum = next(layout_dimension(central.top, central.height, cell_height, ydecoration_pairs, left_align=align_top_left))
|
||||
return window_geometry(xstart, xnum, ystart, ynum)
|
||||
|
||||
|
||||
@ -368,12 +370,12 @@ class Layout: # {{{
|
||||
def xlayout(self, num, bias=None):
|
||||
decoration = self.margin_width + self.border_width + self.padding_width
|
||||
decoration_pairs = tuple(repeat((decoration, decoration), num))
|
||||
return layout_dimension(central.left, central.width, cell_width, decoration_pairs, bias=bias)
|
||||
return layout_dimension(central.left, central.width, cell_width, decoration_pairs, bias=bias, left_align=align_top_left)
|
||||
|
||||
def ylayout(self, num, left_align=True, bias=None):
|
||||
decoration = self.margin_width + self.border_width + self.padding_width
|
||||
decoration_pairs = tuple(repeat((decoration, decoration), num))
|
||||
return layout_dimension(central.top, central.height, cell_height, decoration_pairs, bias=bias)
|
||||
return layout_dimension(central.top, central.height, cell_height, decoration_pairs, bias=bias, left_align=align_top_left)
|
||||
|
||||
def simple_blank_rects(self, first_window, last_window):
|
||||
br = self.blank_rects
|
||||
@ -417,7 +419,7 @@ class Stack(Layout): # {{{
|
||||
def do_layout(self, windows, active_window_idx):
|
||||
mw = self.margin_width if self.single_window_margin_width < 0 else self.single_window_margin_width
|
||||
decoration_pairs = ((mw + self.padding_width, mw + self.padding_width),)
|
||||
wg = layout_single_window(decoration_pairs, decoration_pairs)
|
||||
wg = layout_single_window(decoration_pairs, decoration_pairs, left_align=align_top_left)
|
||||
for i, w in enumerate(windows):
|
||||
w.set_geometry(i, wg)
|
||||
if w.is_visible_in_layout:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user