Contents


Auto Capitalization Support

Setting up Automatic Colorization

Automatic Colorization File Command Syntax

Sample Colorize File


Introduction


SPFLite can display source files with keywords and delimiters automatically highlighted in various colors to assist in the readability of source code. To do this, SPFLite requires an Automatic Colorization file, which describes the particular source language (e.g. reserved words, delimiters used, comment indicators, etc.)


When the PROFILE option HILITE AUTO ON is chosen, (See the HILITE command) SPFLIte will look for an Automatic Colorization file to use in the colorization process. If no matching Automatic Colorization file can be found, the file will be displayed as if colorization had not been requested. Automatic Colorization is based on the Profile selected by the Extended File Type process for the file being edited. Please review this topic to better understand how Profiles are chosen.


The SPFLite web site has a down-loadable ZIP file containing a set of sample Colorization files for some of the common types. Note these files are NOT to be considered exact and complete for any of the languages provided. They were created very quickly from some keyword lists located on the web and they have received little or no real testing. The only one I'm fairly sure of is PowerBasic.AUTO since that is my language of choice. 


AUTO files do not specify the actual colors to be used. The entries reference SCHEME numbers. The details of the colors SCHEME actually displays are specified in the OPTIONS -> SCHEMES dialog, which provides for 14 different color schemes.


Using schemes means if you are consistent in using scheme numbers for particular aspects of colorization (e.g. literals always request Scheme 7), then you can change the color of literals in ALL your AUTO files by simply editing Scheme 7 in OPTIONS -> SCHEMES.


Being consistent here can also be assisted by the Alias support for Schemes.  Review OPTIONS -> SCHEMES for more info. In the following descriptions, whenever a Scheme number is referred to, you can optionally substitute a Scheme Alias name.



Auto Capitalization Support


As well as colorization support, SPFLite can be requested to customise the capitalization all language keywords defined in the .AUTO file. For some computer languages, this can assist readability greatly. Note the capitalization is done only during screen display, the actual text itself is not altered. Actual text changing can be done, See AUTOCAPS for more information on permanently altering the text itself.


Three options exist when identifying language Keywords. Each uses a unique AUTO command directive:


WORD

Identifies keywords which are to be colorized according to the specified Scheme number.


AUTOCAPS

identifies keywords which are to be colorized according to the specified Scheme number

   AND

which are to be capitalized.


AUTOCASE

identifies keywords which are to be colorized according to the specified Scheme number

   AND

the case of the word displayed is to be forced to agree with the case of the keyword as specified in the AUTOCASE statement.

e.g. If AUTOCASE 12 %Yellow is specified in the AUTO file, and the text %YeLlOw appeared in the file, it would be displayed as %Yellow. This is convenient when CamelCase is used for many function or API references



When used, these options will cause all identified keywords in the associated .AUTO file to be case-modified as requested. The keywords are also processed as they are typed. 


e.g. Assume  both FOR and FOREVER are valid keywords in the current .AUTO file. Then assuming the word 'forever' was typed (in lower-case), it would appear successively as:


f

fo

FOR

fore

forev

foreve

FOREVER


As this shows, the uppercasing is not done by actually changing the text data as keywords are detected, if that were the case the sequence would have  looked like:


f

fo

FOR

FORe

FORev

FOReve

FOREVER


and if you actually wanted to stop with the word 'fore' you would not be too happy to have it as 'FORe' .


So the uppercasing is performed only on what is displayed on the screen


If you want the capitalization changes to be written to the file when saved, set the Profile AUTOCAPS to ON, the uppercasing will be 'finalized' and written to the output file. So what you see is what you get.


Note: The Profile AUTOCAPS command is a Primary command, although related, it is not the AUTOCAPS directive  in the AUTO file described above.




