fix some complicated layouts

This commit is contained in:
David Levanon 2020-09-20 21:15:14 +03:00
parent b595bec775
commit 69c8a3f1d9
1 changed files with 12 additions and 12 deletions

View File

@ -14,9 +14,6 @@ class LayoutFile(object):
} }
} }
if len(layoutjson) == 1:
self.build_terminal_layout(layoutjson, result, 'root', 0)
else:
self.build_container_layout(layoutjson, result, 'root', 0, vertical) self.build_container_layout(layoutjson, result, 'root', 0, vertical)
return result return result
@ -41,9 +38,6 @@ class LayoutFile(object):
for tab in layoutjson: for tab in layoutjson:
tabs['labels'].append(tab) tabs['labels'].append(tab)
if len(layoutjson[tab]) == 1:
self.build_terminal_layout(layoutjson[tab][0], result, 'tabs', counter)
else:
self.build_container_layout(layoutjson[tab], result, 'tabs', counter, vertical) self.build_container_layout(layoutjson[tab], result, 'tabs', counter, vertical)
counter += 1 counter += 1
@ -60,6 +54,15 @@ class LayoutFile(object):
} }
def build_container_layout(self, layoutjson, children, parent, order, vertical): def build_container_layout(self, layoutjson, children, parent, order, vertical):
if len(layoutjson) == 1:
layoutjson = layoutjson[0]
if 'children' in layoutjson:
self.build_container_layout(layoutjson['children'], children, parent, order, False if vertical else True)
else:
self.build_terminal_layout(layoutjson, children, parent, order)
return
dbg ('Building %s layout from json: %s' % ("vertical" if vertical else "horizental", layoutjson)) dbg ('Building %s layout from json: %s' % ("vertical" if vertical else "horizental", layoutjson))
counter = 0 counter = 0
@ -78,9 +81,6 @@ class LayoutFile(object):
actualparent = containername actualparent = containername
if 'children' in pane: if 'children' in pane:
if len(pane['children']) == 1:
self.build_terminal_layout(pane, pane['children'], containername, counter)
else:
self.build_container_layout(pane['children'], children, containername, counter, False if vertical else True) self.build_container_layout(pane['children'], children, containername, counter, False if vertical else True)
else: else:
self.build_terminal_layout(pane, children, containername, counter) self.build_terminal_layout(pane, children, containername, counter)