micro icon indicating copy to clipboard operation
micro copied to clipboard

[Question] Lua API Tab Handling

Open 1ynxy opened this issue 2 months ago • 1 comments

I'm a little confused by what functions appear to be exposed to handle Tabs-

Firstly, the only way of creating a tab via Lua, that I have found, is the BufPane:AddTab function, which is strange because a Tab contains BufPanes (as far as I understand), and not the other way around. A more global micro.CreateTab function might be more helpful- especially if you could micro.CreateTabWithBuffer (which would insert a specific Buffer into the first BufPane in a new Tab). I'm not entirely sure who owns NewTabFromBuffer and NewTabFromPane, or if they're at all accessible in Lua.

Additionally the only function I have found for switching Tabs is the BufPane:TabSwitchCmd, but this specifically takes []string types, not Lua.LString types, so I'm guessing this is a mis-wrapped Go function- I confess I don't have full knowledge of the Go binding workings.

When switching panes, the only functions I have found to work are the BufPane:NextSplit and BufPane:PreviousSplit functions, as the BufPane:SetActive function doesn't appear to do anything at all.

And finally, the BufPane:ResizePane function is.. strange. If I VSplitIndex on the left, and resize the returned BufPane, it will resize the left-hand pane, but if I VSplitIndex on the right and resize the returned BufPane, it will resize the.. left-hand pane again?

I apologise if these are dumb questions, or I've mistaken behaviour at all.

1ynxy avatar Oct 09 '25 11:10 1ynxy

I didn't spot these mentioned issues in the Issues tab, but I've had a look through the Pull Requests tab and I've noted a few items which might address the questions / issues mentioned above:

Re: missing API "new tab" functionality https://github.com/zyedidia/micro/pull/3868

Re: strange behaviour on re-sizing splits https://github.com/zyedidia/micro/pull/3825

1ynxy avatar Oct 09 '25 17:10 1ynxy