ctag ignores classes in c++ - c++

how do you make ctags account for class in c++? when i jump to a tag of a function i get to the same name of the function but in a wrong class.
B b;
b.init();
and there are
A::init() {}
B::init() {}
i put the cursor on init of b.init() and the jump is to A::init() {} instead of B::init() {}.
Note, i didn't use a and b in my code. so this might not work if u run ctags. if it's not a common problem i ca post the actual code.

This doesn't solve your original problem, but a mapping such as the following may help:
nnoremap CTRL+] :exe 'tj' expand('<cword>')<CR>
This will at least make CTRL+] show you a selection menu when there are multiple definitions of init().

I am not aware of any method to do this, as it would require vim to do c++ parsing. In that situation I use :tselect to show the whole list and choose one.

I wrote lh-tags to solve this problem [It will require lh-vim-lib.]
It does not recognize whether b is a A or a B, but it proposes a little GUI to select which tag we want to jump to.
See it as an interactive :tselect. Put the cursor on an identifier and type <c-w><m-down> in normal mode (which is configurable). It also proposes ways to build and update the ctags base on <c-x>ta and on :w given that g:/b:ctags_dirname has been set for the current project.

Related

autocompletion of parameter : list static fields without typing a ClassName::

How to make auto-completion list all (static) fields of a certain class that has appropriate variable-type when ctrl+space at a slot of parameter in a certain function?
Example
I tried to ctrl+space in the below code :-
(Code as text is here.)
Question: How to make it show E_1 E_2 E_3?
I don't mind another plugin if I really need one.
It currently works but only for enum :-
My workaround
In practice, to get smart clue, I have to type more (PrototypeList::) :-
Bounty Reason
Here is the result of the current answer (citizenmatt's):-
It is different, but still not show E_1 E_2 E_3.
Have you tried Smart Completion? This feature will only show completion items that are valid for the current context. I think it works in C++, too.
In fact, ReSharper does help you here. All of E_1, E_2 and E_3 are in the completion list, but not on the top of it - they are assigned lower scores because they need an additional qualifier. That said, looks like there is still an issue with scoring:
E_2 and E_3 are in the list too, but they are not shown alongside E_1. We'll investigate this (RSCPP-19501).

How to define a primitive device in Proteus?

I'm trying to make my own full adder and some other devices as a sub-circuit in "Proteus" and use them several times in a bigger circuit.
The problem is when you copy a sub-circuit you need to rename all of its inner parts, otherwise, the parts with a same name in two sub-circuits would be considered as one, therefore you'd get some errors.
So I'd like to know if there is a way to define a full adder of my own and use it like "74LS183" which is a primitive device, and by primitive I mean it has been defined in the library.
From answer posted here
It's in the Proteus Help file:
SCHEMATIC CAPTURE HELP (F1) -> MULTI-SHEET DESIGNS -> Hierarchical Designs
See the section "Module Components":
Any ordinary component can be made into a module by setting the Attach Hierarchy Module checkbox on the Edit Component dialogue form.
The component's value is taken to be the name for the associated circuit,
and the component's reference serves as the instance name.
after this you can use your new implementation of that component with your new name. for making it available at library see "External Modules" section of proteus help.
The problem with copying is solved in "Proteus 8".not completely but sort of.
I mean you can copy a subcircuit without a need to change it's inner parts, but you must change the subcircuit name and I mean the bigger name above the subcircuit not the little one below it.
so there is no need to define a primitive.

QScintilla - Add color to words in a custom lexer

I am trying to create a custom lexer based off of JavaScript for QScintilla. I have figured out how to add keywords the the lexer. However, I can not figure out how to alter the way they look when typed in like it does when you type the word function, for example.
I need to figure out how to do this with, for example, the word "fill".
Here's the code I currently have:
QsciLexer *lexer=new QsciLexerJavaScript;
QsciAPIs *api = new QsciAPIs(lexer);
api->add("fill");
api->prepare();
ui->textEdit->setLexer(lexer);
You need to subclass the QsciLexerCustom class. Then you need to make/configure several QsciStyle objects inside that class. The actual syntax highlighting is done in the styleText() function, which you need to override.
You can find detailed explanation on this website:
https://qscintilla.com/
More specifically on this page:
https://qscintilla.com/syntax-highlighting/
I hope it helps

Putting Controls at ToolBar- Stuck

I have been staring at this documentation for 5 hours now. I simply cant connect the steps. If you guys can enlighten me of the stuff.
Here is the site:
http://msdn.microsoft.com/EN-US/library/bb983718(VS.110).aspx
So my problem are the following:
-at number 5, it asked me to "Set these parameters as follows:", it didnt even mention anything about where? Where to implement the constructor, and why are we using CMFCToolbarComboBoxButton? when it already asked me at step 4 to derive a clas called CFindComboButton. Shouldnt I be making a contstructor for that one instead?
-at number 4(sorry about the non organized numbering of problems), what I did is use the add class (not the class wizard), and then I picked MFC Class. I then enter the supposedly CFindComboButton and Base class as CMFCToolBarComboBoxButton. Did I do something wrong on this one? Do I have to do anything for the ID ID_EDIT_FIND_COMBO?
-When I register the ID_EDIT_FIND_COMBO at the String Table, I dont exactly know what I did. Did I just register an id for future implementation? or is it something else?
-So I cant do step 5, I skipped to step 6. All it ask me is to look for the CreateCombo method athe the override section of properties at CFindComboButton. Well I can only find 3 override. None of them are CreateCombo method. Well from there, you can tell that I'm lost.
I'm a noob at mfc so you might wanna take that in consideration.
Even though your question is a bit jump-led up, let me try and answer so that it works for you.
Create two class - one derived from CComboBox (call it CFindComboBox) and another from CMFCToolBarComboBoxButton (call it CFindComboBoxButton). First class will implement the Combobox that will be shown when you click the drop down button in the toolbar. This drop down button is implemented by CFindComboBoxButton. Hope this is clear.
Now define the constructor for the CFindComboBoxButton as CFindComboBoxButton(UNIT nID, int nImage, DWORD dwStyles) using three parameters as explained below:
Command ID of the button which will be ID_EDIT_FIND_COMBO (or anything you want to define it as). This will get defined in the String Table. Just add a new entry in String Table with ID_EDIT_FIND_COMBO as ID and a placeholder string. Don't omit the string value else the ID will not get defined. The string value can be anything as it wont be used anywhere.
Second parameter will just be a call to CCommandManager::GetCmdImage(ID_EDIT_FIND). This will return the default image used to show the drop down for combobox. In case you want to use your own custom image you can create one and instead pass the ID of that.
Third parameter is the styles you want to use. They are defined at http://msdn.microsoft.com/EN-US/library/7h63bxbe(v=vs.110).aspx but you can use the default value (CBS_DROPDOWNLIST) to start with.
Override the CreateCombo method of CMFCToolBarComboBoxButton and add its implementation to CFindComboBoxButton. In this method create and return a pointer to CFindComboBox (CComboBox derived class).
I hope this clears all the confusion and you should be on your way to have a custom Combobox embedded inside a toolbar.
take a look at the VisualStudioDemo Sample:
http://msdn.microsoft.com/en-us/library/bb983983%28v=vs.90%29.aspx
you can find the CFindComboButton implementation there

How to create automatic a list of items used in a LaTeX-document?

I want to add items in a LaTeX-document. Say for example, that I want add hints to the document. I create a command, so I can call something similar to this:
\hint{foocareful}{Be careful with foo!}{foo is a very precious item and can easily be broken. Be careful, especially don't throw foo.}
This will be formatted in special way, to make it easy for the reader to recognize it as a hint. It gets a label, that can be referenced in the example with 'foocareful'.
In the appendix I want to add a list of all hints with references to them. Something like:
\begin{enumerate}
...
\item Be careful with foo! (\pageref{foocareful})
...
\end{enumerate}
But naturally I don't want to maintain this list by hand. How can I create automatically such a list?
One way to do it is to use the float package. I think that, at least, the floatrow package can also do what you want, and may also be more flexible. See you go, though.
Here's an example of something like you're trying to do using float:
\documentclass{article}
\usepackage{float}
\floatstyle{boxed}
\newfloat{hintbox}{H}{hnt}
\floatname{hintbox}{Hint}
\newcommand\hint[2]{%
\begin{hintbox}
#2
\caption{#1}
\end{hintbox}}
\begin{document}
\section{Hello}
\hint{Be careful with foo!\label{foocareful}}{%
foo is a very precious item and can easily be broken.
Be careful, especially don't throw foo.}
\hint{Don't worry about bar!\label{foocareful}}{%
Unlike foo, bar is pretty easily to get along with.}
\section{End}
\listof{hintbox}{List of Hints}
\end{document}
Have not done this in years, but I would look at the LaTeX source code for \tableofcontents and \listoffigures. I think the mechanism is generic and you can expand it to include your own lists.