diff options
author | jgmdev <jgmdev@gmail.com> | 2022-11-01 20:57:07 -0400 |
---|---|---|
committer | jgmdev <jgmdev@gmail.com> | 2022-11-01 20:57:07 -0400 |
commit | 49139e03398c9d0ecb347267a4882a4eb3f7ee23 (patch) | |
tree | 6ac890a209172a29e09ad47ccd0156e7f7114382 /plugins/datetimestamps.lua | |
parent | 380f6ef5fe9f8af19cd1f6b4c043eede51cbfcae (diff) | |
parent | 0971a7a686a4e18ee31b576c460966a5ec20ff01 (diff) | |
download | lite-xl-plugins-49139e03398c9d0ecb347267a4882a4eb3f7ee23.tar.gz lite-xl-plugins-49139e03398c9d0ecb347267a4882a4eb3f7ee23.zip |
Merge branch '2.1'
Diffstat (limited to 'plugins/datetimestamps.lua')
-rw-r--r-- | plugins/datetimestamps.lua | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/plugins/datetimestamps.lua b/plugins/datetimestamps.lua index 51d698e..f16af83 100644 --- a/plugins/datetimestamps.lua +++ b/plugins/datetimestamps.lua @@ -1,7 +1,8 @@ --- mod-version:2 -- lite-xl 2.0 +-- mod-version:3 local core = require "core" local config = require "core.config" local command = require "core.command" +local common = require "core.common" --[[ Date and time format placeholders @@ -25,11 +26,36 @@ from https://www.lua.org/pil/22.1.html %y two-digit year (98) [00-99] %% the character `%ยด --]] -config.plugins.datetimestamps = { - format_datestamp = "%Y%m%d" - format_datetimestamp = "%Y%m%d_%H%M%S" - format_timestamp = "%H%M%S" -} +config.plugins.datetimestamps = common.merge({ + format_datestamp = "%Y%m%d", + format_datetimestamp = "%Y%m%d_%H%M%S", + format_timestamp = "%H%M%S", + -- The config specification used by the settings gui + config_spec = { + name = "Date and Time Stamps", + { + label = "Date", + description = "Date specification defined with Lua date/time place holders.", + path = "format_datestamp", + type = "string", + default = "%Y%m%d" + }, + { + label = "Time", + description = "Time specification defined with Lua date/time place holders.", + path = "format_timestamp", + type = "string", + default = "%H%M%S" + }, + { + label = "Date and Time", + description = "Date and time specification defined with Lua date/time place holders.", + path = "format_datetimestamp", + type = "string", + default = "%Y%m%d_%H%M%S" + } + } +}, config.plugins.datetimestamps) local function datestamp() local sOut = os.date(config.plugins.datetimestamps.format_datestamp) @@ -49,6 +75,13 @@ end command.add("core.docview", { ["datetimestamps:insert-datestamp"] = datestamp, ["datetimestamps:insert-timestamp"] = timestamp, - ["datetimestamps:insert-datetimestamp"] = datetimestamp + ["datetimestamps:insert-datetimestamp"] = datetimestamp, + ["datetimestamps:insert-custom"] = function() + core.command_view:enter("Date format eg: %H:%M:%S", { + submit = function(cmd) + core.active_view.doc:text_input(os.date(cmd) or "") + end + }) + end, }) |