2.7 FileManager and PowerShell Plugin

CodeBlocks

[Contents] CodeBlocks Manual   [Search] Search

[Table of contents]

2.7 FileManager and PowerShell Plugin


The File Explorer Figure 2.8 is included in the FileManager plugin, and can be found in the ’Files’ tab. The composition of the File Explorer is shown in Figure 2.8.
On top you will find a field for entering the path. By clicking the button at the end of this field, the drop-down field will list a history of the past entries which can be navigated via a scroll bar. The up arrow key on the right-hand side of the field moves up the directory structure one directory.
In the ’Wildcard’ field you can enter a filter term for the file display. Leaving the field empty or entering * results in all files being displayed. Entering *.c;*.h, for example will result in solely C sources and header files being displayed. Opneing the pull-down field will, again, list a history of the last entries.

[Figure # 35]
Figure 2.8: The file manager

Pressing the Shift key and clicking selects a group of files or directories, pressing the Ctrl key and clicking selects multiple separate files or directories.
The following operations can be started via the context menu if one or multiple directories are selected in the File Explorer:
Make Root
defines the current directory as the root directory.
Add to Favorites
sets a marker for the directory and stores it as a favourite. This function allows you to navigate quickly between frequently used directories, also on different network drives.
New File
creates a new file in the selected directory.
New Directory
creates a new subdirectory in the selected directory.
The following operations can be started via the context menu if one or multiple files or directories are selected in the File Explorer:
Duplicate
copies a file/directory and renames it.
Copy To
opens a dialogue for entering the target directory in which the copied file/directory is to be stored.
Move To
moves the selection to the target location.
Delete
deletes the selected files/directories.
Show Hidden Files
activates/deactivates the display of hidden system files. When activated, this menu entry is checkmarked.
Refresh
update the display of the directory tree.
The following operations can be started via the context menu if one or multiple files are selected in the File Explorer:
Open in CB Editor
opens the selected file in the CodeBlocks editor.
Rename
renames the selected file.
Add to active project
adds the file(s) to the active project.
Note:
The files/directories selected in the File Explorer can be accessed in the PowerShell plugin via the mpaths variable.
User-defined functions can be specified via the menu command ’Settings’ /’Environment’ /’PowerShell’ . In the PowerShell mask, a new function which can be named at random, is created via the ’New’ button. In the ’ShellCommand Executable’ field, the executable program is stated, and in the field at the bottom of the window, additional parameters can be passed to the program. By clicking the function in the context menu or the PowerShell menu, the function is started and will then process the selected files/directories. The output is redirected to a separate shell window.
For example a menu entry in ’PowerShell’ /’SVN’ and in the context menu is created for ’SVN’. $file in this context means the file selected in the File Explorer, $mpath the selected files or directories (see section 3.2).
   Add;$interpreter add $mpaths;;;
This and every subsequent command will create a submenu, in this case called ’Extensions’ /’SVN’ /’Add’ . The context menu is extended accordingly. Clicking the command in the context menu will make the SVN command add process the selected files/directories.
TortoiseSVN is a widespread SVN program with integration in the explorer. The program TortoiseProc.exe of TortoiseSVN can be started in the command line and dispalys a dialogue to collect user input. So you can perform the commands, that are available as context menu in the explorer also in the command line. Therefore you can integrate it also a shell extension in CodeBlocks. For example the command
  TortoiseProc.exe /command:diff /path:$file
will diff a selected file in the CodeBlocks file explorer with the SVN base. See Figure 2.9 how to integrate this command.
Note:
For files that are under SVN control the file explorer shows overlay icons if they are actived via menu ’View’ /’SVN Decorators’ .

[Figure # 36]
Figure 2.9: Add a shell extension to the context menu

Example
You can use the file explorer to diff files or directories. Follow these steps:
  1. Add the name via menu ’Settings’ /’Environment’ /’PowerShell’ . This is shown as entry in the interpreter menu and the context menu.
  2. Select the absolute path of Diff executable (e.g. kdiff3). The program is accessed with the variable $interpreter.
  3. Add parameters of the interpreter
  Diff;$interpreter $mpaths;;;
This command will be executed using the selected files or directories as parameter. The selection is accessed via the variable $mpaths. This is an easy way to diff files or directories.
Note:
The plug-in supports the use of CodeBlocks variables within the shell extension.
$interpreter
Call this executable.
$fname
Name of the file without extension.
$fext
Extension of the selected file.
$file
Name of the file.
$relfile
Name of the file without path info.
$dir
Name of the selected directory.
$reldir
Name of directory without path info.
$path
Absolute path.
$relpath
Relative path of file or directory.
$mpaths
List of current selected files or directories.
$inputstr{<msg>}
String that is entered in a message window.
$parentdir
Parent directory (../).
Note:
The entries of shell extension are also available as context menu in the CodeBlocks editor.


[Previous] 2.6.10  Sort Search Results
[Next] 2.8  Browse Tracker

Created: 2010/25/05 11:52   Updated: 2010/25/05 11:52
Author: HighTec EDV-Systeme GmbH
Copyright © 2010 HighTec EDV-Systeme GmbH