load.on.activate and lua's scite.Open

60 views
Skip to first unread message

Agustín Fernández

unread,
Dec 29, 2011, 10:52:00 PM12/29/11
to scite-interest
Hi,

I've noticed that load.on.activate doesn't take effect when I open a
file via Lua's scite.Open.

Is that on purpose? Is it a bug? Am I doing something wrong?

Also, it would be great if the popup would work in a strip instead of
an alert. I often have many files open, switch branches (via git) and
then decide to close many of the files... That means a lot of "OK"
clicking to be able to close them.

. A .

Neil Hodgson

unread,
Dec 30, 2011, 12:37:56 AM12/30/11
to scite-i...@googlegroups.com
Agustín Fernández:

> I've noticed that load.on.activate doesn't take effect when I open a
> file via Lua's scite.Open.
>
> Is that on purpose? Is it a bug? Am I doing something wrong?

Modify SciTEStartup.lua to contain just: scite.Open("c:\\u\\foo.cxx")
Open SciTE. foo.cxx is opened.
Modify foo.cxx in another program such as another instance of SciTE.
Switch back to instance which loaded foo.cxx through script. Changes appear.

What is different in your experience?

> Also, it would be great if the popup would work in a strip instead of
> an alert. I often have many files open, switch branches (via git) and
> then decide to close many of the files... That means a lot of "OK"
> clicking to be able to close them.

load.on.activate doesn't normally show a pop up unless you have
edited the file or have set are.you.sure.on.reload.

In general, pop ups occur in the middle of code and the answer is
required to steer the following code. Using a non-modal dialog or
strip requires bundling up the state at that point and deferring its
use until the dialog is completed. There has to be handling for
changes (like the file being closed) which could occur before the
dialog is completed. It is significant work but if someone wants to
write the code then it sounds like an OK idea.

There is no support currently for stacking strips either using
extra space or multiple messages in one space.

Neil

Agustín Fernández

unread,
Dec 30, 2011, 10:02:59 AM12/30/11
to scite-interest
Hi,

Thanks for the prompt answer!

OK, it seems the problem is there when you open a file under OnKey.

I reduced the code to:

function OnKey(code, shift, control, alt)
if alt and code == 67 then
scite.Open('/home/amfc/www/iats/code/config/
config.js.template')
end
end

And it fails to notice changes consistently.

And about the non-modal strip: I would really love that feature. I
guess I should give it a try and see if I can contribute a patch.

. A .

Neil Hodgson

unread,
Jan 1, 2012, 6:16:40 AM1/1/12
to scite-i...@googlegroups.com
Agustín Fernández:

> OK, it seems the problem is there when you open a file under OnKey.
>
> I reduced the code to:
>
> function OnKey(code, shift, control, alt)
>    if alt and code == 67 then
>        scite.Open('/home/amfc/www/iats/code/config/
> config.js.template')
>    end
> end
>
> And it fails to notice changes consistently.

Works for me on Xubuntu 11.10 with the file name changed to
something present on my machine. Perhaps time stamps are not being
updated by git or the file system as expected for you.

Neil

Agustín Fernández

unread,
Jan 24, 2012, 12:37:48 PM1/24/12
to scite-interest
Hi,

Sorry about the delay.

I checked on the last version (3.0.2).

Clearer simpler steps to reproduce:

User option file:

load.on.activate=1
are.you.sure.on.reload=1

Lua startup script:

c = 1
function OnKey(code, shift, control, alt)
if alt and code == 67 then
scite.Open('/tmp/sample')
elseif alt and code == 99 then
local f = io.open('/tmp/sample', "w")
c = c + 1
f:write(c)
f:close()
end
end

Steps to reproduce:

1. open scite (no tabs present)
2. write "hi" (to avoid this now-empty tab to be replaced)
3. hit alt-c (this will create/edit the temp file with 1 as the
content)
4. hit alt-shift-c (this will switch to the file, now containing "1")
5. control page up (go the the previous tab)
6. hit alt-c again (the temp file will now have "2" as the content)
7. hit alt-shift-c

Expected results:

Scite will switch to the new tab and a popup warning that the contents
of the tab changed

Actual results:

The switch happens, but the old contents (1) is still present.

Workaround:

Control page up twice (switching back and forth in tabs) and the
warning will appear.

Environment:

Ubuntu 10.04 with a custom built debian package with the plain scite
distribution.

I think that since the "activate event" is defined differently in
windows and gtk, this may be platform specific.

My failed investigation

I browsed the code a bit and couldn't find the way in which the
activate event code is reached from lua's open call. From what I can
see the connection doesn't happen from an explicit function call,
perhaps "activate" is a kind of focus event which is supposed to
happen when the tab is switched automatically and it is related to how
linux handles the focus?

I hope this is useful.

. A .

Neil Hodgson

unread,
Jan 24, 2012, 3:29:52 PM1/24/12
to scite-i...@googlegroups.com
Agustín Fernández:

> 1. open scite (no tabs present)
> 2. write "hi" (to avoid this now-empty tab to be replaced)
> 3. hit alt-c (this will create/edit the temp file with 1 as the
> content)
> 4. hit alt-shift-c (this will switch to the file, now containing "1")
> 5. control page up (go the the previous tab)
> 6. hit alt-c again (the temp file will now have "2" as the content)
> 7. hit alt-shift-c

Looks like you are not switching focus from or to SciTE. Therefore
no activation occurs.

> I think that since the "activate event" is defined differently in
> windows and gtk, this may be platform specific.

An application is activated when focus is switched to it from
another application.

Neil

Agustín Fernández

unread,
Jan 26, 2012, 10:09:16 AM1/26/12
to scite-interest
I undestand. However, I think that the current behaviour is not very
consistent (switching with keys or a menu item will trigger reload,
but not from lua).

Perhaps a new config: load.on.tabselect?

One could argue that considering the tab as the subject to the
"activate" event would be more useful.

It's not really a big issue anyway, I can just change the code to work
from the key bindings instead of opening them from OnKey event. (Since
it works from there.)

. A .

Neil Hodgson

unread,
Jan 27, 2012, 7:27:36 PM1/27/12
to scite-i...@googlegroups.com
Agustín Fernández:

> I undestand. However, I think that the current behaviour is not very
> consistent (switching with keys or a menu item will trigger reload,
> but not from lua).

The purpose of the current feature is to facilitate using SciTE
with another application such as a WYSIWYG HTML editor.

Neil

Reply all
Reply to author
Forward
0 new messages