Exemplo n.º 1
0
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"
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
def test_only(vim: Nvim) -> None:
    vim.command("edit text1")
    vim.command("split text2")
    vim.command("split text3")
    w = Window(vim)
    w.only({"action__tabnr": 1, "action__winnr": 1})  # text3
    assert vim.funcs.winnr("$") == 1
    assert Path(vim.current.buffer.name).name == "text3"
Exemplo n.º 4
0
def test_jump(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.jump({"action__tabnr": 1, "action__winnr": 3})  # text1
    assert Path(vim.current.buffer.name).name == "text1"
Exemplo n.º 5
0
def test_open(vim: Nvim) -> None:
    vim.command("edit text1")
    vim.command("split text2")
    vim.command("split text3")
    w = Window(vim)
    w.open({"action__tabnr": 1, "action__winnr": 3})  # text1
    assert [Path(x.buffer.name).name for x in vim.windows] == [
        "text1",
        "text2",
        "text1",
    ]
Exemplo n.º 6
0
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")
Exemplo n.º 7
0
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"])