Platform: Windows 7
I use the Director Interface to update the value of api.$(file.patterns.inno) in Inno scripts depending on which Inno section that is being edited, as each section may have different api file(s). Without calling ReloadProperties(), changing the value has no effect unless an event like changing tabs is done, which is an inefficent method to reload the properties.
Use of the Lua subsystem and with the use of RSciTE's rluawfx-en.dll (source, especially luawfx.cpp), may need to use a C++ DLL function c_SendCmdScite('reloadproperties:') which is sent through the Director Interface to reload the properties. This is called from SetAPIProperty and then SendCmdScite in Lua. A warning may print to the output pane if multiple SciTE instances exist and the messaged Director Interface is the incorrect instance. This is not a desired solution so I have an interest in something better.
This current behaviour is only reliable with 1 instance of SciTE, else the message maybe sent to the Director Interface of the other instance of SciTE, which is not wanted. There might be workarounds, like tracking handles of the Director Interface windows, changing Z-order perhaps, though the Lua Subsystem is lacking ability with that option.
The intergrated Lua Subsystem could have a more direct method to achieve this goal.
A possible fix to replace SendCmdScite('reloadproperties:') with scite.ReloadProperties() once these patches are applied.
The help file:
--- a/scite/doc/SciTELua.html
+++ b/scite/doc/SciTELua.html
@@ -264,6 +264,9 @@
scite.MenuCommand(IDM_constant)
- equivalent to the corresponding IDM_ command defined in SciTE.h
+
+ scite.ReloadProperties()
+ - performs a reload of properties
</tt></pre><p>
<tt>Open</tt> requires special care. When the buffer changes in SciTE, the
Lua global namespace is reset to its initial state, and any extension
@@ -288,6 +291,10 @@
</p><p>
The <tt>MenuCommand</tt> function enables usage of SciTE's menu commands
as defined in SciTE.h.
+</p><p>
+The <tt>ReloadProperties</tt> function performs similar to the
+SciTE Director Interface action of 'reloadproperties:', without
+the need to send the message to the Director window.
</p>
<h4>Scripting user interfaces with strips</h4>
The Lua extension file:
--- a/scite/src/LuaExtension.cxx
+++ b/scite/src/LuaExtension.cxx
@@ -299,6 +299,13 @@
return 0;
}
+static int cf_scite_reload_properties(lua_State *L) {
+ if (!lua_gettop(L)) {
+ host->Perform("reloadproperties:");
+ }
+ return 0;
+}
+
static int cf_scite_menu_command(lua_State *L) {
const int cmdID = luaL_checkint(L, 1);
if (cmdID) {
@@ -1410,6 +1417,9 @@
lua_pushcfunction(luaState, cf_scite_open);
lua_setfield(luaState, -2, "Open");
+
+ lua_pushcfunction(luaState, cf_scite_reload_properties);
+ lua_setfield(luaState, -2, "ReloadProperties");
lua_pushcfunction(luaState, cf_scite_menu_command);
lua_setfield(luaState, -2, "MenuCommand");
It works much better.
I looked into the alternative idea of a scite.Director() function to do more of the Director Interface actions in the Lua Subsystem, though that is beyond my knowledge in C++ to handle actions like replaceall:<search>\000<replace> escaping properly..., else this later idea might be able to do scite.Director('reloadproperties:') instead of scite.ReloadProperties(). Not sure if the rest of the Director Interface actions is as useful as the reloadproperties: in the Lua Subsystem.
Can this feature be added?
Committed as [5a8b20].
Because of the need to escape in "replaceall:", other APIs (like
editor:match ... :replace) are easier to use from Lua.Where other director commands would be useful from Lua, it will likely be better to provide functions.
Related
Commit: [5a8b20]