Updated ConTEXT Highlighter

BlitzMax Forums/BlitzMax Programming/Updated ConTEXT Highlighter

Place this under the /Highlighters folder of your ConTEXT installation as "BlitzMax.chl"

Language:               BlitzMax
Description:            BlitzMax Highlighter, written by Noel R. Cower (www.noelcower.com)
Filter:                 BlitzMax source files (*.bmx)|*.bmx
HelpFile:               c:\blitzmax\doc\index.html
CaseSensitive:          0
LineComment:            '
BlockCommentBeg:        Rem
BlockCommentEnd:        EndRem
IdentifierBegChars:     a..z A..Z _%@.
IdentifierChars:        a..z A..Z _ 0..9
NumConstBegChars:       0..9 $ %
NumConstChars:          0..9 #abcdefABCDEF
EscapeChar:             ~

// Functions
KeyWords1: Cotangent
DegreeToRad
NearestPower
RadToDegree
ReturnedY
Slope
YIntercept
AllocChannel
ChannelPlaying
CueSound
LoadSound
PauseChannel
PlaySound
ResumeChannel
SetChannelDepth
SetChannelPan
SetChannelRate
SetChannelVolume
StopChannel
CreateAudioSample
CreateStaticAudioSample
LoadAudioSample
CreateBankStream
BankBuf
BankCapacity
BankSize
CopyBank
CreateBank
CreateStaticBank
LoadBank
PeekByte
PeekDouble
PeekFloat
PeekInt
PeekLong
PeekShort
PokeByte
PokeDouble
PokeFloat
PokeInt
PokeLong
PokeShort
ReadBank
ResizeBank
SaveBank
WriteBank
Bin
Hex
Instr
Left
LongBin
LongHex
Lower
LSet
Mid
Replace
Right
RSet
Trim
Upper
AppArgs
AppDir
AppFile
AppTitle
LaunchDir
DebugLog
DebugStop
GCCollect
GCMemAlloced
GCSetMode
HandleFromObject
HandleToObject
MemAlloc
MemClear
MemCopy
MemExtend
MemFree
MemMove
OnEnd
ReadStdin
RuntimeError
WriteStderr
WriteStdout
bglAdjustTexSize
bglCreateContext
bglDeleteContext
bglDisplayModes
bglDrawText
bglFixedFontBitmaps
bglSetMouseVisible
bglSetSwapInterval
bglSwapBuffers
bglTexFromPixmap
BufferedD3D7Max2DDriver
D3D7Max2DDriver
BigEndianStream
LittleEndianStream
CreateEvent
EmitEvent
CurrentEvent
EventData
EventExtra
EventID
EventMods
EventSource
EventSourceHandle
EventText
EventX
EventY
PeekEvent
PollEvent
PostEvent
WaitEvent
ChangeDir
CloseDir
CloseFile
CreateDir
CreateFile
CurrentDir
DeleteDir
DeleteFile
ExtractDir
ExtractExt
FileMode
FileSize
FileTime
FileType
LoadDir
NextFile
OpenFile
ReadDir
ReadFile
RealPath
RenameFile
SetFileMode
StripAll
StripDir
StripExt
StripSlash
WriteFile
CloseGNetHost
CloseGNetObject
CloseGNetPeer
CreateGNetHost
CreateGNetMessage
CreateGNetObject
GetGNetFloat
GetGNetInt
GetGNetString
GetGNetTarget
GNetAccept
GNetConnect
GNetListen
GNetMessageObject
GNetMessages
GNetObjectLocal
GNetObjectRemote
GNetObjects
GNetObjectState
GNetPeers
GNetPeerTCPSocket
GNetPeerUDPSocket
GNetSync
GNetTotalBytesIn
GNetTotalBytesOut
SendGNetMessage
SetGNetFloat
SetGNetInt
SetGNetString
SetGNetTarget
CloseGraphics
CountGraphicsModes
CreateGraphics
EndGraphics
Flip
GetGraphicsMode
Graphics
GraphicsDepth
GraphicsFlags
GraphicsHeight
GraphicsHertz
GraphicsModeExists
GraphicsModes
GraphicsWidth
SetGraphics
SetGraphicsDriver
AddHook
AllocHookId
RemoveHook
RunHooks
JoyAxisCaps
JoyButtonCaps
JoyCount
JoyDown
JoyHat
JoyName
JoyPitch
JoyR
JoyRoll
JoyU
JoyV
JoyWheel
JoyX
JoyY
JoyYaw
JoyZ
ClearList
CountList
CreateList
ListAddFirst
ListAddLast
ListContains
ListFindLink
ListFromArray
ListIsEmpty
ListRemove
ListToArray
RemoveLink
ReverseList
SortList
SwapLists
ACos
ASin
ATan
ATan2
Ceil
Cos
Cosh
Exp
Floor
Log
Log10
Sin
Sinh
Sqr
Tan
Tanh
AutoImageFlags
AutoMidHandle
Cls
CollideImage
CollideRect
CreateImage
DrawImage
DrawImageRect
DrawLine
DrawOval
DrawPixmap
DrawPoly
DrawRect
DrawText
GetAlpha
GetBlend
GetClsColor
GetColor
GetHandle
GetImageFont
GetLineWidth
GetMaskColor
GetOrigin
GetRotation
GetScale
GetViewport
GrabImage
GrabPixmap
ImageHeight
ImagesCollide
ImagesCollide2
ImageWidth
LoadAnimImage
LoadImage
LoadImageFont
LockImage
MidHandleImage
Plot
ResetCollisions
SetAlpha
SetBlend
SetClsColor
SetColor
SetHandle
SetImageFont
SetImageHandle
SetLineWidth
SetMaskColor
SetOrigin
SetRotation
SetScale
SetTransform
SetViewport
TextHeight
TextWidth
TileImage
UnlockImage
GLAdjustTexSize
GLDrawText
GLGraphics
GLGraphicsDriver
GLTexFromPixmap
GLMax2DDriver
ConvertPixmap
CopyPixmap
CreatePixmap
CreateStaticPixmap
LoadPixmap
MaskPixmap
PixmapFormat
PixmapHeight
PixmapPitch
PixmapPixelPtr
PixmapWidth
PixmapWindow
ReadPixel
ResizePixmap
WritePixel
XFlipPixmap
YFlipPixmap
LoadPixmapPNG
SavePixmapPNG
AppSuspended
AppTerminate
FlushKeys
FlushMouse
GetChar
KeyDown
KeyHit
MouseDown
MouseHit
MouseX
MouseY
MouseZ
WaitChar
WaitKey
WaitMouse
CreateRamStream
Rand
Rnd
RndDouble
RndFloat
RndSeed
SeedRnd
CreateSocketStream
SocketStreamSocket
BindSocket
CloseSocket
ConnectSocket
CreateTCPSocket
CreateUDPSocket
DottedIP
HostIp
HostIps
HostName
SocketAccept
SocketConnected
SocketListen
SocketLocalIP
SocketLocalPort
SocketReadAvail
SocketRemoteIP
SocketRemotePort
SQL_Close
SQL_Error
SQL_Exec
SQL_Open
StandardIOStream
Input
Print
CasedFileName
CloseStream
CopyBytes
CopyStream
Eof
FlushStream
LoadByteArray
LoadString
OpenStream
ReadByte
ReadDouble
ReadFloat
ReadInt
ReadLine
ReadLong
ReadShort
ReadStream
ReadString
SaveByteArray
SaveString
SeekStream
StreamPos
StreamSize
WriteByte
WriteDouble
WriteFloat
WriteInt
WriteLine
WriteLong
WriteShort
WriteStream
WriteString
Confirm
CurrentDate
CurrentTime
Delay
HideMouse
MilliSecs
MoveMouse
Notify
OpenURL
PollSystem
Proceed
RequestDir
RequestFile
ShowMouse
WaitSystem
CreateTimer
StopTimer
TimerTicks
WaitTimer
compress
compress2
uncompress

