Working With Code

Like most development environments, QuickSharp's work-flow is based on a three-step edit, compile and run cycle.

Editing

Developing any application starts with editing code. QuickSharp includes a capable, multi-file text editor with colour syntax highlighting, code folding, search/replace, text 'snippets' and Visual Studio-style docking windows.

To create a new file simply select New from the File menu, click the toolbar button or press Ctrl+N. A new window will appear with a basic C# program 'skeleton' inserted ready for editing. To create a different content type use the New From Template menu to select the new file from the file templates available.

Templates

All files created in the QuickSharp IDE are copied from templates. These are simply text files stored in the Templates folder of the QuickSharp local application data directory. The location of this will depend on the version of Windows; XP users will find it in:

C:\Documents and Settings\<username>\Local Settings\Application Data\QuickSharp

Vista and Windows 7 users in:

C:\Users\<username>\AppData\Local\QuickSharp

The files can be edited to suit individual preferences and extra files can be added to create additional templates. Folders may be used to organise these files; they will appear as sub-menus in the New From Template menu and can be nested to an arbitrary depth.

A special file '_default.cs' does not appear in the template menu but is used to provide the content created when New is selected from the File menu or toolbar. The type of file created can also be defined by changing the extension of the file; for example to create a VB.NET file rename it to '_default.vb' and update the contents to match.

Zip file templates

Template files are used to create new files in the editor. Zip file templates allow more complex resources to be created, either from multiple files or from files with names not suited to the 'untitled' naming convention used by simple templates.

Zip file templates usually contain groups of files or complete projects; the contents of the template are extracted directly to the workspace instead of being loaded into the editor. Sometimes the contents will require a name to be provided so that unique instances may be created; in other cases template files will have fixed names such as 'Web.config'.

Opening multiple instances of a file

Normally a file can only be loaded into one editing window; any attempt to load the file in another editor will cause the existing editing window to be shown. A file can be opened in a second window if the first is set to be read only; do this with the Edit menu Set Read Only option before opening the file a second time.

Snippets

Snippets are fragments of text which can be inserted into the current file on selection from the Snippets menu. Select Edit, then Snippets and a sub-menu option to insert the text. Snippets are text files stored in the 'Snippets' sub folder of the QuickSharp local application data directory. This can be easily located by selecting Manage Snippets from the Snippets menu. This will open a Windows Explorer view allowing the text files to be edited. New files can be added to create additional snippets and folders used to organise them; they will appear as sub menus and can be nested arbitrarily to create the required arrangement.

The name of each snippet file provides the title of the corresponding menu entry. By adding a simple prefix a short-cut key combination can be assigned to the snippet making it easier to insert into the editor. Short-cut keys can be any letter or number key accompanied by at least two of the three modifier keys 'C', 'A' and 'S' for Ctrl, Alt and Shift. To create a prefix use the chosen key combination followed by '#' at the start of the snippet file name. For example, the 'Using System' snippet provides the short-cut key combination Ctrl+Shift+U and has the file name 'CSU#Using System.txt'.

Compiling

Once source code has been created it can be compiled by pressing Shift-F5, selecting Compile from the Tools menu or clicking the corresponding toolbar button. The compiler will run and present its output in the output window. Compilation errors or warnings will also be presented here; double-click an error message to jump to the appropriate line in the editor.

QuickSharp supports multiple compiler configurations; these are presented in the drop-down menu next to the compile button on the toolbar. Select the configuration you wish to use from the list; all subsequent compilations will use the selected tool.

QuickSharp will automatically decide whether to compile a source file to an program or a library based on it content. If your code contains a valid Main method a program will be created, otherwise a library will result. If necessary this can be overridden with an embedded compiler option.

Running

Once the program has compiled successfully it can be run by pressing Ctrl+F5, or using the Run menu/toolbar commands. Again, the program output will appear in the output window.

In order to shorten this cycle, a program can be compiled and run in a single operation by just using run; if the source is more recent than its output file it will be automatically recompiled. All being well the program will run as requested, if compilation errors occur the run command will be cancelled.

Programs are normally run within QuickSharp and any output captured in the output window. If a program requires user input it should be run in its own window. This can be achieved using the 'RunInOwnWindow' embedded option. Embedded options can also be used to pass input to the program automatically.