Wedit

This section describes creating and using a project in Wedit. Note: currently it's not possible (as far as I can tell) to use a Wedit project to do the compiling automatically for you. There seem to be a couple of bugs in Wedit that prevent a DLL build from generating a workable makefile. Because of this we will still be using our manually created makefile to do the actual compiling, but that doesn't stop us from making use of the function search and other handy features that Wedit has to offer.

Creating a Project

First, if you haven't already done so, create a new patch directory, complete with source code, makefile etc, as described in the LCC Installation section.

Open Wedit, go to File -> Create Project. If it asks for your name, enter it. In the project name box fill in a name for your patch, for example Weapon patch. In the path box browse to your patch directory. For type of project choose Dynamic Link Library. Now click on create.

You are presented with a dialogue box asking for the files that will comprise your project. We want to add all the source files, with .c extension, and the game.def file. To do this, make sure the list files of type drop down box is set to C sources, and that all the .c files are listed on the left. Click add all. Now change list files of type to all files, click on game.def in the top left box, then click on add. Once you've done all this, click validate. Say yes to opening the files. You will be asked if you want to view the makefile, choose no, as we will not be using the automatically generated makefile.

All the source files should now be loaded and displayed. If you quit Wedit now, you'll find next time you reload it, it will automatically load the most recently used project. It is possible to have more than one project in progress, by simply creating another one, however you can only have one project open at a given time. You'll find that if you maximise the document (internal) window, the files will open MUCH faster when you reload Wedit.

The basic editing features of Wedit, (such as cut/copy/paste, opening/closing files, scrolling, editing etc) are much the same as any other text editor. The current function the cursor is inside is displayed on the top right of the status bar.

The Project Window

If you use the window menu to try and switch files, you'll probably find it can't hold enough entries for all the source files, however all is not lost. Select project from the window menu. This will open a new window which will contain a list of all the project files. (You might need to shrink the size of the window to get the whole thing on screen) Not only does it list all the source files, but if you expand the branches (+ signs) before each filename, you'll notice it also lists all the functions in a particular file. Right clicking on one of the files listed and selecting activate will switch immediately to that file.

If you right click on a particular function in the project window and select usage a window will open showing all occurrences where this function is called from. The main scrollbox lists the command line for each instance. If you click on a particular one, files tells you what source file the function call is being made from, and functions tells you from what function within that file the call was made from. This is extremely useful to see what uses a particular function before you modify it.

Function Search

This is probably the most useful feature of Wedit, and there are two variants of it. The first is called function search, and is under the search menu. Selecting this will give you a window which lists ALL functions in the entire project alphabetically. If you know the name of a function but you don't know where it is, this is the way to find it. Clicking on a function name in the defined functions dialogue highlights the source filename that contains the function in the loaded files dialogue, and displays a prototype definition for that function in the prototype dialogue.

Double clicking on the function name will take you immediately to that function, so this is the quickest way to get to an arbitrary function in your project.

Also under the search menu is functions list. This just shows all the functions in the currently selected file, rather than the entire project. You can also activate it with F12, which makes this the quickest way to jump from function to function within the same file.

Structure Search

This will automatically find and display all the structure definitions that are referenced directly in the current source file. To active it, choose structures list from the search menu. A shortcut is CTRL + F12. A dialogue box is displayed with two options - Follow #include "...." and Follow #include <.......>. For our purposes we only want the top one ticked, which tells it to search only header files that are part of our project, (eg in the current directory) and not headers in the LCC include path, which would include things such as stdio.h. Click OK.

The left hand structures dialogue now lists all the structures referenced from the current source file. Clicking on a structure name will display it in the definitions window on the right. Just above that it also lists what line numbers in what header file this definition resides in. The definitions file button will display all the structure definitions listed at once, in a pseudo file called _struct_.c. Each structure is separated by a comment which describes what lines of what file the structure definition actually belongs to. WARNING: do not try to edit or save the current file, it is not the real definitions, so you'll be wasting your time.

Despite its name, the small window button will bring up a larger window to display the same thing. This time however, we have a menu with two useful options, goto and print. Goto will load the correct header file and take you to the right part of the file, from here you can edit the structure directly, and save changes. Print does just that, it prints that structure definition.

Context Menu

Right clicking on text in the edit window brings up a number of interesting features, some of which change depending on what you're clicking on. Here are some of the more useful ones. Right clicking on a function name gives you two options, the definition of the function, and the usage of a function. The definition takes you immediately to specified function, while usage brings up a list of all the places that function is called from. Right clicking on a variable name lets you display a definition and usage of that variable. Another option that exists on the context menu no matter where you click is locals in current function, which displays all local variables in the current function.

Grep

Some of you may have heard of grep, it is generally a utility that lets you search for a particular string in multiple files. Wedit has a built in grep function on the search menu. In the search dialogue, type the string you're searching for in the expression to search for box. File mask controls what files will be searched. By default it is *.c *.h which will search source and header files. When you perform the search, a results window will appear listing all the occurrences found. Double clicking on any entry will switch you immediately to that file and position.

Viewing changes since saving

It's possible to view changes that you have made to a particular file before saving it, in the edit menu, select show changes. The changes are displayed in the form of a diff, where the top window is things you've added, and the bottom window is things you've removed.

Compiling your patch

The observant among you will have noticed the compiler menu. At the moment, you shouldn't be trying to use this to compile, because Wedit tries to use the project to build a makefile. The makefile it generates does not work correctly for DLL's, so you'll have no luck using the compiler menu. Instead, run make from the command prompt as described in the LCC Installation section.

Other features

There are many other features that Wedit offers that I haven't fully explored yet, as I figure them out, I'll add them to this page. Feel free to try them, although I suggest you experiment with a backup project, rather than the real thing in case you get undesirable results :-)