Re: [code] Message Buffer / ui.print always stealing focus

From: Mitchell <m.att.foicica.com>
Date: Sat, 22 Mar 2014 15:01:03 -0400 (EDT)

Hi,

On Fri, 21 Mar 2014, Robert Gieseke wrote:

> Hi Ryan,
>
> Am 21/03/14 14:42, schrieb Ryan Pusztai:
> []
>>> Change committed. There is a new `ui.SILENT_PRINT` that, when true,
>>> prevents any buffers being printed to from stealing the focus. By default
>>> it is off, but prior to calling your spawn, you can turn it on, and then
>>> turn it back off again after your spawn completes.
>>
>> This sounds great. I will try it once a release is out. Thanks.
>
> There is nightly "release" every day :-)
>
>> Also I noticed, not to long ago, you removed creating a new split for
>> "[Message Buffer]" when tabs are enabled. Is it possible to control that
>> behavior with a setting as well? I like the way it used to work much
>> better.
>
> You could overwrite the 'ui.print' function, basically
> changing the line
> if not ui.tabs then view:split() end
> to always create a split view, in your init.lua:
>
> local function _print(buffer_type, ...)
> if buffer._type ~= buffer_type then
> for i, view in ipairs(_VIEWS) do
> if view.buffer._type == buffer_type then ui.goto_view(i) break end
> end
> if view.buffer._type ~= buffer_type then
> view:split()
> for i, buffer in ipairs(_BUFFERS) do
> if buffer._type == buffer_type then view:goto_buffer(i) break end
> end
> if buffer._type ~= buffer_type then
> buffer.new()._type = buffer_type
> events.emit(events.FILE_OPENED)
> end
> end
> end
> local args, n = {...}, select('#', ...)
> for i = 1, n do args[i] = tostring(args[i]) end
> buffer:append_text(table.concat(args, '\t'))
> buffer:append_text('\n')
> buffer:goto_pos(buffer.length)
> buffer:set_save_point()
> end
>
> function ui._print(buffer_type, ...) pcall(_print, buffer_type, ...) end
>
> Alternatively, you could hook into error and run print events if you want
> different behaviours for them -- or Mitchell could introduce a setting to
> toggle the behaviour, but the above code should work.

Thanks for the example, Robert. I would suggest a custom ui.print(), as I
prefer to not litter the API with too many options.

Cheers,
Mitchell

-- 
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 Sat 22 Mar 2014 - 15:01:03 EDT

This archive was generated by hypermail 2.2.0 : Sun 23 Mar 2014 - 06:28:35 EDT