// types/constructs/keywords/etc.
KeyWords2: TBankStream
TBank
TList
TPixmap
TCStream
TStream
TStreamReadException
TStreamWrapper
TStreamWriteException
Matrix
Plane
Quaternion
Rectangle
Vector2
Vector3
TChannel
TSound
TAudioSample
TAudioSampleLoader
Abs
Abstract
And
Asc
Assert
Byte
Case
Catch
Chr
Const
Continue
Default
DefData
Delete
Double
EachIn
Else
ElseIf
End
EndExtern
EndFunction
EndIf
EndMethod
EndSelect
EndTry
EndType
EndWhile
Exit
Extends
Extern
False
Field
Final
Float
For
Forever
Framework
Function
Global
Goto
If
Import
Incbin
IncbinLen
IncbinPtr
Include
Int
Len
Local
Long
Max
Method
Min
Mod
Module
ModuleInfo
New
Next
Not
Null
Object
Or
Pi
Private
Ptr
Public
ReadData
Release
Repeat
RestoreData
Return
Sar
Select
Self
Sgn
Shl
Short
Shr
SizeOf
Step
Strict
String
Super
SuperStrict
Then
Throw
To
True
Try
Type
Until
Var
Varptr
Wend
While
EmitEventHook
TEvent
FlipHook
TLink
TListEnum
BaseLuaInterface
ScriptEngine
TPixmapLoader
TIO
TStreamException
TStreamFactory

