Report dmon modify events

This commit is contained in:
Francesco Abbate 2021-10-08 23:13:50 +02:00
parent a9f6f01ed0
commit 911a3cee08
3 changed files with 20 additions and 3 deletions

View File

@ -1123,6 +1123,10 @@ function core.dir_rescan_add_job(dir, filepath)
end end
function core.on_dirmonitor_modify()
end
function core.on_dir_change(watch_id, action, filepath) function core.on_dir_change(watch_id, action, filepath)
local dir = project_dir_by_watch_id(watch_id) local dir = project_dir_by_watch_id(watch_id)
if not dir then return end if not dir then return end
@ -1131,6 +1135,9 @@ function core.on_dir_change(watch_id, action, filepath)
project_scan_remove_file(dir, filepath) project_scan_remove_file(dir, filepath)
elseif action == "create" then elseif action == "create" then
project_scan_add_file(dir, filepath) project_scan_add_file(dir, filepath)
core.on_dirmonitor_modify(dir, filepath);
elseif action == "modify" then
core.on_dirmonitor_modify(dir, filepath);
end end
end end

View File

@ -240,7 +240,19 @@ top:
case SDL_USEREVENT: case SDL_USEREVENT:
lua_pushstring(L, "dirchange"); lua_pushstring(L, "dirchange");
lua_pushnumber(L, e.user.code >> 16); lua_pushnumber(L, e.user.code >> 16);
lua_pushstring(L, (e.user.code & 0xffff) == DMON_ACTION_DELETE ? "delete" : "create"); switch (e.user.code & 0xffff) {
case DMON_ACTION_DELETE:
lua_pushstring(L, "delete");
break;
case DMON_ACTION_CREATE:
lua_pushstring(L, "create");
break;
case DMON_ACTION_MODIFY:
lua_pushstring(L, "modify");
break;
default:
return luaL_error(L, "unknown dmon event action: %d", e.user.code & 0xffff);
}
lua_pushstring(L, e.user.data1); lua_pushstring(L, e.user.data1);
free(e.user.data1); free(e.user.data1);
return 4; return 4;

View File

@ -52,8 +52,6 @@ void dirmonitor_watch_callback(dmon_watch_id watch_id, dmon_action action, const
send_sdl_event(watch_id, DMON_ACTION_DELETE, oldfilepath); send_sdl_event(watch_id, DMON_ACTION_DELETE, oldfilepath);
send_sdl_event(watch_id, DMON_ACTION_CREATE, filepath); send_sdl_event(watch_id, DMON_ACTION_CREATE, filepath);
break; break;
case DMON_ACTION_MODIFY:
break;
default: default:
send_sdl_event(watch_id, action, filepath); send_sdl_event(watch_id, action, filepath);
} }