1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Append command line to @@key alias?

Discussion in 'Support' started by vefatica, May 18, 2011.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,783
    Likes Received:
    29
    Is there a way to append the current command line to an @@key alias (instead of the default insert/overwrite behavior)? For example, alias @@F2=command (?) in such a way that if I type "foo" and then press F2, "command foo" is executed?
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,726
    Likes Received:
    80
    No. There isn't any variable substitution in key aliases.
     
  3. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,277
    Likes Received:
    38
    It'd be easy enough to do in a keystroke plugin, though....
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,783
    Likes Received:
    29
    On Wed, 18 May 2011 13:52:46 -0400, rconn <> wrote:

    |No. There isn't any variable substitution in key aliases.

    It could be just my lack of imagination, but I can't think of a situation where
    I'd use an automatic key alias (@@) to insert something into a command line in
    progress, at the cursor position, and then execute that command line. That's
    how it behaves.

    Code:
    v:\> alias @@f2 dir
    
    v:\> p:\4Utils\ [F2]
    TCC: Unknown command "p:\4Utils\dir"
    Does anyone use an @@key alias with a command line in progress? ... have a good
    example?

    It would seem much more useful to insert at the beginning of the line followed
    by a space.
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,783
    Likes Received:
    29
    Yes (it'd be pretty useless if it wasn't).
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,783
    Likes Received:
    29
    On Wed, 18 May 2011 14:25:26 -0400, vefatica <> wrote:

    |On Wed, 18 May 2011 13:52:46 -0400, rconn <> wrote:
    |
    ||No. There isn't any variable substitution in key aliases.
    |
    |It could be just my lack of imagination, but I can't think of a situation where
    |I'd use an automatic key alias (@@) to insert something into a command line in
    |progress, at the cursor position, and then execute that command line. That's
    |how it behaves.
    |
    |
    |Code:
    |---------
    |v:\> alias @@f2 dir
    |
    |v:\> p:\4Utils\ [F2]
    |TCC: Unknown command "p:\4Utils\dir"
    |---------
    |Does anyone use an @@key alias with a command line in progress? ... have a good
    |example?
    |
    |It would seem much more useful to insert at the beginning of the line followed
    |by a space.

    Even better ... insertion at the beginning plus full-blown parameter
    substitution from the command line in progress.
     
  7. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,177
    Likes Received:
    11
    It's useful for things like:

    alias @@Alt-F4=exit^n

    -Scott

    vefatica <> wrote on 05/18/2011 02:25:26 PM:


    line in

    That's


    followed

     
  8. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,726
    Likes Received:
    80
    That's how it's always behaved, and that's how people wanted it. It will definitely NOT be changed now!
     
  9. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,783
    Likes Received:
    29
    On Wed, 18 May 2011 17:03:07 -0400, samintz <> wrote:

    |It's useful for things like:
    |
    |alias @@Alt-F4=exit^n

    That wouldn't work in a command line in progress.

    Code:
    v:\> alias @@Alt-F4
    exit
    
    
    v:\> foo[Alt-F4]
    TCC: Unknown command "fooexit"
    I use:

    Code:
    v:\> alias @@Ctrl-F10
    @exit
    That's [Esc]@exit (to clear the command line and keep it out of the history).

    Note I use Gateway "AnyKey" keyboards and there's an F10 right next to the left
    Ctrl key.
     
  10. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,783
    Likes Received:
    29
    On Wed, 18 May 2011 17:05:47 -0400, rconn <> wrote:

    |---Quote (Originally by vefatica)---
    |It could be just my lack of imagination, but I can't think of a situation where I'd use an automatic key alias (@@) to insert something into a command line in progress, at the cursor position, and then execute that command line. That's how it behaves.
    |---End Quote---
    |
    |That's how it's always behaved, and that's how people wanted it. It will definitely NOT be changed now!

    I never dreamed you'd change it. I was just wondering about uses for it in a
    command line in progress.
     
  11. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,783
    Likes Received:
    29
    Not hard to do for just the unmodified F keys (code below).

    Rex, how does TCC handle checking if a keystroke corresponds to a keystroke alias? ... some kind of a hash table I imagine ... could I kludge access to it?

    Code:
    int F[13] = {0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12};
    for ( INT i=1; i<=12; i++ )
    {
        if ( lpKeyInfo->nKey == F[i] )
        {
            WCHAR szAliasName[8], szSave[4096], *pszAlias;
            Sprintf(szAliasName, L"@@F%d", i);
            pszAlias = GetAlias(szAliasName);
            if ( pszAlias != NULL )
            {
                lstrcpy(szSave, lpKeyInfo->pszLine);
                Sprintf(lpKeyInfo->pszLine, L"%s %s", pszAlias, szSave);
                lpKeyInfo->nKey = 13;
                return 0;
            }
        }
    }
     
  12. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    A common situation is when you have a command calling a batch file:
    xxx p1 p2 ...
    and you want to run the debugger, so you want to convert it to:
    bdebugger %@search[xxx] p1 p2 ...

    This requires a complicated operation, consisting of the following steps:

    1/ change edit mode to INSERT
    2/ go to beginning of line
    3/ insert the string "bdebugger %@search["
    4/ go to the end of the first word
    5/ insert "]"
    6/ go to end of line
    7/ insert "<enter>"

    Step 6 may not be needed.

    It would be nice to have a keystroke alias, or a plugin command invoked by a keystroke alias, to do all this automatically. For now I have a keystroke alias which does step 3 - all else must be done manually.
    --
    Steve
     
  13. K_Meinhard

    Joined:
    May 20, 2008
    Messages:
    309
    Likes Received:
    0
    Hallo vefatica,


    Not a straightforward one. But I see that @READSCR still exists, which
    would allow to put your cmdline intoa var and append t his to your
    alias...

    Clumsy, I know.

    herzliche Grüße,

    Klaus Meinhard
     
  14. mfarah

    Joined:
    Nov 2, 2009
    Messages:
    226
    Likes Received:
    5
    There's something that, while it's not the exact same thing, it's technically close:

    On Unix shells, typing ^L will clear the screen while keeping in the command line whatever has been typed. I have an @@^L=cls alias, but it doesn't work the same way (something that drives me, the detailed-obsessed maniac, nuts).

    I'd love to be able to clear the screen in this manner in TCC.
     

Share This Page