aboutsummaryrefslogtreecommitdiff
path: root/plugins/closeconfirmx.lua
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2021-04-21 13:37:22 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2021-04-21 13:37:22 +0200
commit787f31d3eb85541726e066472e1fd20c44939393 (patch)
tree2de7f6076577e18b5bb01ad7539bf4a8993cada6 /plugins/closeconfirmx.lua
parentb09046a719cafa8f75c542123828cd76be460a2a (diff)
parent2fefdae0bb729edb29c6b90e89d34a9e664fbf14 (diff)
downloadlite-xl-plugins-787f31d3eb85541726e066472e1fd20c44939393.tar.gz
lite-xl-plugins-787f31d3eb85541726e066472e1fd20c44939393.zip
Merge branch 'lite-xl-1.16'
Diffstat (limited to 'plugins/closeconfirmx.lua')
-rw-r--r--plugins/closeconfirmx.lua54
1 files changed, 0 insertions, 54 deletions
diff --git a/plugins/closeconfirmx.lua b/plugins/closeconfirmx.lua
deleted file mode 100644
index 805fe3b..0000000
--- a/plugins/closeconfirmx.lua
+++ /dev/null
@@ -1,54 +0,0 @@
--- CloseConfirmX plugin for lite text editor
--- implementation by chekoopa
-
-local core = require "core"
-local config = require "core.config"
-
-config.closeconfirmx_use_legacy = false
-config.closeconfirmx_use_short_name = true
-
-local legacy_confirm = core.confirm_close_all
-
-local function commandful_confirm()
- local dirty_count = 0
- local dirty_name
- for _, doc in ipairs(core.docs) do
- if doc:is_dirty() then
- dirty_count = dirty_count + 1
- dirty_name = doc:get_name()
- end
- end
- if dirty_count > 0 then
- local text
- if dirty_count == 1 then
- if config.closeconfirmx_use_short_name then
- dirty_name = dirty_name:match("[^/%\\]*$")
- end
- text = string.format("Unsaved changes in \"%s\"; Confirm Exit", dirty_name)
- else
- text = string.format("Unsaved changes in %d docs; Confirm Exit", dirty_count)
- end
- core.command_view:enter(text, function(_, item)
- if item.text:match("^[cC]") then
- core.quit(true)
- end
- end, function(text)
- local items = {}
- if not text:find("^[^sS]") then table.insert(items, "Stay here") end
- if not text:find("^[^cC]") then table.insert(items, "Close Without Saving") end
- return items
- end)
- -- as we delegate a choice inside the callback,
- return false
- end
- return true
-end
-
-function core.confirm_close_all()
- if config.closeconfirmx_use_legacy then
- return legacy_confirm()
- else
- return commandful_confirm()
- end
-end
-