Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Surround selection with different #ifdef-s
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

KirillMueller
Ketchup Master

72 Posts

Posted - Jun 18 2007 :  02:11:33 AM  Show Profile  Reply with Quote
Pressing the '#' key to surround a selection with #ifdef <symbol> /#endif is quite useful. A natural enhancement of this feature would be to configure multiple symbol names and let the user choose the appropriate from a context menu (like the "paste" menu) if more than one symbol is configured. The symbol last chosen could be selected first in the context menu.

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Jun 18 2007 :  4:19:09 PM  Show Profile  Reply with Quote
Have you looked into using autotext with $selected$?

http://www.wholetomato.com/products/features/autotext.asp

When you trigger insert autotext with text selected only the items that work kn selected text are offered.

zen is the art of being at one with the two'ness
Go to Top of Page

KirillMueller
Ketchup Master

72 Posts

Posted - Jun 18 2007 :  4:59:00 PM  Show Profile  Reply with Quote
Right, this does fine for me

However, why doesn't VAX insert the selected text when I use a shortcut to access such an autotext?

I've defined an autotext using the shortcut -?-? like that:

#ifdef $end$SYMBOL
$selected$
#endif // SYMBOL

Now, when I select multiple lines and hit -? twice, the autotext is offered but the selected lines disappear and don't reappear after selecting the autotext. Is this by design? If no, fixing this would be the dot on the i.

Build 10.3.1557, VS 2005.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Jun 19 2007 :  07:03:42 AM  Show Profile  Reply with Quote
I am a little confused. By default when you select text in the IDE and then type the selected text is replaced by your typing. VA's surround selection feature is a special case, but autotext shortcuts can be nearly anything, so VA will not know that you are typing an autotext shortcut.

Is -? supposed to indicate a specific key on they keyboard? It is not a character I recognise, or would know how to type.

zen is the art of being at one with the two'ness
Go to Top of Page

KirillMueller
Ketchup Master

72 Posts

Posted - Jun 19 2007 :  07:28:23 AM  Show Profile  Reply with Quote
-? is a character on the German keyboard, replace it by any symbol that you can easily type and has no meaning in the C++ language, like $.

VA doesn't know that it's an autotext shortcut -- until the user selects the autotext from the context menu. The following easy algorithm will do:

1. On typing a character, if the selection is not empty, memoize its contents.
2. On moving the caret or otherwise repositioning, forget the selected text.
3. On confirming the insertion of an autotext, insert the memoized selection at the $selected$ mark in the autotext.

In short, just use the text that has been last replaced by a character.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Jun 19 2007 :  08:08:45 AM  Show Profile  Reply with Quote
I rather like this idea, but I suspect it will cause a lot of problems when people use an autotext entry that has $selected$ in it, but did not want to operate on some selected text.

I am thinking about the following situation:

You are using the standard for autotext entry:

for ($end$)
{
	$selected$
}


you select some random text, and then type int, then delete it, then type for and accept the autotext prompt.

At this point VA has no way of knowing if they wanted to include the previously selected text in the for loop or not.

Changing the rules to clear the remembered selected text as soon as a character is deleted does not work very well either, since what happens if you make a mistake typing the autotext shortcut, and type foo[BACKSPACE]r


Are you aware you can bind a keyboard shortcut to VAssistX.InsertAutotext?

zen is the art of being at one with the two'ness
Go to Top of Page

KirillMueller
Ketchup Master

72 Posts

Posted - Jun 19 2007 :  08:23:02 AM  Show Profile  Reply with Quote
I'd vote for forgetting the selection if a character is deleted. That's most intuitive, I think.

There's two kinds of users -- mouse users and keyboard users. Autotext shortcuts aren't for mouse users. If a keyboard user errs on typing a shortcut, hitting Alt+Backspace (undo) several times takes fractions of a second; the overwritten text is selected and the user can start over.

There could even be a special entry for the most recently overwritten text in the "special paste" menu (Ctrl+Shift+V).

Yes, indeed, I've assigned Alt+# as shortcut for VAssistX.InsertAutotext. It would be nice to have shortcuts for autotext entries with selected text, though.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Jun 19 2007 :  11:38:59 AM  Show Profile  Reply with Quote
I am definitely a keyboard user myself, but typo's when typing autotext shortcuts are something that happen often enough to me for me to be very aware of this possible issue. Having said that this idea seems a reasonable comprimise, so I have put in a feature request to see what our developers make of the idea:

case=7169


For the keyboard shortcut InsertAutotext, try triggering it with and without text selected, you should get two different lists of autotext entries. When you have selected text the main list is only items that include $selected$.

zen is the art of being at one with the two'ness
Go to Top of Page

Xuma
New Member

USA
3 Posts

Posted - Jul 14 2007 :  4:36:03 PM  Show Profile  Reply with Quote
I'm going to jump into this interesting discussion and suggest that surround+# work in C# as well as C/C++. #if...#ifdef is a valid construct for C# and I don't see why there is a restriction to C/C++ only.

DF
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18939 Posts

Posted - Jul 16 2007 :  08:01:16 AM  Show Profile  Reply with Quote
In C# VA adds the ability to surround code with #region, #endregion
Not quite the same as #ifdef, #endif, but from the C# code I have seen this should be quite useful.

Certainly if we add this ability then it needs to work in C# and VB as well as C++.

For now you should already have the C# autotext entry:

#if $end$
$selected$
#endif

so you just need to select the code you want to wrap and then trigger insert autotext.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000