Setting up Automatic Colorization


    • Locate the appropriate sample file for your language, copy it to the SPFLite \AUTO Data folder. If you are unsure of what directory this is, Enter the OPTION CONFIG command to see the "Location for the SPFLite Data storage folders (MACRO, AUTO, STATE etc)". The AUTO colorize control files should be placed in the \AUTO folder within this directory. Ensure the base filename equals the normal extension used for the source. For example, if using PowerBasic as I do, you would copy and rename PowerBasic.AUTO to BAS.AUTO.


    • Examine the SCHEME numbers used by the sample file and decide how this 'fits' with the SCHEMES you have specified in OPTIONS -> SCHEMES. Then simply alter the Scheme numbers in the WORD/AUTOCAPS/AUTOCASE statements to your choice in SCHEMEs.


The structure is fairly simple (described below) and it should be easy to create or update these for any language. Should you update any of these, or create new ones for other languages, I encourage you to send them in to me; I will add them to the collection and make them available for all users.


Automatic Colorization File Command Syntax


Automatic Colorization files consist of either:


    • comments (blank lines, or lines starting with a ; in position 1)


NOTE: Comments must be on separate ; lines, comments are not allowed to be entered following the operands of a definition statement. The fact that they may sometimes seem to work should be ignored


    • definition statements


Definition Statements


COMMENTn   sn   start   end

Up to Nine comment definitions are supported COMMENT1 thru COMMENT9.  


The sn operand refers to the scheme number used to display the comment. Each COMMENTn statement may reference different scheme's if desired, or the same scheme. sn may be a hard-coded number, or a Scheme Alias name.


The start operand specifies the character (string) which indicates the beginning of comments.  


The end operand can have one of three meanings:  


  1. 0 (zero) indicates the start string can begin anywhere in a line and the remainder of the line is a comment


  1. n (positive number) indicates the start operand is to be recognized only in this position and the remainder of the line is a comment. (Like the COBOL comment indicator in position 7.). 


  1. string data indicates the comment starts with the start operand and ends with this operand. A typical example of this would be the comment markers /* */ or (* *). 


Note: SPFLite does not support multi-line comments.  




EXCLUDE  col string

The EXCLUDE statement request that all text lines which match the specified criteria be excluded from further colorization processing. They will be displayed under control of the Normal Text Lo definition.


The col operand specifies a column number in which to look for the string operand; a match will cause the line to be excluded. If the col operand is coded as zero, the string operand will be scanned for anywhere within the text line.


You may code up to 10 EXCLUDE statements.


INCLUDE  col string

The INCLUDE statement request that only text lines which match the specified criteria be passed on for further colorization processing. Lines which fail all INCLUDE statement selection will be displayed under control of the Normal Text Lo definition


The col operand specifies a column number in which to look for the string operand; a match will cause the line to be included. If the col operand is coded as zero, the string operand will be scanned for anywhere within the text line.


You may code up to 10 INCLUDE statements.


Note: If both EXCLUDE and INCLUDE statements are present,  EXCLUDE processing is performed first, followed by INCLUDE processing.



QUOTED   sn [xy] [xy] ...

The sn operand specifies the Scheme number to be used for the display of quoted literal strings. 

sn may be a hard-coded number, or a Scheme Alias name. If entered as simply QUOTED sn (with no optional parameters) then literal quoted strings are assumed to be delimited by the default set of Double quotes  " " 

You may specify a more exact 'set' of delimiters for quoted strings. The delimiters are entered as a pair of characters, separated by spaces. The first character is the 'opening delimiter' and the second character is the 'closing delimiter'.


Examples:

   QUOTED 8 ""

This specifies that only qouble quotes are literal delimiters, the normal single quotes or back quotes will not be recognized as delimiters.

   QUOTED 8 <>

This specifies that the less-than and greater-than characters are the literal string delimiters, none of the normal single, double or back quotes would be recognized as delimiters.

   QUOTED 8 || ''

This specifies that only the vertical Bar | and single quotes will be used as literal delimiters, the normal single quotes or back quotes will not be recognized as delimiters.



NUMERIC  sn

The sn operand specifies the Scheme number to be used for the display of literal strings which are not identified as a keyword, and contain only numeric characters. sn may be a hard-coded number, or a Scheme Alias name. Numeric characters are considered to be 0-9, period and comma.


