New plugin: QKeys

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,667
46
Albuquerque, NM
prospero.unm.edu
#1
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.
 
#8
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[
 
#9
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.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,667
46
Albuquerque, NM
prospero.unm.edu
#11
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?)
 
#12
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!
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,667
46
Albuquerque, NM
prospero.unm.edu
#13
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....
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,667
46
Albuquerque, NM
prospero.unm.edu
#15
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.
 
#17
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
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,667
46
Albuquerque, NM
prospero.unm.edu
#18
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.
 
May 29, 2008
533
3
Groton, CT
#19
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.
 
#20
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.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,667
46
Albuquerque, NM
prospero.unm.edu
#21
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.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,667
46
Albuquerque, NM
prospero.unm.edu
#22
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.
 
May 29, 2008
533
3
Groton, CT
#23
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.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,667
46
Albuquerque, NM
prospero.unm.edu
#24
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.)
 
May 29, 2008
533
3
Groton, CT
#25
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.
 
May 29, 2008
533
3
Groton, CT
#26
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.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,667
46
Albuquerque, NM
prospero.unm.edu
#27
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.