diff options
author | mitchell <70453897+667e-11@users.noreply.github.com> | 2018-09-10 14:19:19 -0400 |
---|---|---|
committer | mitchell <70453897+667e-11@users.noreply.github.com> | 2018-09-10 14:19:19 -0400 |
commit | 638130774ecbd81a8438adb61385208f584659ae (patch) | |
tree | f58bab99129f23b8667c542e1703dd7938329080 /core | |
parent | 8f1b55bfb7dfe2272d489dc70c745e6125662a0c (diff) |
Added ability to save/restore persistent data during reset.
Diffstat (limited to 'core')
-rw-r--r-- | core/events.lua | 8 | ||||
-rw-r--r-- | core/ui.lua | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/core/events.lua b/core/events.lua index b5996baa..98a3475b 100644 --- a/core/events.lua +++ b/core/events.lua @@ -217,9 +217,17 @@ local M = {} -- @field RESET_AFTER (string) -- Emitted after resetting the Lua state. -- Emitted by [`reset()`](). +-- Arguments: +-- +-- * _`persist`_: Table of data persisted by `events.RESET_BEFORE`. All +-- handlers will have access to this same table. -- @field RESET_BEFORE (string) -- Emitted before resetting the Lua state. -- Emitted by [`reset()`](). +-- Arguments: +-- +-- * _`persist`_: Table to store persistent data in for use by +-- `events.RESET_AFTER`. All handlers will have access to this same table. -- @field RESUME (string) -- Emitted when resuming Textadept from a suspended state. -- This event is only emitted by the terminal version. diff --git a/core/ui.lua b/core/ui.lua index 87e88ffb..be5d637b 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -187,6 +187,12 @@ events.connect(events.BUFFER_AFTER_SWITCH, function() table.insert(buffers_zorder, 1, buffer) end) +-- Saves and restores buffer zorder data during a reset. +events.connect(events.RESET_BEFORE, + function(persist) persist.buffers_zorder = buffers_zorder end) +events.connect(events.RESET_AFTER, + function(persist) buffers_zorder = persist.buffers_zorder end) + --- -- Prompts the user to select a buffer to switch to. -- Buffers are listed in the order they were opened unless `zorder` is `true`, |