Re: [code] Improved File Browser

From: Alexander Misel <alexander_misel.att.live.cn>
Date: Fri, 12 Oct 2018 06:03:22 +0000

As for file browser, I wang to do things like:
events.connect(events.BUFFER_AFTER_SWITCH, function ()
  if (buffer._type or ''):match('^%[File Browser') then
    highlight_folder()
  elseif M.view and M.view == view then
    local new_buffer = buffer
    if _BUFFERS[view._prev_buffer] and buffer ~= view._prev_buffer then
      view:goto_buffer(view._prev_buffer)
      highlight_folder()
    end
    for i, other_view in ipairs(_VIEWS) do
      if M.view ~= other_view then ui.goto_view(other_view) break end
    end
    view:goto_buffer(new_buffer)
  end
end)
But the gtk doesn't really focus on the new_buffer as in textadept.c, function lview_goto_buffer
  // If the indexed view is not currently focused, temporarily focus it so
  // `_G.buffer` in handlers is accurate.
  if (view != focused_view) focus_view(view);
  if (!initing) lL_event(L, "buffer_before_switch", -1);
  lL_gotodoc(L, view, lua_tointeger(L, 2), relative);
  if (!initing) lL_event(L, "buffer_after_switch", -1);
  if (focused_view != prev_view) focus_view(prev_view);
  return 0;
And I don't know if there's a way to focus a view in Lua.
________________________________
From: Alexander Misel <alexander_misel.att.live.cn>
Sent: Friday, October 12, 2018 10:46
To: Mitchell; code.att.foicica.com
Subject: Re: [code] Improved File Browser

It works but the operation gives a flash of the new buffer then switch back. I hope this could be done internally or just before the view that a buffer will use is chosen.
________________________________
From: Mitchell <m.att.foicica.com>
Sent: Thursday, October 11, 2018 20:39
To: code.att.foicica.com
Subject: Re: [code] Improved File Browser

Hi Alexander,

On Thu, 11 Oct 2018, Alexander Misel wrote:

> Now I am looking forward to a feature that locks a view to only have ONE buffer (i.e. File Browser, TODO list). Any sugguestions on how to implement it?

One idea I had was to connect to `events.BUFFER_AFTER_SWITCH` and check to see if the current view (`view`) contains a buffer it shouldn't. If so, immediately call `view:goto_buffer(...)` with the buffer you want to "lock". I'm not certain this will work. It's just an idea.

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.
-- 
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 12 Oct 2018 - 02:03:22 EDT

This archive was generated by hypermail 2.2.0 : Fri 12 Oct 2018 - 06:40:54 EDT