By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!OPTION | Keyboard | Category: Editing
[Keys]
, for example:BeginLine = Home Ctrl-Q
EndLine = End Ctrl-T
Left = Left Ctrl-U
I'm in INSERT mode everywhere. When I type @FUNCTIONs names (command line or editing a BTM) I almost always type both brackets and a <Left>. That helps keep track of things if the line is long and (especially) if there are nested functions.Thanks for your replies - I can probably live with typing the close bracket myself, heh heh.
Won't it be tedious if not at the end of the command line (dealing with insert/overstrike mode as needed)? And if end of command line is required, that will preclude building nested thingies from the outside in.How about this: Typing an open bracket or an open parenthesis automatically inserts the matching close mark to the right of the cursor? Something like that would be trivial to implement.
Won't it be tedious if not at the end of the command line (dealing with insert/overstrike mode as needed)? And if end of command line is required, that will preclude building nested thingies from the outside in.
If I'm missing something and it really would be trivial, you could do the same for double quotes, backticks, and braces.
That was going to be too hard. So I did it as you did, Charles. And, I did it for all of these (below). I'll just leave it in place and see if it enhances my life.Autobrackets ... interesting ... simple ... and it works I've started one that will use SendInput (letting TCC worry about the tail). If I'm still so inclined after dinner, I'll get back to it.
struct OPEN_CLOSE_PAIR { WCHAR opener; WCHAR closer; };
OPEN_CLOSE_PAIR oc[5] = { {L'[', L']'} , {L'(', L')'} , {L'\"', L'\"'} , {L'{', L'}'} , {L'`', L'`'} };
Hmmm! I don't know. Presumably, the user wouldn't be typing a close quote if it had already been done for him. Yes/no?I'm a bit leery of quotes because the open quote and the close quote are the same character. If you want to determine whether the quote the user typed is an opener or a closer, you have to look at the context.
I'm thinking maybe: If the user typed a quote, look at the previous character. If it's whitespace, or a colon, equals sign, or open bracket, or if you're at the start of the line (there is no previous character), then it's an opener and should be closed. Anything else, ignore it. Does that make sense to you? Too simpleminded?
Nah! That would be too hard to use. The user would have to press (and the plugin handle) all these.And maybe something like @jpavel's original idea ... use Alt-(, Alt-[ (et cetera) when you want an automatic closer.
pszKey = Alt-`
pszKey = Alt-[
pszKey = Alt-'
pszKey = Alt-Shift-9
pszKey = Alt-Shift-[
pszKey = Alt-Shift-'
Maybe I'll add the single quote. It's nothing special (?). I'm pretty sure I only use it to quote a string inside a WMI query.
WCHAR c;
if ( lpki->nKey == ( c=L')' , L'(' ) ||
lpki->nKey == ( c=L']' , L'[' ) ||
lpki->nKey == ( c=L'}' , L'{' ) ||
lpki->nKey == ( c=L'`' , L'`' ) ||
lpki->nKey == ( c=L'\"' , L'\"' ) ||
lpki->nKey == ( c=L'\'' , L'\'' )
)
{
AddCloser(lpki, c);
return 0;
}
Code:WCHAR c; if ( lpki->nKey == ( c=L')' , L'(' ) || lpki->nKey == ( c=L']' , L'[' ) || lpki->nKey == ( c=L'}' , L'{' ) || lpki->nKey == ( c=L'`' , L'`' ) || lpki->nKey == ( c=L'\"' , L'\"' ) || lpki->nKey == ( c=L'\'' , L'\'' ) ) { AddCloser(lpki, c); return 0; }
Hey Charles ... speaking of headaches, how about this.
Code:VOID AddCloser(LPKEYINFO lpki, WCHAR closer) { WCHAR *p = lpki->pszCurrent; while ( *p++ != UNICODE_NULL ); while ( p > lpki->pszCurrent ) { *p = *(p-1); p -= 1; } *p = closer; }
for ( wchar_t *p = lpki->pszCurrent + wcslen( lpki->pszCurrent ); p >= lpki->pszCurrent; p-- )
p[1] = *p;
lpki->pszCurrent[0] = closer;
VOID AddCloser(LPKEYINFO lpki, WCHAR closer)
{
WCHAR *p = lpki->pszCurrent;
// this loop will stop when *p == 0 (and p will be incremented)
while ( *p++ != UNICODE_NULL );
// now p points one past the terminating null
while ( p > lpki->pszCurrent )
{
*p = *(p-1); // move each character one to the right (starting with the terminating null)
p -= 1;
}
// insert the closer
*p = closer;
}