tooltips in Visual Studio 2010 - visual-studio-2010

Sometimes I prefer to add a comment after declare a variable. For example:
bool isOverhwndChild1; // This is just an example to make my question clear and you can understand.
bool isOverhwndChild2; // This is just an example to make my question clear and you can understand.
bool isOverhwndChild3; // This is just an example to make my question clear and you can understand.
bool isOverhwndChild4; // This is just an example to make my question clear and you can understand.
I installed Visual Assist X.
If I move mouse over thses variables, a tooltip will show up and display the comments. But if the comment is very long, the width of the tooltip is very large.
I don't want to write as following since it distract me from the declaration of variables:
// This is just an example
// to make my question clear
// and you can understand.
bool isOverhwndChild1;
// This is just an example
// to make my question clear
// and you can understand.
bool isOverhwndChild2;
// This is just an example
// to make my question clear
// and you can understand.
bool isOverhwndChild3;
// This is just an example
// to make my question clear
// and you can understand.
bool isOverhwndChild4;
Is there a way to put a newline character in the comments in VS2010 so the tooltip will display multilines?

At the moment comments and tooltips are both long or they are both multilined. It would be nice if there were some mark-up (\n, < br />, or something like this) to have a better control here. Or an option where you can specify the maximum width of such a tooltip would solve your problem, too.
As a "workaround" I suggest to try to make the comments shorter even if the variable names get longer. If a variable is self-explanatory this even supports the readability of your code

Related

ScintillaNet - detect mouse over

is it possible to react when the mouse is over a word ? Suppose I want to show a bubble with a description of the thing I'm currently hovering. Seems strangely difficult to do.
I think it is possible but might be a little hard.
You have the MouseHover event however you don't know what word you hovered so it might be a little hard.
You can get the mouse localization with this:
Point mouseLocation = new Point(e.X, e.Y)
Then if you use a fixed-width type font you know the size of each line/character then you can calculate it.
Some code that helps with position/line transition:
var line = scintilla.LineFromPosition(startPos);
startPos = scintilla.Lines[line].Position;
scintilla -> Control Name
For a better view try seeing this:
https://github.com/jacobslusser/ScintillaNET/wiki/Custom-Syntax-Highlighting
https://github.com/jacobslusser/ScintillaNET/wiki/Basic-Text-Retrieval-and-Modification
Edit:
Not really a good answer soo 2nd try
[scintilla name].CurrentPosition -> you can get the word you selected if I'm not mistaken but I don't know if you can do it by hovering.
Then do the interpretation of the word and it might work.
Try reading this:
https://github.com/jacobslusser/ScintillaNET/issues/149
3rt Try.
Let's hope it's the best one.
https://github.com/Ahmad45123/AutoCompleteMenu-ScintillaNET
There is AutoCompleteMenu for Scintilla that has a hover property.
I'm not sure how it works but might be what you're searching for.

How to insert text into an Ace Editor instance as a comment

I am building a website where I want to allow people to code in almost any language that the Ace editor supports. Right now I have it redirect if they try to load a language that either isn't supported by Ace, or that I didn't list in my supported languages. I only have a few languages that I allow to run (because I haven't got others to work or don't know how to), and for all those other languages that aren't run-supported, I want to load the Ace editor with a note saying that the language they loaded isn't supported for running, but I want it to be a comment in that language.
I tried inserting the text using editor.setValue([message], -1). Then set the focus on the editor using editor.focus(). Then I select all the text with editor.selectAll(). And then use the editor.toggleCommentLines() to make it a comment. For some reason this doesn't work, and I am not sure why.
I know that I could just look up how to write comment in each of the languages that I am allowing, and then convert the message into a comment before inserting it into the editor, but I want an easier way if possible.
Is there an easier way to do it? Or should I just do what I said that I could?
Since I answered my own question, I want to ask another to see if anyone has the answer for this:
When in the Ace editor you can press CTRL+/ to toggle line comments. But if you press CTRL+SHIFT+/ it will toggle multiline comments. I don't see a function for this in the Ace editor documentation but because it works with a keyboard shortcut, there must be a way to do it programmatically, right?
If someone could figure this out, that would be great!
a user found it! See his comment to see the answer to this part.
I was trying a few more things, and one of them was doing a setTimeout on the editor.toggleCommentLines(), and that worked. The timeout worked best if I used 150ms or higher (I started with 2000 just to see if it worked at all, and then slowly moved down).
So the following code works to automatically insert a message and comment it out:
const editor = ace.edit([element]);
editor.setValue([message], 0); // You can also leave the second parameter blank, 0 is the default which automatically selects all.
setTimeout(() => {
editor.toggleCommentLines();
}, 150); // 150ms or more works best
You may also notice that this method clears out 2 methods that I was previously using. There are two reasons for this:
When using 0 instead of -1 for the second parameter of editor.setValue() it selects all the text.
Because we are using the editor variable, the editor doesn't need to be in "focus".

