Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rearrange Plugin Loading and SDL Initialization #1881

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
d5940b6
Initial commit to clean up projects; spun off find-file to its own pl…
adamharrison Apr 1, 2023
2f4aff1
Bump modversion.
adamharrison Jun 22, 2024
a716131
Bumped modversion and changed a few minor things.
adamharrison Jun 22, 2024
f2fd9ba
Added in handling of ignored files.
adamharrison Jun 22, 2024
0350614
Fixed small issue.
adamharrison Jun 27, 2024
3cc4543
Fixed issue with absolute arguments.
adamharrison Jul 5, 2024
9e2ec1b
Removed home encoding; may revert this if I can find out why it was d…
adamharrison Jul 7, 2024
9c05676
Fixed minor issue with file suggestions.
adamharrison Aug 22, 2024
0303199
Cleaned up treeview.
adamharrison Aug 22, 2024
41f8206
Typo.
adamharrison Aug 22, 2024
59650ec
Added in visible.
adamharrison Aug 23, 2024
056a2cb
Ensured that the appropriate project module is loaded.
adamharrison Sep 10, 2024
975e416
Fixed improper rebase.
adamharrison Sep 10, 2024
17a3503
Abstracted out the storage system of the workspace plugin so other pl…
adamharrison Mar 6, 2024
3de9036
Fixed double return.
adamharrison Mar 6, 2024
a8fce83
Fixed functional issue.
adamharrison Mar 6, 2024
11af515
Added documentation.
adamharrison Apr 3, 2024
b84738f
Sumenko reports duplicate function definitions, unsure why.
adamharrison Apr 3, 2024
d5dbfad
Fixed minor bug with workspace.
adamharrison Sep 28, 2024
7be990f
Fixed switching projects on restart.
adamharrison Oct 9, 2024
f2a66b4
Merge branch 'master' into PR/project-rework
adamharrison Oct 22, 2024
00d708c
Harmonized spacing around asserts, and fixed an issue forgetting to s…
adamharrison Nov 3, 2024
86388a6
Made project an object.
adamharrison Nov 3, 2024
62bc82e
Removing unecessary yields.
adamharrison Nov 3, 2024
28b7029
Removed unecessary fallback.
adamharrison Nov 3, 2024
fed7967
Removed unecessary line.
adamharrison Nov 3, 2024
64b5f57
Reveted backslash handling, as it doesn't seem to make any difference.
adamharrison Nov 3, 2024
8e0ae38
Spacing.
adamharrison Nov 3, 2024
320695c
Only stonks.
adamharrison Nov 3, 2024
19046d0
Removed uneeded error handling.
adamharrison Nov 3, 2024
fef8f81
Added in function to determine project by path, and added in deprecat…
adamharrison Nov 3, 2024
dcb0ee6
Merge branch 'master' into PR/project-rework
adamharrison Nov 3, 2024
0bb8d7e
Removed storage module.
adamharrison Nov 3, 2024
283b0ae
Typo.
adamharrison Nov 3, 2024
0a3b440
Changed to use deprecation log instead of regular warn so as to not s…
adamharrison Nov 27, 2024
10f2ab9
Fixed small bug with saving workspaces on project change.
adamharrison Nov 27, 2024
b20a85c
Revert "Removed storage module."
adamharrison Nov 3, 2024
84d62d2
Initial commit.
adamharrison Sep 15, 2024
2b2a009
Moved around plugin initialization.
adamharrison Sep 16, 2024
9491db9
Fixing restarting when changing projects.
adamharrison Sep 16, 2024
e1f5d69
Added in autorestart plugin.
adamharrison Sep 16, 2024
dbb75bf
Moved screensaver call to after video subsystem init.
adamharrison Sep 16, 2024
cc1d209
Fixed minor issue.
adamharrison Sep 16, 2024
154d1d1
Missing extension.
adamharrison Sep 16, 2024
0f7c3dc
Kept initailization of previous_find and previous_replace.
adamharrison Sep 16, 2024
d7b15e8
Allowed priority regex to take a decimal place.
adamharrison Sep 16, 2024
a2ac9f6
Fixed priority regex.
adamharrison Sep 16, 2024
18382f6
Fixed version mismatch error.
adamharrison Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removed storage module.
  • Loading branch information
adamharrison committed Nov 3, 2024
commit 0bb8d7ec052f2d6412b7ee3459dfb75a694f7ad0
78 changes: 0 additions & 78 deletions data/core/storage.lua

This file was deleted.

63 changes: 42 additions & 21 deletions data/plugins/workspace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,59 @@ local core = require "core"
local common = require "core.common"
local DocView = require "core.docview"
local LogView = require "core.logview"
local storage = require "core.storage"

local STORAGE_MODULE = "ws"

local function workspace_keys_for(project_dir)
local function workspace_files_for(project_dir)
local basename = common.basename(project_dir)
local workspace_dir = USERDIR .. PATHSEP .. "ws"
local info_wsdir = system.get_file_info(workspace_dir)
if not info_wsdir then
local ok, err = system.mkdir(workspace_dir)
if not ok then
error("cannot create workspace directory: \"" .. err .. "\"")
end
end
return coroutine.wrap(function()
for _, key in ipairs(storage.keys(STORAGE_MODULE) or {}) do
if key:sub(1, #basename) == basename then
local id = tonumber(key:sub(#basename + 1):match("^-(%d+)$"))
local files = system.list_dir(workspace_dir) or {}
local n = #basename
for _, file in ipairs(files) do
if file:sub(1, n) == basename then
local id = tonumber(file:sub(n + 1):match("^-(%d+)$"))
if id then
coroutine.yield(key, id)
coroutine.yield(workspace_dir .. PATHSEP .. file, id)
end
end
end
end)
end


local function consume_workspace(project_dir)
for key, id in workspace_keys_for(project_dir) do
local workspace = storage.load(STORAGE_MODULE, key)
local function consume_workspace_file(project_dir)
for filename, id in workspace_files_for(project_dir) do
local load_f = loadfile(filename)
local workspace = load_f and load_f()
if workspace and workspace.path == project_dir then
storage.clear(STORAGE_MODULE, key)
os.remove(filename)
return workspace
end
end
end


local function get_workspace_filename(project_dir)
local id_list = {}
for filename, id in workspace_files_for(project_dir) do
id_list[id] = true
end
local id = 1
while id_list[id] do
id = id + 1
end
local basename = common.basename(project_dir)
return USERDIR .. PATHSEP .. "ws" .. PATHSEP .. basename .. "-" .. tostring(id)
end


local function has_no_locked_children(node)
if node.locked then return false end
if node.type == "leaf" then return true end
Expand Down Expand Up @@ -172,17 +195,15 @@ end


local function save_workspace()
local project_dir = common.basename(core.root_project().path)
local id_list = {}
for filename, id in workspace_keys_for(project_dir) do
id_list[id] = true
end
local id = 1
while id_list[id] do
id = id + 1
local project_dir = core.root_project().path
local workspace_filename = get_workspace_filename(project_dir)
local fp = io.open(workspace_filename, "w")
if fp then
local node_text = common.serialize(save_node(root))
local dir_text = common.serialize(save_directories())
fp:write(string.format("return { path = %q, documents = %s, directories = %s }\n", core.project_dir, node_text, dir_text))
fp:close()
end
local root = get_unlocked_root(core.root_view.root_node)
storage.save(STORAGE_MODULE, project_dir .. "-" .. id, { path = core.root_project().path, documents = save_node(root), directories = save_directories() })
end


Expand Down