class Kind(Openable): def __init__(self, vim: Nvim) -> None: super().__init__(vim) self.name = "dwm" self.default_action = "focus" self.redraw_actions += ["delete"] self.persist_actions += ["delete"] self.__kind = Window(vim) def action_focus(self, context: UserContext) -> None: self.action_jump(context) self.vim.call("DWM_Focus") def action_open(self, context: UserContext) -> None: self.__kind.open(context["targets"]) def action_jump(self, context: UserContext) -> None: self.__kind.jump(context["targets"][0]) def action_only(self, context: UserContext) -> None: self.__kind.only(context["targets"][0]) def action_delete(self, context: UserContext) -> None: self.__kind.delete(context["targets"]) self.vim.command("wincmd H") self.vim.call("DWM_ResizeMasterPaneWidth")
def test_delete(vim: Nvim) -> None: vim.command("edit text1") vim.command("split text2") vim.command("split text3") vim.command("tabnew") vim.command("edit text4") vim.command("split text5") vim.command("split text6") w = Window(vim) w.delete([ { "action__tabnr": 1, "action__winnr": 1 }, # text3 { "action__tabnr": 1, "action__winnr": 2 }, # text2 { "action__tabnr": 2, "action__winnr": 1 }, # text6 { "action__tabnr": 2, "action__winnr": 2 }, # text5 ]) assert vim.funcs.winnr("$") == 1 assert Path(vim.tabpages[0].window.buffer.name).name == "text1" assert Path(vim.tabpages[1].window.buffer.name).name == "text4"
class Kind(Openable): def __init__(self, vim: Nvim) -> None: super().__init__(vim) self.name = "window" self.default_action = "jump" self.redraw_actions += ["delete"] self.persist_actions += ["delete"] self.__kind = Window(vim) def action_open(self, context: UserContext) -> None: self.__kind.open(context["targets"][0]) def action_jump(self, context: UserContext) -> None: self.__kind.jump(context["targets"][0]) def action_only(self, context: UserContext) -> None: self.__kind.only(context["targets"][0]) def action_delete(self, context: UserContext) -> None: self.__kind.delete(context["targets"])