aboutsummaryrefslogtreecommitdiff
path: root/plugins/pdfview.lua
diff options
context:
space:
mode:
authorajalexei <23712361+ajalexei@users.noreply.github.com>2021-06-15 23:07:59 +0900
committerGitHub <noreply@github.com>2021-06-15 23:07:59 +0900
commit3d3c48f3215c1d663abafefd78a0ca595565df0e (patch)
tree58e59bee047b9c6eeabd99fe7a17c59e2d2d768a /plugins/pdfview.lua
parent59bd4e61b9875df5fe155d5cc74f4c89c870db56 (diff)
downloadlite-xl-plugins-3d3c48f3215c1d663abafefd78a0ca595565df0e.tar.gz
lite-xl-plugins-3d3c48f3215c1d663abafefd78a0ca595565df0e.zip
Uploaded files
added language_bib.lua, pdfview.lua, texcompile.lua
Diffstat (limited to 'plugins/pdfview.lua')
-rw-r--r--plugins/pdfview.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/pdfview.lua b/plugins/pdfview.lua
new file mode 100644
index 0000000..41e8ad0
--- /dev/null
+++ b/plugins/pdfview.lua
@@ -0,0 +1,45 @@
+-- mod-version:1 -- lite-xl 1.16
+local core = require "core"
+local command = require "core.command"
+local keymap = require "core.keymap"
+
+command.add("core.docview", {
+ ["pdfview:show-preview"] = function()
+ local av = core.active_view
+
+-- User's home directory
+ local homedir = ""
+
+ if PLATFORM == "Windows" then
+ homedir = os.getenv("USERPROFILE")
+ else
+ homedir = os.getenv("HOME")
+ end
+
+-- The current (La)TeX file
+ local texfile = av:get_filename()
+ texfile = string.gsub(texfile, '~', homedir)
+-- Construct the PDF file name out of the (La)Tex filename
+ local pdffile = string.gsub(texfile, ".tex", ".pdf")
+-- PDF viewer - is there any provided by the environment
+ local pdfcmd = os.getenv("LITE_PDF_VIEWER")
+
+ core.log("Opening pdf preview for \"%s\"", texfile)
+
+ if pdfcmd ~= nil then
+ system.exec(pdfcmd .. " " .. pdffile)
+ elseif PLATFORM == "Windows" then
+ system.exec("start " .. pdffile)
+ else
+ system.exec(string.format("xdg-open %q", pdffile))
+ end
+
+-- core.add_thread(function()
+-- coroutine.yield(5)
+-- os.remove(htmlfile)
+-- end)
+ end
+})
+
+
+keymap.add { ["ctrl+shift+v"] = "pdfview:show-preview" }