diff options
author | Jipok <braaga@inbox.ru> | 2021-12-11 00:05:24 +0500 |
---|---|---|
committer | Jipok <braaga@inbox.ru> | 2021-12-11 01:21:18 +0500 |
commit | 56ab78215af3167cab4cc213e09a1ba88cf5a6af (patch) | |
tree | 87b61d26a5020b4a1367f6f812c7a7ada95b83f2 | |
parent | a6be89eb28208a670b2f83ad2983f503410d5f6c (diff) | |
download | lite-xl-plugins-56ab78215af3167cab4cc213e09a1ba88cf5a6af.tar.gz lite-xl-plugins-56ab78215af3167cab4cc213e09a1ba88cf5a6af.zip |
EphemeralDocViews: improve with double clicks
-rw-r--r-- | plugins/ephemeraldocviews.lua | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/plugins/ephemeraldocviews.lua b/plugins/ephemeraldocviews.lua index cb9f53d..1169d7f 100644 --- a/plugins/ephemeraldocviews.lua +++ b/plugins/ephemeraldocviews.lua @@ -4,6 +4,7 @@ local command = require "core.command" local RootView = require "core.rootview" local DocView = require "core.docview" local Doc = require "core.doc" +local TreeView = require "plugins.treeview" local open_doc = RootView.open_doc function RootView:open_doc(doc) @@ -29,7 +30,7 @@ end local get_name = DocView.get_name function DocView:get_name() - return self.doc and self.doc.ephemeral and ("-- " .. get_name(self) .. " --") or get_name(self) + return self.doc and self.doc.ephemeral and ("~ " .. get_name(self) .. " ~") or get_name(self) end local doc_insert = Doc.insert @@ -43,3 +44,27 @@ function Doc:remove(...) doc_remove(self, ...) self.ephemeral = false end + +-- Double clicking in the TreeView makes the tab normal +local TreeView_original_event = TreeView.on_mouse_pressed +function TreeView:on_mouse_pressed(button, x, y, clicks) + TreeView_original_event(self, button, x, y, clicks) + if (clicks > 1) and (core.active_view.doc ~= nil) then + core.active_view.doc.ephemeral = false + end +end + +-- Double clicking on a tab makes it normal +local RootView_original_event = RootView.on_mouse_pressed +function RootView:on_mouse_pressed(button, x, y, clicks) + if RootView_original_event(self, button, x, y, clicks) then + if clicks > 1 then + local node = self.root_node:get_child_overlapping_point(x, y) + local idx = node:get_tab_overlapping_point(x, y) + if idx then + node.views[idx].doc.ephemeral = false + end + end + return true + end +end |