UltraEdit
A text editor. Some tips on using UltraEdit for editing UnrealScript.
UltraEdit is a richly featured Programmers Editor that you can customise a great deal. As usual it is assumed that anyone reading this wants to cut to the chase and get up and running as fast as possible. The built in Help is very good so if my explanations fall short, look for the topic in the help file in UltraEdit.
The features I have found most useful so far are:
- CTAGS support - I use it to navigate up the class tree with a sinble keypress - very very useful...
- Syntax Highlighting - Works just like most Integrated Development Environments (IDE) except you can configure it a great deal...
- Syntax Completion - Again, just like many IDE's only highly configurable...
- Hex Editor - Not so important in UnrealScript but darn nice to have built in...
- Function List - Similar to feature in many IDE's in which you can quickly navigate to a function definition by double clicking a sidebar...
- Defining Project Tool - Allows you to define external application to call and assign to a toolbar button in UltraEdit...
Here are some tips I would have found useful when starting out with UltraEdit. These are for UltraEdit 9.x which is the one I registered. Some features are not present on previous versions. Visit http://www.ultraedit.com to obtain the software and register it once you are convinced.
Syntax Highlighting
Syntax highlighting is the ability to recognize predefined words and display them in a different color(s). This is particularly useful for programmers, and can also be useful to other users who may want certain words in a document to show up in a different color. – from UltraEdit Help
Customising for UnrealScript
- Open the file WORDFILE.TXT which is a standard UltraEdit file in your program directory.
- Go to the end of the file. By default, the last section in this file will start something like:
/L8"PHP" Nocase HTML_LANG Line Comment = // Block Comment On = /* Block Comment Off = */ Escape Char = \ String Chars = "' File Extensions = PHP PHTML INC PHP3 PHP4
- Now insert the following to your file taking care to replace the number after the /L tag in each block definition with next number in your particular installation. At the time of writing, the numbering below will not conflict with defaults:
/L9"UC" Line Comment = // Block Comment On = /* Block Comment Off = */ Escape Char = \ String Chars = "' Nocase File Extensions = UC INT /Delimiters = ~!@%^&*()-+=|\/{}[]:;"'<> , .? /Function String 1 = "%[ ^t]++^(simulated[ ^t]++[a-zA-Z_0-9]*$^)" /Function String 2 = "%[ ^t]++^(state[ ^t]++[a-zA-Z_0-9]*$^)" /Function String 3 = "%[ ^t]++^(class[ ^t]++[a-zA-Z_0-9]*$^)" /Function String 4 = "%[ ^t]++^(function[ ^t]++[a-zA-Z_0-9]*$^)" /Function String 5 = "%[ ^t]++^(event[ ^t]++[a-zA-Z_0-9]*$^)" /Indent Strings = "{" /Unindent Strings = "}" /C1"UnrealScript Keywords" abstract actor auto begin bool break byte case char class coerce config const continue default defaultproperties do dot double down else enum event exec extends expands false final float for foreach function globalconfig guid if ignores import int iterator latent local localized lodmesh log login loop mesh name native nativereplication new noexport none null operator optional out plane preoperator private protected public reliable replication return rot rotator repeater self simulated singular sound spawn state static string struct super switch texture transient true unreliable var vect vector while #exec ' /C2"Operators" + - = // / % & > < ^ ! | ` /C3"Common UT Classes" BotReplicationInfo CTFReplicationInfo GameReplicationInfo Pawn PlayerPawn PlayerReplicationInfo /L10"UHTM" Nocase Noquote HTML_LANG Block Comment On = <!-- Block Comment Off = --> Block Comment On Alt = <% Block Comment Off Alt = %> String Chars = "' File Extensions = UHTM /Delimiters = ~!@$%^&*()+=|\{}[]:;"'<> , .? /Function String = "name=*">" /C1"Tags" <A </A> <ABBR> <ABBR </ABBR> <ABOVE> <ACRONYM> <ACRONYM </ACRONYM> <ADDRESS> <ADDRESS </ADDRESS> <APPLET </APPLET> <ARRAY> <AREA </AREA <B> <B </B> <BASE <BASEFONT <BDO> <BDO </BDO> <BGSOUND <BIG> <BIG </BIG> <BLINK> </BLINK> <BLOCKQUOTE> <BLOCKQUOTE </BLOCKQUOTE> <BODY <BODY> </BODY> <BOX> <BR <BR> <BIG <BLINK <BUTTON> </BUTTON> <CAPTION> <CAPTION </CAPTION> <CENTER> <CENTER </CENTER> <CITE> <CITE </CITE> <CODE> <CODE </CODE> <COL> <COL <COLGROUP <COLGROUP> </COLGROUP> <COMMENT> </COMMENT> <DD> <DD </DD> <DEL> <DEL </DEL> <DFN> <DFN </DFN> <DIR> <DIR </DIR> <DIV> <DIV </DIV> <DL> <DL </DL> <DT> <DT </DT> <EM> <EM </EM> <EMBED <FIELDSET> <FIELDSET </FIELDSET> <FIG> <FONT </FONT> <FORM> <FORM </FORM> <FRAME <FRAMESET </FRAMESET> <H1> <H1 </H1> <H2> <H2 </H2> <H3> <H3 </H3> <H4> <H4 </H4> <H5> <H5 </H5> <H6> <H6 </H6> <HEAD> <HEAD </HEAD> <HR> <HR <HTML> <HTML </HTML> <I> <I </I> <IFRAME> </IFRAME> <ILAYER> </ILAYER> <IMG <INPUT> <INPUT <INS> <INS </INS> <ISINDEX> <ISINDEX <KBD> <KBD </KBD> <LABEL> <LABEL </LABEL> <LAYER> <LAYER </LAYER> <LEGEND> <LEGEND </LEGEND> <LI> <LI </LI> <LINK <LISTING> </LISTING> <MAP </MAP> <MARQUEE </MARQUEE> <MENU> <MENU </MENU> <META <MULTICOL> </MULTICOL> <NEXTID <NOBR> </NOBR> <NOFRAMES> </NOFRAMES> <NOLAYER> </NOLAYER> <NOTE> </NOTE> <NOSCRIPT> </NOSCRIPT> <OBJECT> <OBJECT </OBJECT> <OL> <OL </OL> <OPTION> <OPTION </OPTION> <OPTGROUP> <OPTGROUP </OPTGROUP> <P <P> </P> <PARAM <PRE> <PRE </PRE> <Q> <Q </Q> <QUOTE> <RANGE> <ROOT> <S> <S </S> <SAMP> <SAMP </SAMP> <SCRIPT <SCRIPT> </SCRIPT> <SELECT <SELECT> </SELECT> <SMALL> <SMALL </SMALL> <SOUND <SPACER> <SPAN> <SPAN </SPAN> <SQRT> <STRIKE> <STRIKE </STRIKE> <STRONG> <STRONG </STRONG> <STYLE> <STYLE </STYLE> <SUB> <SUB </SUB> <SUP> <SUP </SUP> <TABLE> <TABLE </TABLE> <TBODY> <TBODY </TBODY> <TD <TD> </TD> <TEXT> <TEXTAREA <TEXTAREA> </TEXTAREA> <TFOOT> <TFOOT </TFOOT> <TH <TH> </TH> <THEAD> <THEAD </THEAD> <TITLE> </TITLE> <TR <TR> </TR> <TT> </TT> <TT <U> <U </U> <UL> <UL </UL> <VAR> </VAR> <VAR <WBR> <XMP> </XMP> /C2"Attributes" ABBR= ACCEPT-CHARSET= ACCEPT= ACCESSKEY= ACTION= ALIGN= ALINK= ALT= ARCHIVE= AXIS= BACKGROUND= BEHAVIOR BELOW BGCOLOR= BORDER= CELLPADDING= CELLSPACING= CHAR= CHAROFF= CHARSET= CHECKED CITE= CLASS= CLASSID= CLEAR= CODE= CODEBASE= CODETYPE= COLOR= COLS= COLSPAN= COMPACT CONTENT= COORDS= DATA= DATETIME= DECLARE DEFER DIR= DISABLED ENCTYPE= FACE= FOR= FRAME= FRAMEBORDER= FRAMESPACING= HEADERS= HEIGHT= HIDDEN= HREF= HREFLANG= HSPACE= HTTP-EQUIV= ID= ISMAP= LABEL= LANG= LANGUAGE= LINK= LOOP= LONGDESC= MAILTO= MARGINHEIGHT= MARGINWIDTH= MAXLENGTH= MEDIA= METHOD= MULTIPLE NAME= NOHREF NORESIZE NOSHADE OBJECT= ONBLUR= ONCHANGE= ONFOCUS= ONKEYDOWN= ONKEYPRESS= ONKEYUP= ONLOAD= ONRESET= ONSELECT= ONSUBMIT= ONUNLOAD= ONCLICK= ONDBLCLICK= ONMOUSEDOWN= ONMOUSEMOVE= ONMOUSEOUT= ONMOUSEOVER= ONMOUSEUP= PROFILE= PROMPT= READONLY REL= REV= ROWS= ROWSPAN= RULES= SCHEME= SCOPE= SCROLLING= SELECTED SHAPE= SIZE= SPAN= SRC= STANDBY= START= STYLE= SUMMARY= TABINDEX= TARGET= TEXT= TITLE= TOPMARGIN= TYPE= URL= USEMAP= VALIGN= VALUE= VALUETYPE= VERSION= VLINK= VSPACE= WIDTH= = /L11"INI" Line Comment = ; String Chars = [=] Nocase File Extensions = INI /Delimiters = ~!@%^&*()-+=|\/{}[]:;"'<> , .? /Function String 1 = "%^(^[*^]^)" /C0 = /C2 [ ]
- Save the file.
- Open a big .uc file to test with.
- From the main menu, Select View | View As and choose UC form the list. (If UC is not visible something in the previous steps failed.)
- Now your Unreal Script file will be syntax-highlighted reasonably well
The additions above also add syntax highlighting for INI files and for UHTM files which are Unreal Tournament's "Dynamic HTML" files used for the Web Admin features.
Setting up File Types in UltraEdit
This allows you to add additional file types to the list of file types in all of UltraEdit's File operations (like Open, Save and so on)
- From the main menu, select Advanced | Configuration | File Types
- In the File Names text box, type
*.uhtm;*.uc
- In the File Description text box, type
Unreal Script Files
- Click Insert to add the defnition
Setting up File Associations in UltraEdit
To set up file association so that double clicking on a .uc file will open UltraEdit:
- From the main menu, select Advanced | Configuration | File Associations
- In the File Typetext box, type
uc
- In the File Description text box, type
Unreal Script File
- Click Add to add the defnition
Syntax Completion
This is a neat feature considering it is totally customiseable.
Customising for UnrealScript
If you have implemented the syntax highlighting as above then you have this already.
- When typing, press CTRL-SPACE together and UltraEdit will attempt to auto-complete your word by referring to:
- Your Syntax Highlighting word list
- Your customised Auto-Completion file
- up to 50 kilobytes before your current position in the current file
This feature is awesome and saves alot of needless typing for those two finger programmers like me...
Function Listing
This command shows the list of functions in the active document. The results are displayed in dockable window either in alphabetical order, or in order they occur in the document. By double clicking on one of the result lines UltraEdit will position to that line in the file and the focus will change to the file. If Enter is pressed while focus is in the Function List UltraEdit will position to that line and focus will remain in the function list. Ctrl+Enter will also position to the line in the file and the focus will change to the file. – from UltraEdit Help
Customising for UnrealScript
Follow the steps above for syntax highlighting because the function highlighting is contained in the WORDFILE.TXT file. Form the above example, the function definition lines for UnrealScript files are:
/Function String 1 = "%[ ^t]++^(simulated[ ^t]++[a-zA-Z_0-9]*$^)" /Function String 2 = "%[ ^t]++^(state[ ^t]++[a-zA-Z_0-9]*$^)" /Function String 3 = "%[ ^t]++^(class[ ^t]++[a-zA-Z_0-9]*$^)" /Function String 4 = "%[ ^t]++^(function[ ^t]++[a-zA-Z_0-9]*$^)" /Function String 5 = "%[ ^t]++^(event[ ^t]++[a-zA-Z_0-9]*$^)"
Unfortunately you are limited to six lines in the current release but forunately, the definitions I have created seem to pick up everything that's useful. The only thing I'd like to see here that is not likely to be added is "nested listing" but most .uc files are small enough to not need this.
Note: The function definitions are written in UltraEdit's internal Regular Expression language.
CTAGS / Find Symbol
UltraEdit supports Ctags, either as part of a project, or independantly. – from UltraEdit Help
What is Ctags?
Ctags generates a tag file (or index) file of C/C++ objects and functions found in C/C++ header and source files that allows these items to be referenced quickly within UltraEdit. – from UltraEdit Help
Finding a Symbol/Tag
The whole purpose of Ctags is to be able to quickly find a function or object that is defined elsewhere in the file or another file. Assuming the tag file exists, selecting "Find Symbol" from the Search menu will search the tag file for the symbol and if only one match is found the file will be opened in UltraEdit and the file positioned to the symbol. If multiple matches occur, a dialog box will be shown giving the user the option to position to the appropriate tag. – from UltraEdit Help
Obtaining CTAGS.EXE
CTAGS have been around for alot longer than UltraEdit and is not part of UltraEdit. UltraEdit takes advantage of "Exuberant Ctags" available from http://ctags.sourceforge.net/.
To use the Find Symbol functionality you need a ctags file to be generated for your uc files. The best way is to download ctags.exe from the site listed and use the syntax hints below.
Customising for UnrealScript
I have found it incredibly useful to have my ctags file contain everything from all of the .uc files in my directory. I have previously used the ucc batchexport command to export all so I have a directory structure like this:
D:\Games |→ UnrealTournament |→ BotPack |→ Classes |→ Core |→ Classes |→ MyClass |→ Classes
For such a directory structure:
- Place ctags.exe in your UltraEdit program directory
- Create a file in the UltraEdit program directory called ctags.cnf and place the following into the file:
--langdef=INI --langmap=INI:.ini --regex-INI=/^[ \t]*\[(.*)\]/\1/b,block/ --regex-INI=/^[ \t]*([^\[=]+)=(.*)/\1/k,key/ --langdef=unrealscript --langmap=unrealscript:.uc --regex-unrealscript=/^[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/c,class/ --regex-unrealscript=/^[ \t]*[^ \t]*[ \t]*state[ \t]*[^ \t]*[ \t]+([a-zA-Z0-9_]+)(\(|\n)/\1/s,state/ --regex-unrealscript=/^[ \t]*simulated[ \t]*(.*)[ \t]+([a-zA-Z0-9_]+)(\(|\n)/\2/i,simulated/ --regex-unrealscript=/^[ \t]*event[ \t]*[^ \t]*[ \t]+([a-zA-Z0-9_]+)(\(|\n)/\1/e,event/ --regex-unrealscript=/^[ \t]*function[ \t]*(.*)[ \t]+([a-zA-Z0-9_]+)(\(|\n)/\2/f,function/ --recurse
This is a configuration file for ctags.exe to use and describes the language mappings I have defined for UnrealScript and INI files. The recurse option will mean that whatever directory you tell ctags to look at, all subdirectories will be scaneed as well - Open a command window and navigate to the UltraEdit program directory
- Type the following command
ctags -f "D:\UnrealScript\uctags.lst" d:\Games\UnrealTournament
- Open the new ctags file to see if it worked. It should be quite a large file starting something like this:
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ !_TAG_PROGRAM_NAME Exuberant Ctags // !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ !_TAG_PROGRAM_VERSION 5.3 // ASTutEvent0 c:\winnt\system32\u\botpack\classes\TrainingAS.uc /^function ASTutEvent0()$/;" d ASTutEvent1 c:\winnt\system32\u\botpack\classes\TrainingAS.uc /^function ASTutEvent1()$/;" d ASTutEvent10 c:\winnt\system32\u\botpack\classes\TrainingAS.uc /^function ASTutEvent10()$/;" d ASTutEvent11 c:\winnt\system32\u\botpack\classes\TrainingAS.uc /^function ASTutEvent11()$/;" d
- From the main menu, select Project | CTAG Options
- In the Default tagfile textbox, type the name fo the tagfile you created as above (for example: D:\UnrealScript\uctags.lst)
- Click the OK button
- Open a big .uc file to test with.
- Put the cursor over some word like "Actor" or "Pawn". Some class or function name you would expect to find a definition for somewhere in the class tree.
- Press F11 on your keyboard and UltraEdit will open the file containing that class definition or if you were finding a function definition, it will probably open a dialog box asking you to select from the list.
Defining a Project
Project Workspaces are a useful way to open and manage all of the files relevant to your current project. I have found it useful to create all of my project files in one place (D:\UnrealScript). I also store my UnrealScript related ctags here as well.
To define a new Project:
- From the main menu, select Project | New Project/Workspace
- Using the project file dialog, navigate to the desired storage location for the project file and type in a name to use. Click Save.
- In the project dialog, use the browser to locate the top level directory for your project files. For example: If your directory structure is similar to mine, you might choose the D:\Games\UnrealTournament directory as your project directory
- Click on New Group and type in the name UC Files as the name of the new group
- Click on Add Files and select the .uc files you wish to have as part of this project
- If you have other types of files (for example INI files, INT files) as part of the the project, create more groups and add the files
- If you created a ctag file as above then you can specify this in the Optional CTAGS file text box. (Highly recommended)
When I wrote this, the Create CTAGS file on project load did not work to my satisfaction. See the following section for a better way to create your ctags file.
Defining Project Tools
Now that you have a project defined, it is very handy to have some command line utilites available as menu options. I have two main ones for all of my projects. These are described below. In both cases, the method to create a Project specific Tool option is the same. If you wish, you can create a Tool option that is available for all projects but I tend to avoid this as it can get messy.
Make Project
To create a Make Project batch file:
- Choose a location to store your utility files (for example: D:\UnrealScript)
- Create a command file such as the following and save it with a name like MakeXYZ where XZY is the name of your project
@ECHO OFF d: cd\Games\UnrealTournament\System copy XYZ.u XYZ.u.bak del XYZ.u ucc make
Naturally you will need to customise this for your UnrealTournament installation directory and for the .u files in your package.
To create a Make Project tool option:
- Open your project file
- From the main menu, select Advanced | Project Tool Configuration
- In the Command line text box, type makeXYZ
- In the Working directory text box, type D:\UnrealScript (or wherever you chose to store your utilities)
- In the Menu Item Name text box, type Make XYZ
- In the command Output option box, I like to select Replace Existing and Capture Output as these work well together to show you any compile errors (heaven forbid! haha)
- Now the most important step that is quite often forgotten! You must select Insert to save your tool configuration. Alternatively, select Replace to replace an existing tool option.
Now, the project tool option will be available form the Advanced menu bar whenever the project is opened.
Create CTAGS file
To create a Create CTAGS file tool option:
- Open your project file
- From the main menu, select Advanced | Project Tool Configuration
- In the Command line text box, type
ctags -f "D:\UnrealScript\uctags.lst" D:\Games\UnrealTournament
(replace with your own locations) - In the Working directory text box, type D:\UnrealScript (or wherever you chose to store your ctags file)
- In the Menu Item Name text box, type Create UT CTAGS
- In the command Output option box, I like to select Append to Existing and Show DOS box as the presence of the DOS window indicates that the ctags are still being generated.
Now you can specify the ctags file as the project ctags file in the Project window. This is highly useful as described in the section above (CTAGS/Find Symbol)
Other Command Files
Another useful command file is very simple and used to export any .u file
I call it uccbatchexport and the syntax is:
D:\Games\UnrealTournament\System\ucc batchexport %1.u class .uc D:\Games\UnrealTournament\%1\Classes\
If you place this in your UnrealTournament\System directory then you can call it from UltraEdit or from the command line any time you want to export a .u file.
Unexplored Territory
So far I have not delved into the Templates or MACRO features. I think they are power tools that C++ programmers are most familiar with. I expect that when I take a look I will end up finding them useful and I will be sure to pop back and update this page (unless someone else already has)
=
I hope this has been helpful – Kuhal
Comments
SocratesJohnson: Thanks for the fantastic info. I've been trying to get ctags to work for the Vim editor (http://www.vim.org) for class browsing and to work with the Taglist script (http://www.vim.org/scripts/script.php?script_id=273) which shows the tags of the current file in a side window for easy access, etc. I've modified your ctags.cnf file for it to work with UT2003, it its current form I got some interesting results. Here's my version:
--langdef=INI --langmap=INI:.ini --regex-INI=/^[ \t]*\[(.*)\]/\1/b,block/ --regex-INI=/^[ \t]*([^\[=]+)=(.*)/\1/k,key/ --langdef=unrealscript --langmap=unrealscript:.uc --regex-unrealscript=/^[ \t]*[cC]lass[ \t]*([a-zA-Z0-9_]+)/\1/c,class/ --regex-unrealscript=/^[ \t]*[sS]tate[() \t]*([a-zA-Z0-9]+)/\1/s,state/ --regex-unrealscript=/^[ \t]*[sS]imulated[ \t]*(.*)[ \t]+([a-zA-Z0-9_]+)\(/\2/i,simulated/ --regex-unrealscript=/^[ \t]*[eE]vent[ \t]*[^ \t]*[ \t]+([a-zA-Z0-9_]+)\(/\1/e,event/ --regex-unrealscript=/^[ \t]*[fF]unction[ \t]*(.*)[ \t]+([a-zA-Z0-9_]+)\(/\2/f,function/ --recurse
The [() \t] bit in the state regex is a bit cheesy but it works.
I think I'll add a new page for people who are interested in Vim as an UnrealScript editor with some things I've come across.
Comments
Piglet: UltraEdit is a very nice program, I basically use it whenever I can know, for unrealscript i'm currently using WOTgreal (as a class browser and file launcher) and UltraEdit (as my actual code editor) It's a bit of a clumsy setup but it seems to work quite well
El Muerte TDS: try UnCodeX is suits better as a class browser than WOTgreal </advertisement>
Piglet: By the way the custom syntax highlighting stuff was useful (i was bodging it with CPP notation before and was trying to get myself motivated to do it myself, now i dont have to )