StringBegChar:          "
StringEndChar:          "
MultilineStrings:       0
UsePreprocessor:        0
CurrLineHighlighted:    1

SpaceCol:               clWindowText $00885522
Keyword1Col:            $00FFF5C1 $00885522
Keyword2Col:            $00FFFFAA $00885522 B
Keyword3Col:            $00FFFFAA $00885522
IdentifierCol:          clWhite $00885522
CommentCol:             $0000EEFF $00885522
NumberCol:              $00D3FF37 $00885522
StringCol:              $0066FF00 $00885522
SymbolCol:              $00EEEEEE $00885522
PreprocessorCol:        clOlive $00885522
SelectionCol:           clAqua clTeal
CurrentLineCol:         clWhite $009C6936

OverrideTxtFgColor:     0

BlockAutoindent:        0
BlockBegStr:
BlockEndStr:
Keyword4Col:            clWindowText clWindow
Keyword5Col:            clWindowText clWindow
MatchedBracesCol:       clWindowText clWindow


This is a BlitzMax highlighter for the ConTEXT editor (I would not call it an IDE as it's too generic for the purpose). It includes some types/functions of my own, but that shouldn't be a problem. If it is, you can use this code to generate new keywords for the highlighter. Just build and run it in the BMax/doc/bmxmods/ folder and copy the appropriate list to each Keyword# category in the highlighter (lists are seperated by a line of ='s).

(Note: This is not clean code nor is it intended to be used for anything other than the purpose of getting a list of all keywords used by MaxIDE and sorting them into two categories)
in:TStream = ReadFile( "commands.txt" )
out:TStream = WriteFile( "cmdlist.txt" )

Local p:Int

Local keywords:TList = New TList
Type Keyword
	Field id
	Field name$

	Method Compare%( other:Object )
		Local o:Keyword = Keyword(other)
		Return id-o.id
	End Method
End Type

While Not in.Eof( )

	p = 2
	line$ = in.ReadLine( )
	line = line[..line.Find( "|" ) ]
	If line.Find( "(" ) > 0 Then
		line = line[..line.Find("(")]
		p = 1
	EndIf
	If line.Find( "[" ) > 0 Then
		line = line[..line.Find("[")]
		p = 1
	EndIf
	If line.Find( ":" ) > 0 Then
		line = line[..line.Find(":")]
		p = 1
	EndIf
	If "!#@$%".Find( line[line.Length-1..] ) > -1 Then
		line = line[..line.Length-1]
		p = 1
	EndIf
	If line.Find( " " ) > 0 Then
		line = line[..line.Find(" ")]
		p = 2
	EndIf
	Local k:Keyword = New Keyword
	k.id = p
	k.name = line
	keywords.AddLast( k )

Wend

keywords.Sort( )
p = Keyword(keywords.First( )).id
For Local j:Keyword = EachIn keywords
	if ( j.id <> p )
		out.WriteLine "==========================================================="
	endif
	out.WriteLine j.name
	p = j.id
Next

out.Close( )
in.Close( )


Thanks.
Is there a way to get conTEXT to change the keyword case? Example: endgraphics() - > EndGraphics()

No.

No?

That's what I said: no.

ConTEXT assumes you know how to type.

Ok.

Noel, by any chance do you have any environment options-> execute compiler output rules?
EXECUTE: c:\bmx\bin\bmk.exe
START IN: %p
PARAMETERS: makeapp -o "%F.debug" %f
COMPILER OUTPUT RULE: ???

Also, any way to get conTEXT to run the exe afterwards other than creating another execute key to do it?

Sorry for dredging this post.

Matt

Compiler output rule is [%n;%l;*]

And no.

Cheers ears, matey