In Python Wing IDE, how to navigate to file from keyboard? - wing-ide

What is the equivalent of PyCharms "double-shift" shortcut to jump to a file by name? It's a pain to scroll through a list in the Project explorer. I'd rather just type the name and get an autocompletion list

Use Open from Project in the File menu (or more likely its keyboard equivalent, which depends on keyboard personality but is listed in the menu). If you want you can bind your own key to the command open-from-project.
Related to this are Find Symbol and Find Symbol in Project in the Source menu, which find symbols in your code whose names match the fragment you type.

Related

Keil Uvision 5 adding header files and source files?

I started with an example project in keil from Nordic SDK. This question is not about the nordic sdk, but rather how Keil connects header files and source files. After what I can understand Keil hides all header files merged into the main.c file, see figure below.
I want to add my own header file called "physical.h" where I define additional hardware that I added.
Sometimes I want to add a header file and source files "*.c" files.
What can I specifically do to add a new file, and compile this new file with my main.c file? A walkthrough would be appreciated.
I believe Keil is not intuitive in the folder structure sense. However, it is probably good for a modular design as it can easily include files from many places on your computer (git, library etc...).
Let's start with problem one (adding a header file):
The header files in the main.c file is an image of whats already included and "working". Add a new file by right clicking the parent folder of main.c and click "Add new item to group ". From within the menu, choose C-file/H-file or any other appropriate file.
If there is no group yet, just add a group from the parent folder.
Right click and press "add group ...".
Now, what might confuse you is that the .h file will not appear in the folder you just created it. The .c files will appear, but not .h! You will find your file at the open in a new window. Right click that tab with the filename you just created, and click "copy full path".
Here comes the tricky part.
Go to the project tab in Keil menu, and click "options for target " or ALT+F7.
Go to the tab "C/C++" tab. In the "Include Paths" slot, the will be a button indicating "...", click it.
In the top right corner, holding over the first icon will show "New (insert)", click it. Click the new button "..." in the slot you just created, this will open a folder menu. This is where you find your file and add the parent folder of that file. However, you may need to move the file you created in order to find a good structure.
The structure inside Keil Uvision 5 is just virtual folders, and creating a file will just put it in the project folder with no structure. Finding a good solution now, is up to you, comment if you come up with one.
The last part I would like to add is what happens when you just included this file. Well, go into your main.c file, include the header file, as in normal C convention. #include "myfile.h". If you try to compile, it should show no error, and your main.c file will have a sub-file of that same .h file you just included.
Second problem:
For C-files you can just add them, the same way as earlier, however, Keil will dump them all at the source of your project, having no structure at all. For structure, you must do that outside of Keil unfortunately.

How to find the callers and callee of a function in C code in vi/vim?

I want to know how can I easily click (or maybe use some easy shortcuts) on a function name and find all its callee or open where it has been defined. Most of the web manuals in web are really hard to follow or don't happen to work out. Say I want to click on allocuvm and see where it has been defined?
uint newstk=allocuvm(pgdir, USERTOP-PGSIZE, USERTOP);
cscope minimal example
Ingo mentioned it, here is an example.
First you should set on your .vimrc:
set cscopequickfix=s-,c-,d-,i-,t-,e-
Then to the base directory of your project and run:
cscope -Rb
This generates a cscope.out file which contains the parsed information. Generation is reasonably fast, even for huge projects like the Linux kernel.
Open vim and run:
:cs add cscope.out
:cs find c my_func
c is a mnemonic for callers. The other cscope provided queries are also possible, mnemonics are listed under:
help cscope
This adds a list of the callers to the quickfix list, which you can open with:
:copen
Go to the line that interests you and hit enter to jump there.
To find callers of the function name currently under the cursor, add to your .vimrc:
function! Csc()
cscope find c <cword>
copen
endfunction
command! Csc call Csc()
and enter :Csc<enter> when the cursor is on top of the function.
TODO:
do it for the current function under cursor with a single command. Related: Show function name in status line
automatically add the nearest database (parent directories) when you enter a file: how to auto load cscope.out in vim
interactively open the call graph like Eclipse. Related: Generate Call-Tree from cscope database
A word of advice: I love vim, but it is too complicated for me to setup this kind of thing. And it does not take into account classes e.g. in C++. If a project matters enough to you, try to get the project working on some "IDE". It may involve some overhead if the project does not track the IDE configuration files (which are auto-changing blobs that pollute the repo...), but it is worth it to me. For C / C++, my favorite so far was KDevelop 4.
For that, Vim integrates with the cscope tool; see :help cscope for more information.
vi / . --- / is the search function in vi, and . will repeat the same command.
you could also use sed ( stream editor ) if it is a large file
sed
grep can get you the line numbers
read the man page

emacs open includes in code files, multiple directories

ECB, cscope, xcscope. All working. Is cedet necessary?
MSVS, eclipse, code::blocks, xcode. All of them allow easy click on an included source file and take you to it.
Now, with the above setup, emacs does too.
Except emacs doesn't take you to the std:: libraries, doesn't assume their location in /src/linux or some such. Emacs is a little blind and needs you to manually set it up.
But I can't find anything that explains how to set up ff-find-other-file to search for any other directories, let alone standard major libraries, outside of a project's directory.
So, how do I do it?
Edit; Most important is to be able to request on either a file name (.h, .c, .cpp, .anything) or a library (iostream) and open the file in which the code resides.
Additional directories for ff-find-other-file to look into are in ff-search-directories variable which by default uses the value of cc-search-directories, so you should be able to customize any of the two to specify additional search paths.
As for the second question about requesting a file name and finding corresponding file, something like that will do:
(defun ff-query-find-file (file-name)
(interactive "sFilename: ")
;; dirs expansion is borrowed from `ff-find-the-other-file` function
(setq dirs
(if (symbolp ff-search-directories)
(ff-list-replace-env-vars (symbol-value ff-search-directories))
(ff-list-replace-env-vars ff-search-directories)))
(ff-get-file dirs file-name))
Call it with M-x ff-query-find-file or bind it to a key to your liking.

How to set include path in xcode project

I am trying to use a C library in an Objective-C Xcode project.
The libraries directory structure is as follows:
-- include/
|-- config.h
|-- lib/
| |-- file1.h
| |-- file2.h
| |-- file3.h
The library's docs say to include file1.h, and file1.h includes file2.h and file3.h.
I am getting "file not found" errors for the includes of file2.h and file3.h`.
They are included by file1.h in the following manner:
#include <lib/file1.h>
#include <lib/file2.h>
I read here that these angle-brackets instruct the preprocessor to search for include files along the path specified by the INCLUDE environment variable, as opposed to searching in the same directory as the file that contains the #include.
So I added the INCLUDE environment variable in Xcode by going to Product->Edit Scheme.. and set it to /the-whole-path-to/include/ however, I am still getting the file not found errors.
The files are successfully included if I change file1.h to include them like this:
#include "file2.h"
but I'd rather not do that for every file in the library.
How can I fix this?
In version 5.0.2 of XCode, the best way to accomplish this is probably to add it to the target's "Search Paths" pane. Locating this was (for me) incredibly unintuitive. Here's how I got to it, for those as confused as I:
In the left column, click on the Project Navigator icon (looks like a folder). Then, click on the project entry. This should show a bunch of settings in the main pane. At the top of this pane, click on "Build Settings. This shows a bunch of entries... including one called Search Paths... but you can't add a search path here! This made me gnash my teeth for quite a while, until I figured out that the name of the project at the top of this pane was a pull-down; choose the target from this pull-down, and you should now be able to double click on "Header Search Paths" and perform the needed edit.
Oh, the joy of crazy GUIs.
Figured it out.
All you have to do is add the -I flag to your build setting under "Other C Flags"
So in your target's build setting search for "Other C Flags" and add -I/path-to-include/
Here's a screenshot:
Try this:
1 - select your project file in the left Xcode pane
2 - make sure your project is selected in the middle Xcode pane
3 - select "Build Settings" at the top of the middle Xcode pane
4 - be sure "All" & "Combined" are selected just beneath "Build Settings"
5 - type header in the search field just below "Build Settings"
You should see the search path fields ready for editing in the middle pane.
I solved this in Xcode 5.0.1 using the project Build Settings (as John and Ian noted above, but I cannot comment due to <50 rep).
New info:
When adding includes to User Header Search Paths, I also had to change Always Search User Paths to Yes.
When adding includes to (non-User) Header Search Paths, Always Search User Paths is not required.
Although this works, it is probably better to put it under the "Search Paths" tab instead.
Either you can use "Other C Flags" or use "HEADER_SEARCH_PATHS", to specify the include paths, to look for header for your executable.
In 2021, Xcode v. 12.4, the solution seems to be:
Project->Targets->General->"Scan All Source Files For Includes"-> set to "Yes"
This worked for me.
However, this might backfire if you have multiple versions of a specific .h file, probably not a good practice but it's possible if you have lots of sub-directories with their own mini-projects and similarly named include files.

Adding Linker Flags in Xcode

(I'm not sure if "flag" is the word I'm looking for, but I'll explain it.)
I am trying to compile a program that uses the GMP big number library. But to be able to compile with GMP, I have to add -lgmp to the end of the command. For example, if I want to compile "program.c", I have to type gcc program.c -lgmp. This is easy from the command line, but I don't see how to do it in Xcode. How can I add the lgmp flag while using Xcode?
Right-click the target in the Xcode Groups and Files list and select Get Info from the contextual menu. In the Build tab, type linker into the search field and then locate the Other Linker Flags item.
Double-click the Other Linker Flags item and add -lgmp.
Maybe this helps:
You can also open the active target's preferences, and click the "General" tab. You can add the library to be linked inside that tab, in the "Linked Libraries" section at the botton.
Taken from http://www.soulstorm-creations.com/PROJECT_SOULSTORM_2_0/programming-articles/installing-portable-libraries-on-os-x.html
You can just open the folder containing libgmp.a on your system (/usr/local/lib/ for a default install), and drag the library out of the folder onto the target that you want it to get linked into. There are several other ways as well, such as the one suggested by Zitrax.

Resources