aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorajalexei <23712361+ajalexei@users.noreply.github.com>2021-06-17 11:27:09 +0900
committerGitHub <noreply@github.com>2021-06-17 11:27:09 +0900
commiteff60118b8bba6e71d6d6844ff026a8821cacfd3 (patch)
tree5222faa9f66f5dc802c76b6410865f88dc965a4a /plugins
parent5700d2f77bd356aede9bbc33d197f9c5e6914cd1 (diff)
parent081665d20f2ad1a9b8b516f24438fd73cd6324f3 (diff)
downloadlite-xl-plugins-eff60118b8bba6e71d6d6844ff026a8821cacfd3.tar.gz
lite-xl-plugins-eff60118b8bba6e71d6d6844ff026a8821cacfd3.zip
Merge branch 'lite-xl:master' into master
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ephemeraldocviews.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/ephemeraldocviews.lua b/plugins/ephemeraldocviews.lua
new file mode 100644
index 0000000..37b3a3b
--- /dev/null
+++ b/plugins/ephemeraldocviews.lua
@@ -0,0 +1,45 @@
+-- mod-version:1 -- lite-xl 1.16
+local core = require "core"
+local command = require "core.command"
+local RootView = require "core.rootview"
+local DocView = require "core.docview"
+local Doc = require "core.doc"
+
+local open_doc = RootView.open_doc
+function RootView:open_doc(doc)
+ local node = self:get_active_node_default()
+ local ephemeral, existing_ephemeral = node.views, nil
+ for i, view in ipairs(node.views) do
+ if view.doc == doc then
+ ephemeral = false
+ end
+ if view.doc and view.doc.ephemeral then
+ existing_ephemeral = view
+ end
+ end
+ if ephemeral and existing_ephemeral then
+ node:close_view(self.root_node, existing_ephemeral)
+ end
+ local view = open_doc(self, doc)
+ if ephemeral then
+ view.doc.ephemeral = #node.views > 1
+ end
+ return view
+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)
+end
+
+local doc_insert = Doc.insert
+function Doc:insert(...)
+ doc_insert(self, ...)
+ self.ephemeral = false
+end
+
+local doc_remove = Doc.remove
+function Doc:remove(...)
+ doc_remove(self, ...)
+ self.ephemeral = false
+end