def rotate(self, count=<NUM_LIT:1>, with_pane_before_only=False, with_pane_after_only=False):
<EOL>items = []<EOL>current_pane_index = None<EOL>for s in self.splits:<EOL><INDENT>for index, item in enumerate(s):<EOL><INDENT>if isinstance(item, Pane):<EOL><INDENT>items.append((s, index, item, s.weights[item]))<EOL>if item == self.active_pane:<EOL><INDENT>current_pane_index = len(items) - <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT><DEDENT>if with_pane_before_only:<EOL><INDENT>items = items[current_pane_index - <NUM_LIT:1>:current_pane_index + <NUM_LIT:1>]<EOL><DEDENT>elif with_pane_after_only:<EOL><INDENT>items = items[current_pane_index:current_pane_index + <NUM_LIT:2>]<EOL><DEDENT>for i, triple in enumerate(items):<EOL><INDENT>split, index, pane, weight = triple<EOL>new_item = items[(i + count) % len(items)][<NUM_LIT:2>]<EOL>split[index] = new_item<EOL>split.weights[new_item] = weight<EOL><DEDENT>
Rotate panes.
When `with_pane_before_only` or `with_pane_after_only` is True, only rotate
with the pane before/after the active pane.