Nice work =)
I was playing around with it and added double clicking to select words/lines, if someone wants it.
add some needed fields to TEditControl
Field DoubleClickTiming:Int = 200
Field DoubleClickTimer:Int, GotFirstClick:Int
replace the EVENT_MOUSEUP in OnEvent()
Case EVENT_MOUSEUP
If event.data = 1 Then
If Not GotFirstClick Then
' start timer
GotFirstClick = True
DoubleClickTimer = MilliSecs() + DoubleClickTiming
Else
If DoubleClickTimer >= MilliSecs() Then
' execute actions
If event.x < 10 Then
HL(); Action("DBLCLKGT") ' gutter double clicked
Else
HL(); Action("DBLCLK") ' editor double clicked
EndIf
DoubleClickTimer = 0
GotFirstClick = False
Else
' start timer
GotFirstClick = True
DoubleClickTimer = MilliSecs() + DoubleClickTiming
EndIf
EndIf
MB1 = False
EndIf
Draw
add these new actions to Action()
Case "DBLCLK"
SelectWordAt( Line,Column)
Case "DBLCLKGT"
' select line
HLine = Line
HColumn = 0
Column = Dat[Line].Length - 1
and lastly, add this method for selecting words/identifiers
Method SelectWordAt:Int( ln:Int, col:Int)
Function IsIdentChar:Int( char:Byte)
Local chars:String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
For Local i:Int = 0 Until chars.Length
If chars[i] = char Then Return True
Next
Return False
EndFunction
If (ln < 0) Or (ln >= Dat.Length) Then Return False
Local s:String = Dat[ln]
Local l:Int,r:Int = s.Length-1
If s.Length <= 0 Then Return False
' find left edge
If col >= 1 Then
For i = col - 1 To 0 Step -1
If Not IsIdentChar( s[i]) Then
l = i
Exit
EndIf
Next
EndIf
' find right edge
If col < s.Length - 2 Then
For i = col + 1 Until s.LEngth
If Not IsIdentChar( s[i]) Then
r = i
Exit
EndIf
Next
EndIf
' select word
If l < r Then
HLine = ln
' make sure the selection is correct
If (l > 1) Or (Not IsIdentChar(s[l])) Then l :+ 1
If (r < s.Length-1) Or (Not IsIdentChar(s[r])) Then r :- 1
HColumn = l
Column = r
Return True
EndIf
Return False
EndMethod
im gonna play with this some more. Again, good work TeraBit =)