Skip to content

Commit d792379

Browse files
committed
Create yield.lua
darktable yield compatibility script
1 parent a85d222 commit d792379

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

official/yield.lua

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
--[[
2+
This file is part of darktable,
3+
Copyright 2016 by Tobias Jakobs.
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation; either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
]]
18+
--[[
19+
darktable yield compatibility script
20+
21+
USAGE
22+
* require this script from your main Lua file in the first line
23+
24+
]]
25+
local dt = require "darktable"
26+
local yield_orig = coroutine.yield
27+
28+
-- ToDo: Test with dt master
29+
--[[
30+
if (dt.configuration.api_version_major >= 4) then
31+
coroutine.yield = function(yield_type, command)
32+
if (yield_type == "RUN_COMMAND") then
33+
dt.control.execute(command)
34+
elseif (yield_type == "FILE_READABLE") then
35+
dt.control.read(command)
36+
elseif (yield_type == "WAIT_MS") then
37+
dt.control.sleep(command)
38+
end
39+
end
40+
end
41+
]]
42+
43+
if (dt.configuration.api_version_major < 4) then
44+
dt.control = {}
45+
dt.control.execute = function(command)
46+
yield_orig("RUN_COMMAND", command)
47+
end
48+
dt.control.read = function(command)
49+
yield_orig("FILE_READABLE", command)
50+
end
51+
dt.control.sleep = function(command)
52+
yield_orig("WAIT_MS", command)
53+
end
54+
end
55+
56+
-- vim: shiftwidth=2 expandtab tabstop=2 cindent syntax=lua
57+
-- kate: hl Lua;

0 commit comments

Comments
 (0)