ModeWhen files define which mode StrongED uses when a file is initially loaded. If the ModeWhen files haven't caused such a decision, then BaseMode is used.
A word of warning: inspecting StrongED's files can be instructive, even necessary in order to understand them. However as StrongED writes out many of its own files, the primary file, as supplied with the StrongED release, can look different in places to the changed file. These descriptions apply to the primary files.
A mode file can consist of the following sections:
| PrintHead | PrintFoot | Tabstops |
| Search | SyntaxWords | Replace |
| FoldParm1 | ClickList | KeyList |
| Functions | Shortcuts |
Other named ClickLists can be tied to key presses rather than mousebutton presses. See Named Search Expressions
ClickList [name] search-name List of functions EndThus in the BaseMode file you will find two ClickLists. The first is:
When you double click with Select, this list is consulted. StrongED will go through it and see if the clicked word matches any of the search expressions in the Search section of the ModeFile of the current mode or the BaseMode. If it does, the corresponding list of functions will be executed. In the above case, the function is BroadcastURL
The search-name needs to match a named expression in the Search section of the ModeFile.
The list of functions is one or more of StrongED's functions, separated by spaces.
You can prefix a clicklist name with for instance, s-. It will then only apply if Shift was held in while you clicked. The full syntax of the mouse-clicklist name is then:
[a][c][s]- Select|Adjust 1|2
Example: cs-Select2 = Doubleclick Select, with Ctrl and Shift pressed.
Example 2: To run a file when a filename is double-clicked you could use:
ClickList Select2
Filename Run("Filer_Run ")
End
and in the search section you would put:
Search
FileSys "ADFS" | "RAM" | "SCSI" | "SDFS"
FileName FileSys "::" {~(Ctrl|White) Any}+
end
There is more on ClickLists
When is executed, a fold is performed based on FoldParm1 and FoldParm2 as defined in the ModeFile(s). FoldParm1 is defined in the BaseMode file and is used globally unless otherwise re-defined. FoldParm2 is optional.
These FoldParms passed to the FoldSpecial function.
The syntax is: FoldParm1(Startfold, Endfold, Where, Case)
Each parameter may be either a text string, enclosed in double inverted commas, or it may be a named search expression, as defined in the Search section of the ModeFile. In many Modes, these named expressions are actually called e.g. fold_start, fold_end, startofline, case (or similar names).
There is a list of Fold Parameters Pre-defined in ModeFiles which should clarify this. For instance in Document mode both FoldParms are defined thus:
FoldParm1 (fold1start,fold1end,StartOfLine,NoCase) FoldParm2 (fold2start,fold2end,StartSpace,NoCase)All the parameters are named, StartOfLine and NoCase being internally defined and the other names being defined in the Search section:
You can override the fold parameters in the modefile by specifying them directly in the start of a text.
NB1: Due to a bug, the open fold markers will not redraw correctly. Unfortunately I (FG) have so far been unable to fix this.
NB2: As far as I (FG) can see, 'EndOfLine' is not supported.
Foldparm2 ("<H",,,nocase)
This folds, showing <H Headings as the fold points.
Sections are in blocks: only some lines call internal functions, others assign names to icons or names to keys which will perform the same action as the mouse click defined in the same block.
You may want to inspect an existing ModeFile. If doing so, beware of the above warning!
Items in a block may be in any order, except that Key or Menu should start the block.
This file may be, for example, <StrongED$Dir>.Defaults.Modes.BaseMode.Resources.UK.Messages or in a Mode directory such as !StrED_cfg.UserPrefs.Modes.HTML.Resources.UK.Messages
However, when more than a single mouse-click operations is defined, it would be ambiguous as to which mouse action applied to the defined Key. So an empty line is required before or after lines which do not apply to the Key definition. The mouse action which is not separated by two Returns is the one that applies to the Key. There is an example which should clarify this.
This is not a filer path but simply a comma separated string listing which StrongHelp manuals should be searched. The manuals will be searched in the order they listed. The manuals known to StrongHelp can be determined by Adjust-click on StrongHelp.
The definition may end with a trailing comma in which case StrongHelp will search all remaining manuals if those listed do not produce a match.
The BaseMode ModeFile does not include a HelpPath but most other modes do.
One of the items in a mode's Choices -> Colours list of colourable Elements is Identifiers. These three items define what words should be coloured as Identifiers.
The colouring of other words, as defined in SyntaxWords or SyntaxOptions, will be applied preferentially.
This is useful for such things as variables in a programming language. Or for tags in html.
ID_FirstChar defines which characters an Identifier can start with. Some programming languages have restrictions on this, eg in BBC BASIC IDs can't start with a digit.
ID_Middle defines which characters can be in the middle (ie not first or last) of an Identifier.
ID_LastChar is used for special characters that denote the end of an Identifier. In BBC BASIC integer variables end with '%', and string variables with '$'.
As an example, consider the html ModeFile where these three are defined:
ID_FirstChar < ID_Middle /A-Za-z_0-9 ID_LastChar A-Za-z_0-9>
This example is interesting - ID_LastChar is optional. If it is not defined then it is ignored. Its only purpose is to colour the last character. In the above case the set A-Za-z_0-9 has already been defined in ID_Middle, so will be coloured. It is then redundant to redefine that set again as ID_LastChar and a clearer definition of ID_LastChar would be simply <
However the ModeFile for HTML is old, a better definition of these three IDs might be
ID_FirstChar < ID_Middle /A-Za-z _0-9 ID_LastChar >Notice the space after the z - this colours the whole of a tag, including any class definition.
Keylist is followed by the name of what it is to be tied to. If a name is not specified, then it defaults to Mode which is the only name which can be used in a normal mode file, so in practise is not used there. The other possible names are only used in BaseMode and are all listed below:
syntax
<Key name> <List of Functions=>!ref_function> End
Some example key definitions:
^Right 1 EndOfWLine
^Right 2 EndOfTLine
^D,^D DateAndTime ("%DY%MN%YR")
^D,^T DateAndTime ("%24:%MI")
^D,^W DateAndTime ("%WK")
Another example, in HTML mode:
Note the use of the old ASC &5E for Ctrl and ASC &8B for Shift: new representation would be e.g. cs-T.
OnLoad <list of functions\>The OnLoad keyword can be used to automatically execute a list of commands every time a file is loaded. No ModeFiles as supplied include the command. Execution of the OnLoad function is controlled on a mode by mode basis in the ModeLock File
PrintHead <String to send to printer> PrintFoot <String to send to printer>The BaseMode is the only mode that has these pre-defined. So unless you define them in other modes the header and footer (if printed) will default to:
PrintHeadThe string is passed through OS_GSTrans so you can use system variables such as Sys$Time, Sys$Date and Sys$Time. In addition you can use the variables defined by the Function SetTmp, StrongED also defines the variable StrongED$Tmp_Page which holds the page number of the page being printed.|i|i |m PrintFoot |m|i---- ----
To split the output into multiple lines use |m (=carriage return). Each line can be divided into three sections (left, center, right) by using |i (=tab) as a separator. Examples
PrintHead |i Centredgives a header:
and The default, as defined in BaseMode is
PrintHead <StrongED$Tmp_FileName>|i|i<Sys$Time> <Sys$Date> <Sys$Year>Printing the source of this html file that you are reading results in:
The BaseMode contains only one:
The syntax is the same as that for Advanced Replace
Syntax of the block is
Search name Expression .. Endwhere Expression is a valid search expression as explained in Advanced Search and Replace. There are four uses for named search expressions;
You can also name such Search Expressins in a Patterns File.
There is a screen shot of the BaseMode's Search section. It is long! However you can open the ModeFile of the BaseMode by a Ctrl-Adjust click on StrongED's iconbar icon. any of these named definitions can be used in a Search expression.
Syntax
Shortcut typed_text replacement_text ... End
Whenever the 'shortcut' is typed, and it is floating, it will be replaced by the 'replacement_text'.
The shortcut is floating when the characters that are before and after it in the text are of a different type than the first and last letter of the shortcut. Thus in html mode, some of the shortcuts defined are:
so that typing ``1This is a heading will be expanded to <h1>This is a heading</h1>. The ``1 bit is expanded immediately you type it since the white space following it means it is floating. The caret, after the expansion, is positioned at the first \@ in the expanded text, so after the <h1>.
However if you type This is a heading first and then go back and insert the ``1, it does not expand because of the T following the typed text!
The replacement text can contain some special escape sequences:
\n is replaced with a newline \t is replaced with a TAB \i is replaced with the indent that the first line has \@ Defines where the caret should be placed after expansion.If \@ is not present, the caret will be placed at the end of the inserted text.
These \@ markers for the cursor position behave in a manner somewhat similar to the @ markers in Search and replace. If an \@ marker is followed by a number, then this number will refer to a previous @ marker in the replacement text - StrongED keeps internal note of the quantity of \@ markers in the expansion.
On pressing return to jump to the next \@ marker, when the Caret reaches this numbered \@ marker, the (expanded) word before the position it refers to is copied to the cursor.
``f function \@()\n-- end of \@0Then, after typing ``f and the function name we might have:
function Foobar() -- end ofThe cursor will be just after Foobar. If we now hit return the cursor will be moved to after 'end of ' and the word before the first \@ will be copied there, in this case 'Foobar', so that we end up with:
function Foobar() -- end of Foobar
<h2 id="Shortcuts">Shortcuts</h2>So I now have added the shortcut
<<h2 <h2 id="\@">\@0</a>\n\@To get the above heading all I would then type would be
<<h2Shortcutfollowed by Return twice.
It is very well worth looking at the shortcuts in the modes you use a lot to see what is available there.
Syntax
SmartIndent IndentSizeThe SmartIndent section provides two ways to make StrongED indent text automatically. It is possible to use both methods at the same time, in that case the indent characters take precedence over the indent expressions. For both methods IndentSize determines by how much the indent will be increased/decreased.IndentChar OutdentChar IndentAfter OutdentLine End
The current line is re-indented when Return is pressed by seeing if there's a match against any of the definitions. If so, the indent of the current line is increased or decreased by IndentSize as appropriate.
Please note that SmartIndent works best with the option 'Automatic indent after Return' in the Edit section of the Mode Choices is turned on. However you can use SmartIndent with the option turned off.
When Return is pressed StrongED checks if the previous line ends with the IndentChar. If so, the indent of the current line is increased by IndentSize.
Next StrongED checks if the current line starts with the OutdentChar (which may be preceded by whitespace). If so, StrongED scans backwards through the text to find the matching IndentChar taking nesting into account. If a match is found the indent of the current line is set to be the same as the line producing the match.
This method is useful for languages that use certain characters to delimit blocks of code, such as curly braces in C.
When Return is pressed StrongED checks if the previous line matches IndentAfter. If so, the indent of the current line is increased by IndentSize.
Next StrongED checks if the current line matches OutdentLine. If so, the indent of the current line is decreased by IndentSize.
SmartIndent Case
IndentSize 2
IndentAfter < {" "} ("do" | "if" | "elseif" | "else" | "for" | "function" | "repeat" | "while") \s
OutdentLine < {" "} ("end" | "elseif" | "else" | "until") \s
End
This tells the syntax colouring routines what a comment looks like. Two can be defined. The parameters are described below, defaults are shown in italics. *CommentType* specifies how far a comment spans. /OneLine/ Comments spans just one line, e.g. REM in BASIC. MultiLine Comments can span several lines, e.g. /*..*/ in C. Recursive Comments can span several lines, they can also be nested. *StartWhere* defines where on a line a comment can start. /AnyWhere/ Comments can start anywhere on a line. StartLine Comments must be right at start of line. StartSpace As above but may be preceded by whitespace. *StartWith* String that a comment will start with. *EndWith* String that a comment will end with. /Notes/ Recursive comments are not yet supported. Previously /CommentType/ was called /Type/ which is still supported but deprecated. The EndWith part is optional, if omitted it'll default to end-of-line for OneLine and to end-of-text for MultiLine/Recursive comments.
Various options for the syntax colouring routines.
SyntaxOptions
| SingleQuote | yes|no | 'String' |
| DoubleQuote | yes|no | "String" |
| QuoteQuote | yes|no | "String with ""Quote""" |
| SplitString | yes|no | Can a string continue on next line? |
| QuoteChar | char | Which char is used to prefix quotes & such? |
| HexPrefix | string | After this a hexadecimal number follows |
| HexSuffix | string | Terminates a hexadecimal number |
| BinPrefix | string | After this a binary number follows |
| BinSuffix | string | Terminates a binary number |
| Numbers | Off|Int|Flt|Exp | Determines which numbers are coloured |
| Functions | None|NoSpace|Spaces|White | Determines what may separate a function name from '(' |
Here are defined groups of words that you want picked out in a particular colour. Each Group relates directly to the Mode's choices -> Colours dialog box whyere they will be listed. In StrongED 4.6 there are 16 possible groups (1-16). In StrongED 4.7 this is increased to 32 (Group1 to Group32). There are also some named syntax words:
| Text | Tabs | Ctrl | Spaces | |
| HardSpc | Brackets | Newlines | Caret | |
| Block | Mark | Border | Margin | |
| Hardwrap | Linenumbers | Identifiers | Functions | |
| Strings | Comments | Numbers | Punctuation |
SyntaxWords Group1..32 [case|nocase] [StartOfLine|StartSpace] EndType list of words Endwhere
| EndAlways | Accept now |
| EndNonID | Accept if next char is not in the ID_Middle set |
| EndOfID | Accept and continue until first non-id char |
| EndOfLine | Accept and continue until end of line |
| EndOfExpr /name/ | Accept and match against the search expression /name/ |
| For Assembly : | |
| EndOfAsm | Accept if it's a valid instruction |
| EndOfFlt | Accept if it's a valid instruction |
| The following EndTypes are considered obsolete and should no longer be used. They are still supported but simply map onto EndOfAsm. | |
| EndAsm | Accept if rest matches [condition] [B | P | S] |
| EndSTM | Accept if rest matches [condition] direction |
| EndBL | Accept if rest matches [L] [condition]. Use for B and BL |
Below is an example of how EndOfExpr could be used to do the same job as EndAsm. This would be slightly slower than EndAsm itself, but not noticeably so, since assembly is normally written one statement a line, meaning a full screen redraw would cause only about 40 matches against ee_asm.
Search
ee_opt "eq" | "ne" | "cs" | "cc" | "mi" | "pl" etc...
ee_asm [ee_opt] ["S" | "B" | "P"]
...
SyntaxWords Group1 EndofExpr {f*:ee_asm} nocase
ADC ADD AND BIC CMN CMP EOR MLA MOV MUL
..
As an example consider the SyntaxWords section of the NewsMode file. Of particular interest are groups 5 to 8 where four different colours are used for different quoting levels. The fourth level is:
SyntaxWords Group8 StartOfLine EndOfLine nocase >>>> ">>> >" ">> >>" ">> > >" "> >>>" "> >> >" "> > >>" "> > > >" ">>>> " ">>> > " ">> >> " ">> > > " "> >>> " "> >> > " "> > >> " "> > > > " EndThese definitions include every variation of four < signs and single spaces. Note that to include a space in the word to be highlighted you must enclose that word in double quote marks.
As an example, I wondered whether it was possible to make URLs starting with other than https:// or www coloured and clickable. There are problems!
By default, Tabstops are only defined in the BaseMode.Modefile where the definition is:
Tabstops 3*
However much more complicated definitions are possible, for example:
Tabstops 1,2,[3,4]*5,6,7*3,8*
Should the cursor position be greater than the total of all tabstops then pressing the tab key will have no effect.
Tabstops can also be defined by setting StrongED$Tabstops = (definition) in the start of a file. See Options embedded in Files
TabStops insert the required number of spaces to tab to the appropriate column. It does nor affect the lenght of the dotted line display.
Example definition strings
| 3,5*4,8* | one 3 char column, then four 5s and then 8s forever | |
| [6,9]* | Alternating 6 and 9 char columns | |
| [3*2,5*3]*4 | Two 3s then three 5s, repeated four times and then no more | |
| [[4*3,5]*2,7]* | An endless series of 4, 4, 4, 5, 4, 4, 4, 5, 7 |