Can AndroidDeveloper do anything like XCode's // MARK: - ...?

One of the features I use a bunch in larger code bodies in XCode is the ability to delineate/label blocks of functionality with // MARK: comments. These get used by the IDE to label things in the menus. I'm porting an app to AndroidStudio/Kotlin, and really missing this. Is there anything like this? I've found the Structure view, but I don't see any hints that comments influence it at all.
Not exactly the same but you can do:
//region RegionName
... code ...
//endregion
and you'll be able to fold this section of code.

Script to enable mouse shadow?

I've found people asking this question on some forums, but no solutions. This is a small but annoying cosmetic problem many people know.
Some full screen programs disable the shadow under the cursor in Windows. The shadow usually comes back, but when is doesn't (for example the program didn't close normally) the mouse appears without shadow, and you have to go and manually enable it back.
The solution I'd like to do is a .bat or .vbs to enable the shadow, only I haven't figured how.
What I did find is that it's a registry value, and there is also something to do to "refresh" the cursor and make the shadow appear. Can anyone help?
I'd like to add that I have very small experience in .bat or .vbs writing, so if you know what to do and how, please post the how too.
Using the API makes it take effect immediately.
#include <Windows.h>
int main() {
BOOL didSucceed = SystemParametersInfo(
SPI_SETCURSORSHADOW,
0,
(PVOID) TRUE,
SPIF_UPDATEINIFILE + SPIF_SENDCHANGE);
return didSucceed ? EXIT_SUCCESS : EXIT_FAILURE;
}
It's located in the famous (yet undocumented :-) "UserPreferencesMask" registry key.
Here are some pointers:
A first general link with information on this key, and how the mouse shadow setting is defined: HKCU\Control Panel\Desktop\UserPreferencesMask
And a sample that explain how to code it using VBSCript (it's another key, but the principle is the same): Set UserPreferencesMask Binary Registry Key

Symbian S60 - Scrolling text in a CEikLabel

I have a single line CEikLabel in my application that needs to scroll text.
The simple solution that comes to mind (but possibly naive) would be something like..
[begin pseduo code]
on timer.fire {
set slightly shifted text in label
redraw label
}
start timer
[end pseudo code]
Using a CPeriodic class as the timer and label.DrawDeferred() on each update.
Do you think this is the best way, it may be rather inefficient redrawing the label two or three times a second.. but is there any other way?
Thanks :)
I've seen the timer based solution used for scrolling item names in listboxes.
A couple of things to watch out for are that it could flicker a bit while scrolling and that you need to make sure the text you put on the label is not too long, otherwise it will automatically clip the string and add an elipsis (...)
Use TextUtils::ClipToFit to get a string that fits on the label and remove the elipsis it adds before putting the text on the label (search for KTextUtilClipEndChar in your clipped string). You will need to work out how many characters to skip at the beginning of the string before passing it to the clip function.
I don't know whether there is another way to do it and can't say whether the approach you have in your mind will be inefficient. However, you may want to take a look at this thread which discusses pretty much the same question as yours and also briefly mentions somewhat the same solution as the one you have conceived of.
I have done it like this
TTimeIntervalMicroSeconds32 scrolltime(70000);
iPeriodicScroll = CPeriodic::NewL(CActive::EPriorityIdle);
iPeriodicScroll->Start(scrolltime, scrolltime, TCallBack(CVisTagContainerView::ScrollTextL, this));
and then in the repeated function
CEikLabel *label = iContainer->Label();
const TDesC16 *temp = label->Text();
if (temp->Length() <= 0) {
if (iTextState != ETextIdle) { return; }
DownloadMoreTextL();
return;
}
TPtrC16 right = temp->Right(temp->Length()-1);
label->SetTextL(right);
label->DrawDeferred();
So text moves right to left, and when all gone, the label is repopulated by DownloadMoreTextL

Resources