Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-802: Macro API to report VMenu alignment state. Part 2: Plumbing and Lua API. #902

Conversation

MKadaner
Copy link
Contributor

@MKadaner MKadaner commented Jan 24, 2025

Summary

Surfacing the state maintained by vmenu_horizontal_tracker to Lua macro.

References

Checklist

  • I have followed the contributing guidelines.
  • I have discussed this with project maintainers:

    If not checked, I accept that this work might be rejected in favor of a different great big ineffable plan.

Details

The following macro seems to work as expected:

Macro {
  area="Menu";
  key="AltT";
  action = function()
    far.Message(Menu.HorizontalAlignment, "Horizontal Alignment")
  end;
}

@rohitab, may I ask you to give this new property a try? Does it suite your purpose? Do you need something more?

@shmuz shmuz self-requested a review January 24, 2025 10:18
Copy link
Contributor

@shmuz shmuz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MKadaner , with regards to macro API:

  1. As I can see there are 4 possible return values: -1, 1, 2 and 4. Why the latter is 4 rather than 3 ?
  2. Despite the macro section in Far Encyclopedia is outdated it would be desirable to add the description of Menu.HorisontalAlignment to enc\enc_rus\meta\macro\macrocmd\prop_func\menus.html.
  3. There are also 3 files enc\enc_lua\macroapi_manual.??.tsi that I can update myself after the PR is merged.

@alabuzhev
Copy link
Contributor

what is the right / simplest way to build Far with plugins locally for testing?

@MKadaner, _build\vc\all.sln

@MKadaner
Copy link
Contributor Author

MKadaner commented Jan 25, 2025

@shmuz:

Why the latter is 4 rather than 3 ?

It is related to @HamRusTal's comment. If we want to add an enumeration, Center should have value 3, and Annotation should be 4. Even if the enumeration is not needed, it makes sense to reserve 3 for a possible future use.

Of course, I am not strong on either of these. Please let me know how to proceed.

I also noticed that the Menu.Id property in Encyclopedia and code comments is spelled as Menu.Info.Id. Do you want me to fix it?

Please have a look at Encyclopedia and Lua Manual.

@johnd0e
Copy link
Contributor

johnd0e commented Jan 25, 2025

I also noticed that the Menu.Id property in Encyclopedia and code comments is spelled as Menu.Info.Id. Do you want me to fix it?

No sense, as Encyclopedia (in Macro section) is in either case severely outdated.
So I do not see any point in touching it at all.
@shmuz

@shmuz
Copy link
Contributor

shmuz commented Jan 25, 2025

@MKadaner
@johnd0e
I agree that we shouldn't fix anything there (until somebody volunteers to fix it all).
But with regards to the new property Menu.HorizontalAlignment I think it is worth to add.

@johnd0e
Copy link
Contributor

johnd0e commented Jan 25, 2025

But there are a lot of things missing already.

E.g.

  • Area: Current, ShellAutoCompletion, DialogAutoCompletion
  • Panel: CustomSortMenu, LoadCustomSortMode, SetCustomSortMode
  • Dlg: Owner
  • Far: GetConfig
  • Mouse: LastCtrlState
  • Object: Height, Width
  • Plugin.SyncCall
  • mf: acall, AddExitHandler, deserialize/serialize, EnumScripts, GetMacroCopy, postmacro, printconsole, usermenu

@shmuz
Copy link
Contributor

shmuz commented Jan 25, 2025

@johnd0e
I want Menu.HorizontalAlignment there. Period.

@MKadaner MKadaner force-pushed the mzk/gh-802/retrieve-vmenu-alignment-api-lua branch from 1cd9778 to 4f31e08 Compare January 26, 2025 02:16
@MKadaner MKadaner changed the title gh-802: Macro API to report VMenu alignment state. Part 2: Plumbing. gh-802: Macro API to report VMenu alignment state. Part 2: Plumbing and Lua API. Jan 26, 2025
@MKadaner MKadaner marked this pull request as ready for review January 26, 2025 02:18
@MKadaner
Copy link
Contributor Author

I did my best. Ready for review.

I did not touch Menu.Info.Id, mostly because I was not sure I fully understand things like this:

#_1. `Menu.Info.Id -> Menu.Id`

@shmuz
Copy link
Contributor

shmuz commented Jan 26, 2025

@MKadaner
Menu.Info.Id -> Menu.Id means that after changing from the old macro language to Lua one should use Menu.Id instead of Menu.Info.Id.
These TSI-files are sources for the corresponding CHM-files found in the %FARHOME%\Encyclopedia directory.

@MKadaner
Copy link
Contributor Author

@shmuz, thanks. It means that somewhere there is still some code which parses the string Menu.Info.Id and invokes VMProcess, right? If so, no changes to the documentation are required in this regard.

Let's merge this PR?

@shmuz
Copy link
Contributor

shmuz commented Jan 27, 2025

It means that somewhere there is still some code which parses the string Menu.Info.Id and invokes VMProcess, right?

  1. No there isn't such code in current Far3.
    That article ("API changes in comparison to the macro language") was written in year 2012 to ease the transition from old macro language to Lua. The old constructs like Menu.Info.Id won't work in any Far3 build since 3.0.2851 (Sep 30 2012).
  2. The Macro part in Far Encyclopedia is not updated since then. There is a big warning in red about that.
  3. With regards to merging this PR - let's @alabuzhev decide. I have no objections for merging it.

@alabuzhev alabuzhev merged commit ab23357 into FarGroup:master Jan 27, 2025
51 checks passed
@alabuzhev
Copy link
Contributor

Thank you

@MKadaner MKadaner deleted the mzk/gh-802/retrieve-vmenu-alignment-api-lua branch January 28, 2025 02:58
@MKadaner
Copy link
Contributor Author

Thank you all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants