KDevelop4/Manual/Working with source code: Difference between revisions

From KDE UserBase Wiki
Line 31: Line 31:
* '''File system''': Shows you a tree view of the file system.
* '''File system''': Shows you a tree view of the file system.
* '''Documentation''': Allows you to search for man pages and other help documents.
* '''Documentation''': Allows you to search for man pages and other help documents.
* '''Snippets''': This provides sequences of text that one uses over an over and doesn't want to write every time. For example, in the project from which the picture above was create, there is a frequent need to write code like <code>for (typename Triangulation&lt;dim&gt;::active_cell_iterator cell = triangulation.begin_active(); cell != triangulation.end(); ++cell)</code>. This is an awkward expression but it will look almost exactly like this everytime you need such a loop &mdash; which would make it a good candidate for a snippet.
* '''Snippets''': This provides sequences of text that one uses over an over and doesn't want to write every time. For example, in the project from which the picture above was created, there is a frequent need to write code like <code>for (typename Triangulation&lt;dim&gt;::active_cell_iterator cell = triangulation.begin_active(); cell != triangulation.end(); ++cell)</code>. This is an awkward expression but it will look almost exactly like this everytime you need such a loop &mdash; which would make it a good candidate for a snippet.
* '''Konsole''': Opens a command line window inside KDevelop's main window, for the occasional command you may want to enter (e.g. to run <code>./configure</code>).
* '''Konsole''': Opens a command line window inside KDevelop's main window, for the occasional command you may want to enter (e.g. to run <code>./configure</code>).


For many programmers, vertical screen space is the most important. To this end, you can arrange your
For many programmers, vertical screen space is the most important. To this end, you can arrange your
tool views at the left and right margin of the window: to move a tool, click on its symbol with the right mouse button and select a new position for it.
tool views at the left and right margin of the window: to move a tool, click on its symbol with the right mouse button and select a new position for it.

Revision as of 14:15, 17 May 2011

Working with source code

Besides debugging, reading through and writing source code is what you will spend the most time with when developing software. To this end, KDevelop offers you many many different ways to explore source codes and to make writing it more productive. As discussed in more detail in the following sections, KDevelop is not just a source editor — rather, it is a source management system that gives you different views of extracted information on the files that collectively make up your session's source code.

Terminology: Tools and Views

In order to work with projects, KDevelop has the concept of tools. A tool provides a particular view of the source, or an action that can be taken with it. Tools are represented by buttons around the perimeter of your window (in vertical text along the left and right margins, or horizontally along the bottom margin). If you click on them, they expand to a subwindow — a view — within the main window; if you click on the tool button again, the subwindow disappears again.

Note

To make a subwindow disappear, you can also click at the "x" at the top right of the subwindow; however, at least with KDevelop 4.2.x, this also removes the button representing the tool from the perimeter, which was your way of getting the subwindow back. See below for how to get the button back onto the perimeter in the same way as getting any tool's button there. This behavior has been reported as bug 270018)

The picture above shows a particular selection of tools, aligned on the left and right margins; in the picture, the "Classes" tool is open on the left and the "Snippets" tool on the right, along with an editor for a source file in the middle. In practice, most of the time you will probably only have the editor and maybe the "Classes" or "Code Browser" tool open at the left. Other tool view will likely only be open temporarily as you use the tool, leaving more space for the editor most of the time.

When you run KDevelop the first time, you should already have the "Projects" tool button. Click on it: it will open a subwindow that shows the projects you have added to the session at the bottom, and a file system view of the directories of your projects at the top.

There are many other tools you can use with KDevelop, not all of which are initially present as buttons on the perimeter. To add some, go to the Windows > Add tool view menu entry. Here are some that you will likely find useful (a complete discussion of all tools can be found elsewhere in this manual):

  • Classes: A complete list of all classes that are defined in one of the projects or your session with all of their member functions and variables. Clicking on any of the members opens a source editor window at the location of the item you clicked on.
  • Documents: Lists some of the more recently visited files, by kind (e.g. source files, patch files, plain text documents).
  • Code Browser: Depending on your cursor position in a file, this tool shows things that are related. For example, if you are on an #include line, it shows information about the file you are including such as what classes are declared in that file; if you are on an empty line at file scope, it shows the classes and functions declared and defined in the current file (all as links: clicking on them brings you to the point in the file where the declaration or definition actually is); if you are in a function definition, it shows where the declaration is and offers a list of places where the function is used.
  • File system: Shows you a tree view of the file system.
  • Documentation: Allows you to search for man pages and other help documents.
  • Snippets: This provides sequences of text that one uses over an over and doesn't want to write every time. For example, in the project from which the picture above was created, there is a frequent need to write code like for (typename Triangulation<dim>::active_cell_iterator cell = triangulation.begin_active(); cell != triangulation.end(); ++cell). This is an awkward expression but it will look almost exactly like this everytime you need such a loop — which would make it a good candidate for a snippet.
  • Konsole: Opens a command line window inside KDevelop's main window, for the occasional command you may want to enter (e.g. to run ./configure).

For many programmers, vertical screen space is the most important. To this end, you can arrange your tool views at the left and right margin of the window: to move a tool, click on its symbol with the right mouse button and select a new position for it.