Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

New plugin: QKeys

Charles Dye

Super Moderator
May
4,938
126
Staff member
Here: prospero.unm.edu/plugins/qkeys.html

Inspired by a remark by Steve Fabian in another thread. This plugin lets you define custom hotkeys to grab the word at the cursor and do stuff with it. I don't know whether this one deserves much development, but some of the possibilities seem interesting, e.g. grab a mathematical expression and evaluate it with @EVAL while composing a command.
 
I found out how function keys with modifiers can be defined and use them already. But function keys defined without modifiers QKEY displays the definitions, but the result is an empty string.
 
I found out how function keys with modifiers can be defined and use them already. But function keys defined without modifiers QKEY displays the definitions, but the result is an empty string.

Can you give me an example?
 
To delete all hotkeys:
qkey /d *

I've already added that ability, with a slightly different syntax, to the next build. What I didn't understand was your question about function keys without modifiers. You should be able to e.g.
Code:
qkey /x f12=%%@expand[#]
Doesn't that work for you?
 
That's what failed, trying both F2 and F4. In the event it's significant, I just verified with @FULL[]. ctrl-f2 worked.
Not significant, but my batch file to list keystorke aliases is a bit stylized:
Code:
        @@F3 %loc\WINMIN.BTM
    @@alt-F3 %loc\WINMAX.BTM
   @@ctrl-F3 %bat\SHOWSIZE.BTM
  @@shift-F3 %loc\WINBIG.BTM
         @F4 %@full[
     @alt-F4 %@expand[
   @shift-F4 bdebugger %@search[
 
Some keys I will switch ASAP to QKEY instead of keystroke aliases, because they need to postprocess it. Should I switch all? The execution time is not really critical when I must pay attention of what I do...

My current definitions are in a separate file last updated in Dec. of 2009.

BTW, keystroke aliases allow the same key defined both as autoexecute and as insert-only, but the insert-only overrides the autoexecute. I suppose QKEYS would just override the last definition all prior ones.
 
Some keys I will switch ASAP to QKEY instead of keystroke aliases, because they need to postprocess it. Should I switch all? The execution time is not really critical when I must pay attention of what I do...

TCC seems to check key plugins before key aliases, so there's no need to change your aliases file. Define a QKey and it'll override the alias. Delete it, and you're back to the alias again.

BTW, keystroke aliases allow the same key defined both as autoexecute and as insert-only, but the insert-only overrides the autoexecute. I suppose QKEYS would just override the last definition all prior ones.

A new definition replaces any old one for the same key. (I thought that defining an @@-alias automatically removed any @-alias, and vice versa. No? Not when read in from a file, perhaps?)
 
Very explicit comment from 2004 states that it is possible to define both @@ and @ for the same key, in which case @ is active, but both are listed by ALIAS. Never went back to try again. I avoid conflicts. Your statement (new definition replaces any old one) is perfectly fine.
The advantage of letting TCC taking key plugins over key aliases is that running older TCC that does not support QKEYS is self-adjusting. What is the oldest version of TCC compatible with QKEYS?
I have to apologize for the "plain function key". TCC does not permit a keyhandler for F2; it does for F4. There is a whole 4th paragraph of Special Considerations for Keystroke Aliases on the subject.
I tested the original QKEYS successfully in TCC version 11. It's what I use when installing new builds.
THANKS!
 
The advantage of letting TCC taking key plugins over key aliases is that running older TCC that does not support QKEYS is self-adjusting. What is the oldest version of TCC compatible with QKEYS?

I recommend at least 11.00.48. It will run in older versions, but hotkeys may require two presses after history recall, filename completion, and so on.

I just searched the forum for info on the above issue, and discovered that Vince has already written a QKEY plugin implementing a QKEY command. I am therefore open to suggestions for a new name....
 
HOTKEY?
BTW, I presume redirecting the command listing all to a file is the one I can use to reload with /R:filename'
Must treat the hotkeys as unique to each TCC instance, I presume, no equivalent to global aliases.
 
BTW, I presume redirecting the command listing all to a file is the one I can use to reload with /R:filename
That's what /S: is for. Redirection should work too, but (a) may mangle high-order characters if UnicodeOutput=No, or (b) will produce a larger output file if UnicodeOutput=Yes.

Must treat the hotkeys as unique to each TCC instance, I presume, no equivalent to global aliases.
Yes, each gets its own list.
 
Sorry, not yet RTFM. BTW, I don't expect more than a very few keystrokes. Full wildcarding does not appear worth for listing (and deleting) "subsets".
 
Here: prospero.unm.edu/plugins/qkeys.html

Inspired by a remark by Steve Fabian in another thread. This plugin lets you define custom hotkeys to grab the word at the cursor and do stuff with it. I don't know whether this one deserves much development, but some of the possibilities seem interesting, e.g. grab a mathematical expression and evaluate it with @EVAL while composing a command.

One of the things I enjoy about the PowerShell console is the ability to do math at the command line. You just type in your numbers and operators, press enter, and you have the result.

Using qkey /x alt-==%%@eval[#] now allows me to do almost the same thing in TCC, except I have to now press Alt= to get the result, instead of just pressing enter, which really isn't a problem. Another great tool for TCC. Thanks.

Joe
 
I've put up a new build here: prospero.unm.edu/plugins/ekeys.html

I have changed the name of the plugin, and its one command, to fix a collision with an earlier plugin of Vincent's. I've also added one new option allowing you to insert a word at the start of the command line, possibly useful for commands like BDEBUGGER and IDE.
 
This sounded like exactly what I was waiting for. I often type a partial command and discover that I need to issue some other command first. So what I've been doing is hitting [Home] [Insert] then REM and a space, then hitting ENTER. I can bring back the REM command later with command recall and edit it.

So I thought that I'd be able to define a hotkey like

EKEY /C ALT-1=REM

No such luck. If I enter FOO BAR BAZ and hit ALT-1 while the cursor is on BAZ, the resulting line is FOO BAR REM, though I think it should be REM FOO BAR BAZ.

TCC 15 // Windows XP. I haven't tried it yet on Windows 7.
 
I've put up a new build here: prospero.unm.edu/plugins/ekeys.html

I have changed the name of the plugin, and its one command, to fix a collision with an earlier plugin of Vincent's. I've also added one new option allowing you to insert a word at the start of the command line, possibly useful for commands like BDEBUGGER and IDE.
Was anyone actually involved in a collision? I don't even remember QKEYS, and having just read its text file, I still don't remember it.
 
This sounded like exactly what I was waiting for. I often type a partial command and discover that I need to issue some other command first. So what I've been doing is hitting [Home] [Insert] then REM and a space, then hitting ENTER. I can bring back the REM command later with command recall and edit it.

So I thought that I'd be able to define a hotkey like

EKEY /C ALT-1=REM

No such luck. If I enter FOO BAR BAZ and hit ALT-1 while the cursor is on BAZ, the resulting line is FOO BAR REM, though I think it should be REM FOO BAR BAZ.

Try EKEY /C ALT-1=REM #

The # stands for the word at the cursor, effectively replacing it with itself; the part before the space is moved to the start of the command line as the new command.
 
Was anyone actually involved in a collision? I don't even remember QKEYS, and having just read its text file, I still don't remember it.

Don't know, but it can't be good to have two plugins with the same name.

I don't remember QKEYS either, but I had an old copy in my downloads directory, so I must have been aware of it at one time. Presumably the name stuck in my memory.
 
Thanks, Charles. That wasn't obvious. So, maybe the documentation should say something like,
"When /C is used, the first token on the command line is altered, rather than the word under the cursor."

I found another use for this.

ekey /c /e alt-2=echo #
can be used see what the expanded version of a command looks like before execution.
 
Thanks, Charles. That wasn't obvious. So, maybe the documentation should say something like,
"When /C is used, the first token on the command line is altered, rather than the word under the cursor."

No, it still picks up the word at the cursor. It's always the word at the cursor. To see how it works, try changing your original hotkey to something like:
Code:
ekey /c alt-1=rem (#)

(And if the cursor is not at a word, the hotkey does nothing at all. I may change that in a future build.)
 
So /C doesn't work unless a # appears somewhere in the definition?

Whatever. It's working for me now.

I haven't tried it, but if the cursor were not on some word, I would still expect /C to work, but probably not anything else.
 
Charles,

I'm sorry for sounding snotty in my last reply. I didn't mean to be, but as I reread my own words, I realize that it sounds that way.
I meant no disrespect.

I also reread the .html file description of /C, and I see that the behavior does match the description. However, I still think you need a note saying that a # must appear for the /C to be useful.

Sorry for the misunderstanding.
 
I'm sorry for sounding snotty in my last reply. I didn't mean to be, but as I reread my own words, I realize that it sounds that way.
I meant no disrespect.

No worries. This is about the most amiable internet forum I've ever encountered. (Hey, I have the power to slap down trolls here! ...and have never yet found an excuse to try it out.)

I also reread the .html file description of /C, and I see that the behavior does match the description. However, I still think you need a note saying that a # must appear for the /C to be useful.

You'll almost always want a # in the definition, unless you intend to discard the word at the cursor. I suppose I might automatically append a #, if /C is specified and the definition text contains only one word.
 
From Help > TCC > Command Line > Command Line Editing: "Ctrl-K Save the current command line in the history list without executing it, and then clear the command line".
 

Similar threads

Back
Top