Note if the period or comma are also specified as delimiters in the DELIMS string, the DELIMS specification will take precedence. For example if the comma is a delimiter, the string 123,456 will be treated as a numeric string 123, followed by a comma delimiter, followed by a numeric string 456.


If the NUMERIC statement is not provided, Numeric strings will be displayed under control of the Normal Text Lo definition


ESCAPECHR   x

Literals in some languages allow embedded special characters (including the single or double quote) within a literal if they are preceded by an 'escape' character, which basically says to ignore the next character as a delimiter. For example, if ESCAPECHR  \ is specified, then the following string would be a valid quoted literal.  


'What\'s the matter, didn\'t you understand'


DELIMS   string

The DELIMS statement defines the delimiters which the language uses to separate operands and language elements. Normally the string would be something like +-*/=()^<>[]{},; This string typically varies mostly due to what characters are allowable in variable names where sometimes characters like _ and . are allowed. Note that when the language uses relational operators like BASIC's <> or >= that the individual characters are what should be entered. Note that the space need not be specified, it is always a delimiter.  


MIXEDCASE   yes  |  no

Some computer languages are sensitive to the case of the keywords and can have duplicate keywords that have different meaning depending on their case. (e.g. void and Void in Java) If MIXEDCASE YES is specified, then the keyword search will be sensitive to the case of the words. If the default MIXEDCASE NO is specified, keywords will be searched for regardless of case.


WORD           sn   string

AUTOCAPS  sn  string

AUTOCASE  sn  string

The WORD / AUTOCAPS / AUTOCASE statements define the reserved words for the particular language.  


The sn operand refers to the Scheme number (defined in Options -> Schemes) used to display the word. sn may be a hard-coded number, or a Scheme Alias name. Different Schemes may be used to classify reserved words into various categories. 


When AUTOCAPS is used instead of WORD, it requests uppercasing of the specified keyword when it is detected.


When AUTOCASE is used instead of WORD, it requests forcing the the specified keyword to appear (case-wise) exactly as it is specified by the AUTOCASE statement.


The string specifies the actual reserved word. No embedded blanks are allowed, use multiple WORDs if needed.  


Note: Each character entered in the DELIMS statement should be entered also with a WORD statement.  


Sample Colorize File


; SPFLite colorize file for DOS Batch files

;

QUOTED   5

COMMENT1 1  REM  0 

COMMENT2 1  ::   1    

; Delimiters

DELIMS   (),.:=@

WORD     6  (

WORD     6  )

WORD     3  ,

WORD     3  .

WORD     3  :

WORD     3  =

WORD     3  @

;                              Reserved words

WORD     4  aux                

WORD     4  com1               

WORD     4  com2

WORD     4  com3

WORD     4  com4

WORD     4  con

WORD     4  lpt1

WORD     4  lpt2

WORD     4  lpt3

WORD     4  prn

AUTOCAPS 3  call               

AUTOCAPS 3  cd                 

AUTOCAPS 3  defined            

AUTOCAPS 3  dir

AUTOCAPS 3  do

AUTOCAPS 3  echo

AUTOCAPS 3  else

AUTOCAPS 3  endlocal

AUTOCAPS 3  equ

AUTOCAPS 3  errorlevel

AUTOCAPS 3  exist

AUTOCAPS 3  exit

AUTOCAPS 3  for

AUTOCAPS 3  geq

AUTOCAPS 3  goto

AUTOCAPS 3  gtr

AUTOCAPS 3  if

AUTOCAPS 3  in

AUTOCAPS 3  leq

AUTOCAPS 3  lss

AUTOCAPS 3  neq

AUTOCAPS 3  not

AUTOCAPS 3  nul

AUTOCAPS 3  pause

AUTOCAPS 3  set

AUTOCAPS 3  setlocal

AUTOCAPS 3  shift


Created with the Personal Edition of HelpNDoc: Effortlessly Convert Your Word Doc to an eBook: A Step-by-Step Guide