Distinct capitals for macros (or testing Shift key)

Here you can discuss any topic concerning Far macro commands.
Post Reply
galaxy_far_FAR_away
Posts: 23
Joined: Mon 12 Aug, 2013 14:03
Has thanked: 6 times

Distinct capitals for macros (or testing Shift key)

Post by galaxy_far_FAR_away »

I want to use Fast Find function (which is mapped to Alt+Key by default) by pressing Shift+Key. I tried "Macro { key="A"; ..." but that is activated by small 'a' too.

1a.) So, I like to know how can I test Shift key status?
1b.) ...or how to use a Unicode function to test if a character is capital?
2.) Why LUA not distinguish hotkey capitals?

3.) Is there a more elegant way to bring up 'Fast find' dialog?

This ugly code not works for international characters:

Code: Select all

local function my_key ()
  if (akey(0) < 96) -- capital (works only for ASCII)
  then
    Keys "Alt? BS"  -- brings up 'Fast find'
  end
  Keys "Akey"
end
Thanks for Your answers!
Shmuel
Posts: 6815
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 526 times

Distinct capitals for macros (or testing Shift key)

Post by Shmuel »

galaxy_far_FAR_away wrote: 1a.) So, I like to know how can I test Shift key status?
If I remember correctly there is currently no way to detect that from a macro (though one can use PeekConsoleInput via FFI to do that).
galaxy_far_FAR_away wrote: ...or how to use a Unicode function to test if a character is capital?
Use either far.LIsUpper(c) or c:match("%u").
galaxy_far_FAR_away wrote: 2.) Why LUA not distinguish hotkey capitals?
That is the way it always has been.
galaxy_far_FAR_away wrote: 3.) Is there a more elegant way to bring up 'Fast find' dialog?
I don't know. I use Fast Find Enhanced plugin.
User avatar
HaRT
Moderator
Posts: 10806
Joined: Tue 30 Aug, 2005 17:21
Has thanked: 220 times
Been thanked: 357 times

Distinct capitals for macros (or testing Shift key)

Post by HaRT »

galaxy_far_FAR_away, though not exactly what you ask for, I've just successfully assigned opening the QSearch box to a single Shift key (pressed and released). Is it elegant enough?
Фар есть инструмент, а не нянька. © 2009 DrKnS
galaxy_far_FAR_away
Posts: 23
Joined: Mon 12 Aug, 2013 14:03
Has thanked: 6 times

Distinct capitals for macros (or testing Shift key)

Post by galaxy_far_FAR_away »

Both capital tests works, I have chosen the "match" variant (it is terrible why I not learn LUA entirely :( I should do...)

Under "Elegant way to bring up Fast Find" I meant a function call to open that input field.

Now I faced another problem: it is a way to do "Macro { key="Alpha"; ..." ? I'm fear there is no way... Now I must to assign all ASCII & beyond-ASCII (national) keys to "my_key ()" separately. Instead an "Alpha" option would be nice :)

Thanks for Your support!
Shmuel
Posts: 6815
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 526 times

Distinct capitals for macros (or testing Shift key)

Post by Shmuel »

galaxy_far_FAR_away wrote: Now I faced another problem: it is a way to do "Macro { key="Alpha"; ..." ? I'm fear there is no way...
key="/\\i/"; or key="/[\\i\\d]/"; depending on what you want.
Post Reply

Return to “Macro Commands Discussions”