[code] Printing to custom buffer

From: Oliver Jan Krylow <oliver.att.bugabinga.net>
Date: Fri, 01 Jun 2018 01:14:58 +0200

Hello list!

The following `init.lua` causes `ta` to seemingly get stuck in some
loop, be unresponsive and take 100% of one CPU core until I SIGTERM it.

        local function msg(...)
          ui._print('LOG', ...)
        end

        msg(1,2,3, 'START')

> Notice the `_print`!

Make sure you have no `session` file initially.
You have to open `ta` two times to observe this.
(Make sure you have not disabled session loading)

It seems `ui._print` is only usable after `events.INITIALIZED`. Correct?

        local function msg(...)
          ui._print('LOG', ...)
        end

        events.connect(events.INITIALIZED, function()
                ui.print("HELLO")
                msg(1,2,3, 'START')
        end)

This fixes the unresponsive loop issue, but there is another issue
after second launch of `ta`. A dialog pops up saying "session LOG
cannot be found".

This can be fixed by renaming 'LOG' to '[LOG]'. Why?

I stumbled upon this while trying to create my own custom "Message
Buffer" and don't quite understand what is going on.

Apologies, if this is documented somewhere and I missed it, but I could
not find mention of this in the manual.

So, I am just a little confused about what is expected behaviour, what
is possibly an issue and if one should generally put the whole
`init.lua` in a `events.INITIALZED` handler maybe?

Best regards, Oliver

---
Textadept 10 beta
Ubuntu 16.04
-- 
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 Thu 31 May 2018 - 19:14:58 EDT

This archive was generated by hypermail 2.2.0 : Fri 01 Jun 2018 - 06:30:28 EDT