Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Assist for include files
Assist for include files [message #31016] Tue, 01 February 2011 11:06 Go to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
Hello,

I'm working to add to the ide a new feature similar to visual studio 2010. When the user types include and the the key < or " the window will PopUp having all the appropriate files in it.

I use as a reference the assist used to displaying function names.
So far so good, but i'm having some issues.

1. Apparently i can't figure out why normal assist will close when pressing Escape and my assist will not. Also i can't find any code related to that. I could just add a statement to take care of that but i don't know what other side effects this might have.
2. What would be the best approach: having the files scanned when the assist will open? or to scan the files in advance (when the package is loaded) and just fill the assist with already existent data.
3. What is the Key code for '"'? because i can't figure it this out with the debugger.
4. Are there any hidden issues i have to address?

Thanks,
Raxvan.


92b48bf94855483bb4cec8bcc8c0c933
Re: Assist for include files [message #31043 is a reply to message #31016] Wed, 02 February 2011 10:17 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Raxvan
raxvan wrote on Tue, 01 February 2011 11:06

I'm working to add to the ide a new feature similar to visual studio 2010. When the user types include and the the key < or " the window will PopUp having all the appropriate files in it.

I use as a reference the assist used to displaying function names.
So far so good, but i'm having some issues.

Good idea, although I have to warn you that it might not be as easy as it seems. I did attempt something similar once (showing annotation in the editor), but failed. AssistEditor code is quite a jungle Smile

raxvan wrote on Tue, 01 February 2011 11:06

1. Apparently i can't figure out why normal assist will close when pressing Escape and my assist will not. Also i can't find any code related to that. I could just add a statement to take care of that but i don't know what other side effects this might have.
The assist is handled at many different places, e.g. in AssistEditor::LeftDown() it is closed when you click in the editor. I guess (don't see the code right now) that closing on esc might be handled similarly. Anyway, I think it might be easy to actually extend current Assist behavior to do this than write a new one...
raxvan wrote on Tue, 01 February 2011 11:06

2. What would be the best approach: having the files scanned when the assist will open? or to scan the files in advance (when the package is loaded) and just fill the assist with already existent data.
Depends on what exactly you want to show. If you restrict to files from packages in current project (which would be just fine IMHO), you can process this information very fast because it is already stored within theide. If you wan't to scan for files on disk than some clever pre-reading might be needed. Or you can cheat and suggest user some fixed set of standard system headers + the files in packages Wink
raxvan wrote on Tue, 01 February 2011 11:06

3. What is the Key code for '"'? because i can't figure it this out with the debugger.
It's \x22 (or 34 in decimal) or you can just write '\"'. Neat trick: In theide press Ctrl+E to show calculator, type '"' and press enter Wink
raxvan wrote on Tue, 01 February 2011 11:06

4. Are there any hidden issues i have to address?
Nothing I am aware of right now, as long as it behaves like regular assist, it should be fine. In case you will be searching for files on disk, you should make sure it is very fast - slow dialogs are annoying for users Wink

Also if you want to take part in theide development, you should probably ask Mirek for a Redmine account and create a feature issue in the issue tracker we just recently started to use Wink

Best regards,
Honza
Re: Assist for include files [message #31047 is a reply to message #31043] Wed, 02 February 2011 11:30 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
Hello,
dolik.rce wrote on Wed, 02 February 2011 10:17


Good idea, although I have to warn you that it might not be as easy as it seems. I did attempt something similar once (showing annotation in the editor), but failed. AssistEditor code is quite a jungle Smile


I can see Smile, but i find the ide code really easy to understand.
dolik.rce wrote on Wed, 02 February 2011 10:17


The assist is handled at many different places, e.g. in AssistEditor::LeftDown() it is closed when you click in the editor. I guess (don't see the code right now) that closing on esc might be handled similarly. Anyway, I think it might be easy to actually extend current Assist behavior to do this than write a new one...


I have that fixed now, the file assist opens and closes properly.
The next step left is populating the popup with proper stuff.

dolik.rce wrote on Wed, 02 February 2011 10:17


Depends on what exactly you want to show. If you restrict to files from packages in current project (which would be just fine IMHO), you can process this information very fast because it is already stored within theide. If you wan't to scan for files on disk than some clever pre-reading might be needed. Or you can cheat and suggest user some fixed set of standard system headers + the files in packages Wink


I want to show the files in all the assembly paths from the current project. Also the files from include directories. I'm thinking to do a scan in advance but in this case i have to handle all the changes (add file, remove file, etc).

dolik.rce wrote on Wed, 02 February 2011 10:17


It's \x22 (or 34 in decimal) or you can just write '\"'. Neat trick: In theide press Ctrl+E to show calculator, type '"' and press enter Wink


Fixed , the problem was in some other place , actually the key was equal to '"' but the code was busted.

dolik.rce wrote on Wed, 02 February 2011 10:17


Also if you want to take part in theide development, you should probably ask Mirek for a Redmine account and create a feature issue in the issue tracker we just recently started to use Wink


Will do , once i have a working beta of this.


Thanks,
Raxvan.


92b48bf94855483bb4cec8bcc8c0c933
Re: Assist for include files [message #31048 is a reply to message #31047] Wed, 02 February 2011 12:21 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

raxvan wrote on Wed, 02 February 2011 11:30

dolik.rce wrote on Wed, 02 February 2011 10:17

Good idea, although I have to warn you that it might not be as easy as it seems. I did attempt something similar once (showing annotation in the editor), but failed. AssistEditor code is quite a jungle Smile
I can see Smile, but i find the ide code really easy to understand.
Yes, once you *find* what you are looking for, then it is really easy to read Very Happy

raxvan wrote on Wed, 02 February 2011 11:30

I want to show the files in all the assembly paths from the current project. Also the files from include directories. I'm thinking to do a scan in advance but in this case i have to handle all the changes (add file, remove file, etc).

Is there some point to suggest non-project packages from assemblies? In 99% of cases you have to add the package to make any use of the headers inside. The files from include directories are different situation of course, and it makes sense to suggest them. I'd personally prefer creating a list at the start of theide and check for changes only on request (on Assist -> Rescan code). You will see how fast you can write it, if it would delay starting too much, you would have to do some trickery e.g. creating the list in a background task (can be done using callbacks).

Actually it would be nice if some of the present scanning was rewritten into separate threads... That would speed things nicely, since the disk I/O heavy task (including yours) could be done in background, while user could already work.

Honza
Re: Assist for include files [message #31050 is a reply to message #31048] Wed, 02 February 2011 13:55 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
dolik.rce wrote on Wed, 02 February 2011 12:21


Is there some point to suggest non-project packages from assemblies? In 99% of cases you have to add the package to make any use of the headers inside. The files from include directories are different situation of course, and it makes sense to suggest them. I'd personally prefer creating a list at the start of theide and check for changes only on request (on Assist -> Rescan code).


You are right, the only files you *should* use should already be in a package in current project. Therefore i will stick, for now, with these files only.

I think in visual studio the files are scanned on request based on the current path. This system allows the user to see files from paths such as "../../Folder/etc". I personally believe this should not be allowed because paths like these are confusing. Therefore i will not implement something like this.

Raxvan.


92b48bf94855483bb4cec8bcc8c0c933
Re: Assist for include files [message #31071 is a reply to message #31016] Thu, 03 February 2011 19:06 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
Hello,
Here is a simple image with the work i have done.
The method chosen to scan the files is mixed. Some files are stored in a Vector and the rest of the files are scanned on demand.
The scanning is performed using the class CoWork (I suggest including this CoWork class into the main Ide class so other heavy operations, such as FindInFiles and Assist Code Scanner, to work in background).
The behavior is exactly like normal assist and ~95 % of it is already implemented/working/tested.


I have one question:
What type (or what methods) has a class to implement in order to work as a row in ArrayCtrl? Because now i use AttrText and when i insert i can only use the current row in the ArrayCtrl.
I would like to have some extra data associated with each row in order to finish this.

I used Windows to develop this, but i think it should work fine with linux too.


Thanks,
Raxvan.
  • Attachment: demo.PNG
    (Size: 45.68KB, Downloaded 292 times)


92b48bf94855483bb4cec8bcc8c0c933

[Updated on: Thu, 03 February 2011 19:08]

Report message to a moderator

Re: Assist for include files [message #31073 is a reply to message #31071] Thu, 03 February 2011 19:32 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

That looks great Thumbs Up

One hint: I believe that for the quoted style includes, only files from current package should be suggested. IIRC the gcc search for the file relatively to the current file, so if the other package was in different assembly, it might cause problem. Also it is IMHO a good coding style to use #include "file.h" only for "local" files.

Have you tested how the CoWork solution works on single core processor? (Or when you set affinity of the process to single core...).

Unfortunately, I can't answer the question about ArrayCtrl, as I don't know answer...

Looking forward to see the code Wink

Honza
Re: Assist for include files [message #31074 is a reply to message #31016] Thu, 03 February 2011 19:50 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
Hello,

When the include assist uses quotes ('"') the current file is taken (theide->editfile) and a search is performed. I can see that 'editfile' variable holds the entire path to the current edited file , therefore i extract the path from that and i perform a search based on that path. This will give only "local" files/folders.

The only files stored and prescanned are the files from VC Include Directories + All files/folders from the current Assembly. I chose to store these files because the high count.

I can't test CoWork anywhere because i have no single core machines Sad . CoWork is very simple to use (just Do(THISBACK(...)), and don't care how the function will run.) and i never encountered problems with this system. There will be more extensive testing later.
Using this required me to modify the current build configuration for the Ide to be multithreaded.
The "Loading..." message is there for a very short amount of time (~0.1 seconds or less) but i will keep it there in case of some existing heavy disk operations.

The icons and the look may not be final.

Raxvan.


92b48bf94855483bb4cec8bcc8c0c933
Re: Assist for include files [message #31075 is a reply to message #31074] Thu, 03 February 2011 21:58 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

raxvan wrote on Thu, 03 February 2011 19:50

When the include assist uses quotes ('"') the current file is taken (theide->editfile) and a search is performed. I can see that 'editfile' variable holds the entire path to the current edited file , therefore i extract the path from that and i perform a search based on that path. This will give only "local" files/folders.
I guess it is more of a philosophical question Smile Or matter of taste. My point of view is this: If I wan't to include something from other packages, I should include them first (so I don't forget to do it later Smile ). Secondly, if I wan't to include something from other package, I will always use <pkg/file.h> for a simple reason that another user might have different setup of assemblies (e.g. two nest from non-neighboring directories) and then "pkg/file.h" might not make sense. From this follows that a) only local package files can be shown when '"' is pressed and b) only files from loaded packages can be suggested. Both of these cases save you scanning disk, since those files are already accessible through ide.IdeWorkspace(). So the only thing that is IMHO really needed to be looked up on disk are the system headers from include directories and those doesn't change very often, so it might be even possible to cache the list in a single file to have it ready at start and check if it is up to date later (e.g. when the application is idle). That way you wouldn't even have to worry about speed. But that is all just my opinion, if you think you will need more files suggested or something else, you are free to do it Wink

raxvan wrote on Thu, 03 February 2011 19:50

I can't test CoWork anywhere because i have no single core machines Sad . CoWork is very simple to use (just Do(THISBACK(...)), and don't care how the function will run.) and i never encountered problems with this system. There will be more extensive testing later.
Using this required me to modify the current build configuration for the Ide to be multithreaded.
The "Loading..." message is there for a very short amount of time (~0.1 seconds or less) but i will keep it there in case of some existing heavy disk operations.
You can test by instructing the process to use only single core using Task manager (there should be Set Affinity in context menu for each process on Processes tab) but if it is under 1 second it is probably OK even if it was executed in serial.

Honza
Re: Assist for include files [message #31082 is a reply to message #31016] Fri, 04 February 2011 09:15 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
Hello,

I have created a rar file with the source files of the ide so everyone can test it. The code is not final, as you will see the path dose not support `../` and deleting a `/` will close the assist.

For fix these issues with a nice solution requires some thinking. This might delay the final product with 2-3 days.

My only concern is about linux (i haven't had any time to try it out) and filenames containing special characters. FindFile will only return a String not a WString.

http://dl.dropbox.com/u/9887398/ide.rar

Raxvan.


92b48bf94855483bb4cec8bcc8c0c933
Re: Assist for include files [message #31088 is a reply to message #31082] Fri, 04 February 2011 12:40 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Raxvan
It works quite fine on my Arch Linux Smile Only problem I noticed is that the system include files are not suggested. I'll try to figure out why...

Also to make it compile, I had to do a little changes in IncludeFileDisplayClass::Paint0() because Clang refused to compile "Image & img = BrowserImg::IncludeFile()", so I had to change it to "Image img = ...".

One thing that should be definitely changed is the "ToUnicode(txt, CHARSET_WIN1250)", I think there should be GetDdefaultCharset() or something like that.

I'll probably post more ideas after I have some time to dig in the code a bit Wink

Honza

PS: Could you use same icons as the rest of theide? It feels a bit distracting Wink

[Updated on: Fri, 04 February 2011 13:00]

Report message to a moderator

Re: Assist for include files [message #31089 is a reply to message #31016] Fri, 04 February 2011 13:29 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
Hmm ,
I think you have to look into the function void AssistEditor::ScanFrontFiles() and see what paths are chosen for the search.
The line Vector<String> tmp = SplitDirs(GetVar("UPP") + ';' + BuildMethodMap.Get("INCLUDE", "")); is supposed to get all of them.
Please check if function NativePath(tmp[i]+"\\*") will return the correct path.

The charset CHARSET_WIN1250 was chosen from the original assist. There, the function that inserted code into the source was "Paste(ToUnicode(txt, CHARSET_WIN1250))"

The icons are not final, i can easily change them , but i like the ones i used more Smile.


Thanks,
Raxvan.


92b48bf94855483bb4cec8bcc8c0c933
Re: Assist for include files [message #31184 is a reply to message #31016] Fri, 11 February 2011 19:09 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
Hello,

I have created a new archive with the latest version of the Include Assist.
There have been some major modifications and this one is almost the final one.
I will post a more detailed description of the progres later.
http://dl.dropbox.com/u/9887398/ide.rar

Raxvan


92b48bf94855483bb4cec8bcc8c0c933

[Updated on: Fri, 11 February 2011 19:11]

Report message to a moderator

Re: Assist for include files [message #31193 is a reply to message #31016] Sat, 12 February 2011 15:11 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
Hello,

New images:
http://dl.dropbox.com/u/9887398/Screenshot.png
http://dl.dropbox.com/u/9887398/Screenshot-2.png
http://dl.dropbox.com/u/9887398/Screenshot-3.png
http://dl.dropbox.com/u/9887398/Screenshot-4.png


92b48bf94855483bb4cec8bcc8c0c933
Re: Assist for include files [message #31195 is a reply to message #31193] Sat, 12 February 2011 19:56 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Raxvan

It is a nice feature Smile.

It works fine for me in Windows XP, although it has got an exception and it does not let me enter a Bazaar folder.


Best regards
Iñaki
Re: Assist for include files [message #31196 is a reply to message #31016] Sat, 12 February 2011 20:31 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
Hello,

I have changed the source code and i hope this is the final version.I found that if i compile for speed the system doesn't work at all in linux. Also i have to test this version for windows to check that everything is working before i will post a new release.

koldo:
The path to the Bazaar must be specified in your current assembly.
Anyway, the code has changed again, so i hope that this version has everything working Smile


Raxvan.


92b48bf94855483bb4cec8bcc8c0c933
Re: Assist for include files [message #31199 is a reply to message #31016] Sun, 13 February 2011 00:14 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
Hello,

I have attached a patch for the latest IDE revision. The source code is almost complete and i tested this in linux and windows. It works fine with one exception: When compiling the ide for speed in linux the assist will not start.


Thanks,
Raxvan.
  • Attachment: ide.patch
    (Size: 32.99KB, Downloaded 230 times)


92b48bf94855483bb4cec8bcc8c0c933
Re: Assist for include files [message #31202 is a reply to message #31199] Sun, 13 February 2011 20:35 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
raxvan wrote on Sun, 13 February 2011 00:14

Hello,

I have attached a patch for the latest IDE revision. The source code is almost complete and i tested this in linux and windows. It works fine with one exception: When compiling the ide for speed in linux the assist will not start.


Thanks,
Raxvan.

Is it updated http://dl.dropbox.com/u/9887398/ide.rar ?


Best regards
Iñaki
Re: Assist for include files [message #31204 is a reply to message #31202] Mon, 14 February 2011 08:06 Go to previous messageGo to next message
raxvan is currently offline  raxvan
Messages: 60
Registered: December 2009
Member
koldo wrote on Sun, 13 February 2011 20:35

raxvan wrote on Sun, 13 February 2011 00:14

Hello,

I have attached a patch for the latest IDE revision. The source code is almost complete and i tested this in linux and windows. It works fine with one exception: When compiling the ide for speed in linux the assist will not start.


Thanks,
Raxvan.

Is it updated http://dl.dropbox.com/u/9887398/ide.rar ?

Yes sir Smile , updated , i posted two patches on redmine with the final code.
Also here:
http://dl.dropbox.com/u/9887398/IDE_MT.patch
http://dl.dropbox.com/u/9887398/IDE_ST.patch

Raxvan.


92b48bf94855483bb4cec8bcc8c0c933
Re: Assist for include files [message #31206 is a reply to message #31204] Mon, 14 February 2011 11:12 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Raxvan

I have downloaded from here two hours ago:
- In Windows XP, MSC10 Speed it runs perfect. It is nice.
- In GNU/Linux/Ubuntu, GCC Speed I get an "Invalid Memory Access" exception when keying "Enter" after choosing the right .h file from the menu.


Best regards
Iñaki
Previous Topic: Possible issue in Controls4U::Meter
Next Topic: external GIT clones differ in HASH --> problem when merging
Goto Forum:
  


Current Time: Thu Apr 18 23:15:39 CEST 2024

Total time taken to generate the page: 0.03915 seconds