This may help:
Window = CreateWindow("HTML Editor", 100, 100, 400, 300, 0)
Panel = CreatePanel(0, 0, ClientWidth(Window), ClientHeight(Window), Window)
TextArea = CreateTextArea(0, 0, ClientWidth(Panel), ClientHeight(Panel), Panel)
Timer = CreateTimer(100) ;100 ms
AreaText$ = "" ;TextArea Text
count = False
countNum% = 1
Tag$ = ""
Repeat
Select WaitEvent()
Case $803
End
Case $4001 ; Tick
Select EventSource()
Case Timer
tmp$ = TextAreaText$(TextArea) ; Grab Text
If tmp$ <> AreaText$ Then ; User has entered a character
tmp2$ = Right(tmp$, Len(tmp$) - Len(AreaText$)) ; Isolate new from old entry
If count = False ;If your not currently getting the HTML tag
If Instr(Lower(tmp2$), "<", 1) Then count = True ;If the character entered is <, start getting tag
Else If count = True ;Your are getting the HTML tag
If Instr(Lower(tmp2$), ">", 1) ;Is it the end tag?
countNum = countNum + 1 ;Increase the characters
count = False ;Stop counting
z = CheckTag(Tag$) ;Is it an HTML tag?
If z = True ;It is a HTML tag
FormatTextAreaText(TextArea, 255, 0, 0, 0, TextAreaLen(TextArea) - countNum, countNum) ;Higlight the Tag
End If
Tag$ = "" ;Reset Tag
countNum = 1 ;num of characters back to one
Else ;It's not the end tag
Tag$ = Tag$ + tmp2$ ;Add the chracter to the Tag
countNum = countNum + 1 ;Add 1 to the num of chars
End If
End If
AreaText$ = tmp$
EndIf
End Select
End Select
Forever
Function CheckTag(tagToCheck$)
tagToCheck$ = Upper(tagToCheck$)
a = ReadFile("files/tags.mltg")
Repeat
b$ = ReadLine(a)
c$ = "/" + b$ ;To see if it is an end tag
If b$ = tagToCheck$
Return True
Else If c$ = tagToCheck$
Return True
End If
Until Eof(a)
Return False
End Function
in the html file i put all the html tags i could find. There are problems with this though with backspaces. If you put <htmlk and backspace, it wont work when you put the > as the tag would be "htmlk". I hope that makes sense!
|