Re: [code] [textadept] Textadept 10.0 alpha issue II

From: Gabriel Dubatti <gdubatti.att.gmail.com>
Date: Tue, 9 Jan 2018 17:29:17 -0300

Thanks!

I forget about this when don't use LUA for a while... (It was driving me
crazy)

Now I get:

mar 09 ene 2018 17:22:14 -03: INIT_START
mar 09 ene 2018 17:22:14 -03: INIT_END
mar 09 ene 2018 17:22:14 -03: BUFFER_NEW
mar 09 ene 2018 17:22:14 -03: BUFFER_NEW
mar 09 ene 2018 17:22:14 -03: BUFFER_NEW
mar 09 ene 2018 17:22:14 -03: BUFFER_NEW
mar 09 ene 2018 17:22:14 -03: BUFFER_NEW
mar 09 ene 2018 17:22:14 -03: INITIALIZED

mar 09 ene 2018 17:22:19 -03: BUFFER_NEW
mar 09 ene 2018 17:23:11 -03: BUFFER_NEW

AFTER RESET:
mar 09 ene 2018 17:23:20 -03: INIT_START
mar 09 ene 2018 17:23:20 -03: INIT_END
mar 09 ene 2018 17:23:20 -03: INITIALIZED

mar 09 ene 2018 17:23:20 -03: RESET_AFTER
mar 09 ene 2018 17:23:21 -03: BUFFER_NEW

As expected...

Cheers,
Gabriel

El 09/01/2018 a las 17:07, Michal Kottman escribió:
> On Jan 9, 2018 20:29, "Gabriel Dubatti" <gdubatti.att.gmail.com
> <mailto:gdubatti.att.gmail.com>> wrote:
>
> function log_event(event)
>   local line= os.date('%c')..": "..event.."\n"
>   log_ev[#log_ev+1]= line
> end
>
> log_event("INIT_START")
>
> events.connect(events.RESET_BEFORE, log_event("RESET_BEFORE"))
> events.connect(events.RESET_AFTER, log_event("RESET_AFTER"))
> events.connect(events.INITIALIZED, log_event("INITIALIZED"))
> events.connect(events.BUFFER_NEW, log_event("BUFFER_NEW"))
>
> keys.cf4 = reset
>
> keys.cf5 = function()
>   buffer.new()
>   for i=1,#log_ev do
>     buffer:append_text(log_ev[i])
>   end
>   buffer:set_save_point()
> end
>
> log_event("INIT_END")
> ------------------
>
>
> And get the following output (press Ctrl+F5 to show):
> ........................
> mar 09 ene 2018 16:10:31 -03: INIT_START
> mar 09 ene 2018 16:10:31 -03: RESET_BEFORE
> mar 09 ene 2018 16:10:31 -03: RESET_AFTER
> mar 09 ene 2018 16:10:31 -03: INITIALIZED
> mar 09 ene 2018 16:10:31 -03: BUFFER_NEW
> mar 09 ene 2018 16:10:31 -03: INIT_END
> ....................
>
> Why does the INITIALIZED event appear before "INIT_END" ?
>
>
> You are actually executing the "log_event" calls as you setup the
> events instead of registering callbacks. Try this:
>
> events.connect(events.RESET_BEFORE, function()
> log_event("RESET_BEFORE") end)
> ...
>
> Or:
>
> function log_event_callback(name)
>   return function() log_event(name) end
> end
> ...
> events.connect(events.RESET_BEFORE, log_event_callback("RESET_BEFORE"))
>

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Tue 09 Jan 2018 - 15:29:17 EST

This archive was generated by hypermail 2.2.0 : Wed 10 Jan 2018 - 06:34:25 EST