From 9ad65f2e1dfc9b44326f45edcd1d882fbc586b4c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 23 Jan 2018 19:35:30 +0530 Subject: [PATCH] Cleanup layouts patch Fix bottom rect in horizontal layout not covering all windows. Fix pep8 issues. Add README and CHANGELOG entries. --- CHANGELOG.rst | 2 ++ README.asciidoc | 4 +++- kitty/layout.py | 10 ++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f65f66201..b4509957e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,8 @@ version 0.7.0 [future] - Add option to override the default shell +- Add "Horizontal" and "Vertical" window layouts + - Sessions: Allow setting titles and working directories for individual windows - Option to copy to clipboard on mouse select diff --git a/README.asciidoc b/README.asciidoc index 7d8096308..35783cbe5 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -265,8 +265,10 @@ hold down `ctrl+shift` and click on a URL to open it in a browser. Currently, there are three layouts available, * Stack -- Only a single maximized window is shown at a time -* Tall -- One window is shown full height on the left, the rest of the windows are shown one below the other on the right. +* Tall -- One window is shown full height on the left, the rest of the windows are shown one below the other on the right * Grid -- All windows are shown in a grid +* Horizontal -- All windows are shown side-by-side +* Vertical -- All windows are shown one below the other You can switch between layouts using the {sc_next_layout} key combination. diff --git a/kitty/layout.py b/kitty/layout.py index 61892ec2d..cc2376002 100644 --- a/kitty/layout.py +++ b/kitty/layout.py @@ -241,6 +241,7 @@ class Grid(Tall): for i in range(ncols - 1): self.between_blank_rect(win_col_map[i][0], win_col_map[i + 1][0]) + class Vertical(Layout): name = 'vertical' @@ -256,7 +257,7 @@ class Vertical(Layout): xlayout = self.xlayout(1) xstart, xnum = next(xlayout) - ylayout = self.ylayout(window_count) + ylayout = self.ylayout(window_count) for i in range(window_count): ystart, ynum = next(ylayout) @@ -264,7 +265,7 @@ class Vertical(Layout): # left, top and right blank rects self.simple_blank_rects(windows[0], windows[-1]) - #bottom blank rect + # bottom blank rect self.bottom_blank_rect(windows[-1]) @@ -294,7 +295,8 @@ class Horizontal(Layout): # left, top and right blank rects self.simple_blank_rects(windows[0], windows[-1]) - #bottom blank rect - self.bottom_blank_rect(windows[0]) + # bottom blank rect + self.blank_rects.append(Rect(windows[0].geometry.left, windows[0].geometry.bottom, windows[-1].geometry.right, central.bottom + 1)) + all_layouts = {o.name: o for o in globals().values() if isinstance(o, type) and issubclass(o, Layout) and o is not Layout}