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

From: Robert Gieseke <rob.g.att.web.de>
Date: Fri, 21 Mar 2014 22:30:26 +0100

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.

Cheers,
Robert

-- 
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 Fri 21 Mar 2014 - 17:30:26 EDT

This archive was generated by hypermail 2.2.0 : Sat 22 Mar 2014 - 06:31:17 EDT