Code: Alles auswählen
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Threadspezifisch, leert den Rest einer Zeile
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
Procedure clear_current_line(*daten.struct_pure_multiline_code_editor)
Protected p.i
; ***
For p = *daten\length To 19999
*daten\strom[p]\color = 0
*daten\strom[p]\char = ""
*daten\strom[p]\pos = 0
Next
; ***
If IsThread(*daten)
KillThread(*daten)
EndIf
EndProcedure
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Ermittelt die aktuell angesteuerte Zeile
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
Procedure allocate_current_line(*daten.struct_pure_multiline_code_editor)
Protected p.i, s.s
; ***
*threaded_current_line = *daten
; ***
*daten\strom[0]\color = 0
*daten\strom[0]\char = ""
*daten\strom[0]\pos = 0
; ***
*daten\strom[1]\color = 0
*daten\strom[1]\char = ""
*daten\strom[1]\pos = 0
; ***
*daten\strom[2]\color = 0
*daten\strom[2]\char = ""
*daten\strom[2]\pos = 0
; ***
If *daten\content\lines()
*daten\index = *daten\position + *daten\toplimit
; ***
*daten\length = Len(s)
; ***
If IsThread(*daten)
KillThread(*daten)
EndIf
; ***
CreateThread( @clear_current_line(), *daten )
; ***
If *daten\index >= 0 And *daten\index < *daten\content\lines()
s = *daten\content\get(*daten\index)
; ***
If Trim(s)
*daten\length = 19999
; ***
For p = 1 To *daten\length
If p <= Len(s)
*daten\strom[p]\char = Mid( s, p, 1 )
Else
*daten\strom[p]\char = ""
EndIf
; ***
*daten\strom[p]\color = 0
*daten\strom[p]\pos = 0
; ***
If p > Len(s)
If *daten\strom[p]\char = ""
Break
EndIf
EndIf
Next
; ***
*daten\strom[0]\char = ""
; ***
*daten\length = Len(s) + 1
; ***
update_current_syntax( *daten )
Else
*daten\cursor = 1
*daten\length = 0
; ***
*daten\strom[0]\color = 0
*daten\strom[0]\char = ""
*daten\strom[0]\pos = 0
EndIf
EndIf
EndIf
EndProcedure
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Geht zu einer Zeile
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
Procedure goto_current_line(*daten.struct_pure_multiline_code_editor,w.i,h.i,currentUpdate.a=#False)
Protected ww.d, hh.i
; ***
If *daten\index >= 0
If *daten\index < *daten\content\lines()
*daten\position = *daten\index - *daten\toplimit
; ***
;Debug Str(*daten\position) + ":" + Str(*daten\index) + " > " + *daten\content\get(*daten\index)
allocate_current_line( *daten )
; ***
If IsImage( *daten\visbkg ) > 0
CopyImage( *daten\visbkg, *daten\tmpbkg )
EndIf
; ***
If *daten\justdraw = 0
*daten\justdraw = 1
; ***
If CreateImage( *daten\visbkg, w, h, 32, #PB_Image_Transparent ) And
StartDrawing( ImageOutput( *daten\visbkg ) )
; ***
DrawingMode( #PB_2DDrawing_AlphaBlend )
; ***
If IsFont(100):DrawingFont(FontID(100)):EndIf
; ***
If IsImage( *daten\tmpbkg )
DrawAlphaImage( ImageID( *daten\tmpbkg ), 0, 0 )
EndIf
; ***
DrawingMode( #PB_2DDrawing_AlphaChannel )
; ***
Box( 0, TextHeight("A") * *daten\position, w, TextHeight("A"), RGBA(0,0,0,0) )
; ***
StopDrawing()
; ***
CopyImage( *daten\visbkg, *daten\tmpbkg )
; ***
If currentUpdate
ww = 0
; ***
If CreateImage( *daten\curlin, w, 100, 32, #PB_Image_Transparent ) And
StartDrawing( ImageOutput( *daten\curlin ) )
If IsFont(100):DrawingFont(FontID(100)):EndIf
; ***
hh = TextHeight("A")
; ***
StopDrawing()
EndIf
; ***
If CreateImage( *daten\curlin, w, hh, 32, #PB_Image_Transparent ) And
StartDrawing( ImageOutput( *daten\curlin ) )
DrawingMode( #PB_2DDrawing_Transparent|#PB_2DDrawing_AlphaBlend )
; ***
If IsFont(100):DrawingFont(FontID(100)):EndIf
; ***
For p = 0 To *daten\length ;- 1
DrawText( ww, 0, *daten\strom[p]\char, opaque(*daten\strom[p]\color) )
; ***
*daten\strom[p]\pos = ww : ww + TextWidth(*daten\strom[p]\char)
Next
; ***
StopDrawing()
EndIf
EndIf
; ***
*daten\justdraw = 0
EndIf
EndIf
EndIf
EndIf
EndProcedure
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Hintergrundbild zeichnen
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
Procedure update_content(*daten.struct_pure_multiline_code_editor,id,w.i,h.i)
Protected p.i, a.a = 0, tw.i
; ***
If IsGadget(id)
If *daten\condir <> 0
allocate_current_line( *daten )
; ***
If *daten\theight < 8
*daten\theight = 8
EndIf
; ***
If CreateImage(*daten\curlin,w,*daten\theight) And StartDrawing(ImageOutput(*daten\curlin))
Box( 0, 0, w, h, $FFFFFF ) ; VORÜBRGEHEND
; ***
If IsFont(100)
DrawingFont( FontID(100) )
EndIf
; ***
DrawingMode( #PB_2DDrawing_Transparent )
; ***
If evt = #PB_EventType_Input
*daten\theight = TextHeight("A")
; ***
*daten\vislimit = (h / *daten\theight) - 1
; ***
If *daten\vislimit <= 0
*daten\vislimit = 1
EndIf
EndIf
; ***
For p = 0 To *daten\length -1
If p = 0
DrawText( 0, 0, *daten\strom[p]\char, *daten\strom[p]\color )
Else
DrawText( tw, 0, *daten\strom[p]\char, *daten\strom[p]\color )
EndIf
; ***
tw + TextWidth(*daten\strom[p]\char)
Next
; ***
StopDrawing()
EndIf
EndIf
; ***
If IsImage(*daten\visbkg)
a = 1
CopyImage( *daten\visbkg, *daten\tmpbkg )
EndIf
; ***
If CreateImage(*daten\visbkg,w,h) And StartDrawing(ImageOutput(*daten\visbkg))
If a = 0
; Es wird das erste Mal gezeichnet, deshalb kommt auch der
; vollständige Hintergrund gleich mit
Box( 0, 0, w, h, *daten\color_bkg )
EndIf
; ***
Select *daten\condir
Case 0 ; Normal
If a = 1
If IsImage(*daten\tmpbkg)
DrawImage( ImageID(*daten\tmpbkg), 0, 0 )
EndIf
EndIf
; ***
If IsImage(*daten\curlin)
DrawImage( ImageID(*daten\curlin), 0, *daten\position * *daten\theight )
EndIf
Case 1 ; Rauf
If a = 1
If IsImage(*daten\tmpbkg)
DrawImage( ImageID(*daten\tmpbkg), 0, *daten\theight )
EndIf
EndIf
; ***
If IsImage(*daten\curlin)
DrawImage( ImageID(*daten\curlin), 0, 0 )
EndIf
Case 2 ; Runter
If a = 1
If IsImage(*daten\tmpbkg)
DrawImage( ImageID(*daten\tmpbkg), 0, - *daten\theight )
EndIf
EndIf
; ***
If IsImage(*daten\curlin)
DrawImage( ImageID(*daten\curlin), 0, h - *daten\theight )
EndIf
EndSelect
; ***
*daten\condir = 0
; ***
StopDrawing()
EndIf
EndIf
EndProcedure
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Aktuelle Zeile in ein echtes String umwandeln
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
Procedure.s getInputStringLine(*daten.struct_pure_multiline_code_editor)
Protected p.i, s.s
; ***
For p = 0 To *daten\length
s + *daten\strom[p]\char
Next
; ***
ProcedureReturn s
EndProcedure
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Markierungsfeldumfeld leeren
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
Procedure clearImageArea(*daten.struct_pure_multiline_code_editor,id,w,h)
Protected mmx.i
; ***
y = *daten\markstart + *daten\toplimit
h = *daten\markclose + *daten\toplimit
; ***
x = *daten\markCursorFrom
w = *daten\markCursorInto
; ***
Debug "Y: " + Str(y) + " | H: " + Str(h) + " | X: " + Str(x) + " | W: " + Str(w)
If IsGadget(id)
If StartDrawing(ImageOutput(*daten\visbkg))
If IsFont(100)
DrawingFont( FontID(100) )
EndIf
; ***
mmx = ImageWidth(*daten\visbkg) - (*daten\markCursorInto - *daten\markCursorFrom)
; ***
Box( ImageWidth(*daten\tempor) + 6 + *daten\markCursorFrom, *daten\markstart * *daten\theight, w - mmx, (*daten\markclose - *daten\markstart) * *daten\theight, *daten\color_bkg )
; ***
StopDrawing()
EndIf
EndIf
EndProcedure
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Markierungsstart und Richtungskorrektur setzen, sobald die Markierung
; mittels Tastatur durchgeführt wird
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
Procedure setKeyMarkStart(key.i, *daten.struct_pure_multiline_code_editor)
Protected p.i, tww.i, cc.i = *daten\cursor
; ***
Select key
Case #pure_keycode_left
cc + 1
Case #pure_keycode_right
cc - 1
EndSelect
; ***
If StartDrawing(ImageOutput(*daten\curlin))
If IsFont(100)
DrawingFont( FontID(100) )
EndIf
; ***
DrawingMode( #PB_2DDrawing_Transparent )
; ***
For p = 0 To 19999
If cc = p
Break
EndIf
; ***
*daten\markpos = p
*daten\markCursorFrom = tww
; ***
If *daten\strom[p]\char
tww + TextWidth(*daten\strom[p]\char)
Else
tww + TextWidth(" ")
EndIf
Next
; ***
StopDrawing()
; ***
*daten\marklen = *daten\markpos
*daten\markCursorInto = *daten\markCursorFrom
; ***
;Debug Str(*daten\markpos) + " -> " + Str(*daten\markCursorFrom)
*daten\mark = #True
*daten\markmode = #False
EndIf
EndProcedure
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Realisiert den Syntax-Editor, samt Eingabe und Maus-Events
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
#ControlUpMore = #PB_Canvas_Command
CompilerElse
#ControlUpMore = #PB_Canvas_Control
CompilerEndIf
Procedure update(*daten.struct_pure_multiline_code_editor,id.i,evt.i,key.i,inp.i,mx.i,my.i)
If IsGadget(id)
Protected w.i, h.i, p.i, n.i, tw.d, cc.s, du.a = #False, sb.a = #False, top.i, pos.i
Protected tt.i, tx.s, ti.i, m.i, tww.d, mmx.i, emi.a = 0, gi.i, gu.i, tps.s = "", dd.d
Protected tix.i, tiy.i, tiw.i, tih.i
; ***
w = GadgetWidth(id)
h = GadgetHeight(id)
; ***
Select evt
Case #PB_EventType_LeftButtonDown, #PB_EventType_RightButtonDown, #PB_EventType_MiddleButtonDown
;{
mmx = -90000
; ***
*daten\markdif = 0
; ***
If *daten\mark = #True
tix = ImageWidth(*daten\tempor) + 6 + *daten\markCursorFrom
tiy = *daten\markstart * *daten\theight
tiw = w - ImageWidth(*daten\visbkg) - (*daten\markCursorInto - *daten\markCursorFrom)
tih = (*daten\markclose - *daten\markstart) * *daten\theight
; ***
;Box( ImageWidth(*daten\tempor) + 6 + *daten\markCursorFrom, *daten\markstart * *daten\theight, w - mmx, (*daten\markclose - *daten\markstart) * *daten\theight, *daten\color_marked_bkg )
If mx >= tix And mx <= tix + tiw And my >= tiy And my <= tiy + tih
; nix
Else
*daten\mark = #False
*daten\markmode = #False
EndIf
EndIf
; ***
For m = 0 To *daten\vislimit
If my >= ( m * *daten\theight ) And my <= ( m * *daten\theight ) + *daten\theight
*daten\index = *daten\position + *daten\toplimit
; ***
update_current_syntax(*daten)
; ***
update_content( *daten, id, w, h )
; ***
*daten\content\set( *daten\index, getInputStringLine(*daten) )
; ***
*daten\position = m
; ***
*daten\index = *daten\position + *daten\toplimit
; ***
allocate_current_line( *daten )
; ***
mmx = mx - ImageWidth(*daten\tempor)
; ***
If mmx < 0
*daten\cursor = 1
Else
If StartDrawing(ImageOutput(*daten\curlin))
If IsFont(100)
DrawingFont( FontID(100) )
EndIf
; ***
DrawingMode( #PB_2DDrawing_Transparent )
; ***
For p = 0 To *daten\length -1
If mmx >= tww And mmx <= tww + TextWidth(*daten\strom[p]\char)
*daten\cursor = p
; ***
emi = 1
; ***
*daten\markCursorFrom = tww
; ***
*daten\markpos = p
; ***
Break
EndIf
; ***
tww + TextWidth(*daten\strom[p]\char)
Next
; ***
StopDrawing()
; ***
If emi = 0
*daten\cursor = *daten\length
EndIf
EndIf
EndIf
; ***
du = #True
; ***
Break
EndIf
Next
; ***
If mx <= ImageWidth(*daten\tempor)
*daten\markpos = 0
*daten\marklen = 19999
*daten\markCursorFrom = 0
*daten\markCursorInto = ImageWidth(*daten\visbkg) - ImageWidth(*daten\tempor) - 6
EndIf
; ***
If mmx <> -90000
If evt = #PB_EventType_LeftButtonDown
*daten\mark = #True
; ***
*daten\markrel = *daten\position
*daten\markrow = *daten\index
; ***
*daten\markstart = *daten\markrel
*daten\markclose = *daten\markrel
EndIf
EndIf
;}
Case #PB_EventType_LeftButtonUp
;{
*daten\markmode = #True
ProcedureReturn
;}
Case #PB_EventType_MouseMove
;{
If *daten\mark = #True And *daten\markmode = #False
mmx = mx - ImageWidth(*daten\tempor) : tww = 0
; ***
If StartDrawing(ImageOutput(*daten\curlin))
If IsFont(100)
DrawingFont( FontID(100) )
EndIf
; ***
DrawingMode( #PB_2DDrawing_Transparent )
; ***
For p = 0 To 19999
If tww >= w - ImageWidth(*daten\tempor)
Break
EndIf
; ***
If mmx >= tww And mmx <= tww + TextWidth(*daten\strom[p]\char)
*daten\markCursorInto = tww
; ***
*daten\marklen = p
; ***
Break
EndIf
; ***
If *daten\strom[p]\char
tww + TextWidth(*daten\strom[p]\char)
Else
tww + TextWidth(" ")
EndIf
Next
; ***
StopDrawing()
EndIf
; ***
mmx = -90000
; ***
tww = 0
; ***
For m = 0 To *daten\vislimit
If my >= ( m * *daten\theight ) And my <= ( m * *daten\theight ) + *daten\theight
mmx = m
; ***
Break
EndIf
Next
; ***
If mmx <> -90000
If mmx >= *daten\markrel
*daten\markstart = *daten\markrel
*daten\markclose = mmx + 1
Else
*daten\markstart = mmx
*daten\markclose = *daten\markrel + 1
EndIf
EndIf
Else
ProcedureReturn
EndIf
;}
Case #PB_EventType_MouseWheel
;{
;}
Case #PB_EventType_Input
;{
If Not GetGadgetAttribute(id, #PB_Canvas_Modifiers) & #ControlUpMore
If inp = 32 Or inp = 9 Or inp = 10 Or inp = 13
If *daten\curlen
If *daten\curpos >= 0 And *daten\curpos < *daten\length
cc = ""
; ***
update_current_token( *daten, *daten\curpos, *daten\curlen )
EndIf
EndIf
; ***
*daten\curpos = *daten\cursor + 1
*daten\curlen = 0
ElseIf inp <> 32 And inp <> 9
*daten\curlen + 1
EndIf
; ***
If *daten\cursor = 0
If *daten\length
p = *daten\length
; ***
If p >= 0 And p < 20000
Repeat
*daten\strom[p+1]\char = *daten\strom[p]\char
*daten\strom[p+1]\color = *daten\strom[p]\color
*daten\strom[p]\color = 0
; ***
p - 1
Until p = 0
EndIf
EndIf
; ***
*daten\strom[0]\char = Chr(inp)
ElseIf *daten\cursor = *daten\length
*daten\strom[*daten\cursor]\char = Chr(inp)
Else
p = *daten\length
; ***
Repeat
If p >= 0 And p <= 19998
*daten\strom[p+1]\char = *daten\strom[p]\char
*daten\strom[p+1]\color = *daten\strom[p]\color
Else
Break
EndIf
; ***
p - 1
Until p = *daten\cursor -1
; ***
*daten\strom[*daten\cursor]\char = Chr(inp)
*daten\strom[*daten\cursor]\color = 0
EndIf
; ***
*daten\cursor + 1
*daten\length + 1
; ***
*daten\cursorDisplay = #True
; ***
update_current_syntax(*daten)
; ***
*daten\mark = #False
*daten\markmode = #False
; ***
*daten\markrel = *daten\position
*daten\markrow = *daten\index
; ***
*daten\markstart = *daten\markrel
*daten\markclose = *daten\markrel
; ***
du = #True
EndIf
;}
Case #PB_EventType_KeyUp
;{
If *daten\intellivis = #False
If *daten\mark = #True
*daten\markmode = #True
; ***
*daten\markdif = 1
; ***
;*daten\markrel = *daten\position
;*daten\markrow = *daten\index
; ***
*daten\markstart = *daten\markrel
*daten\markclose = *daten\markrel + 1
; ***
*daten\index = *daten\position + *daten\toplimit
; ***
update_current_syntax(*daten)
; ***
update_content( *daten, id, w, h )
; ***
*daten\content\set( *daten\index, getInputStringLine(*daten) )
EndIf
EndIf
;}
Case #PB_EventType_KeyDown
Select key
Case #pure_keycode_tabbed
;{
If *daten\cursor < 19998 - 1
*daten\length + 1
*daten\cursor + 1
*daten\strom[*daten\cursor]\char = " "
*daten\strom[*daten\cursor]\color = 0
*daten\strom[*daten\cursor]\pos = 0
; ***
If *daten\cursor < 19998 - 1
*daten\length + 1
*daten\cursor + 1
*daten\strom[*daten\cursor]\char = " "
*daten\strom[*daten\cursor]\color = 0
*daten\strom[*daten\cursor]\pos = 0
; ***
If *daten\cursor < 19998 - 1
*daten\length + 1
*daten\cursor + 1
*daten\strom[*daten\cursor]\char = " "
*daten\strom[*daten\cursor]\color = 0
*daten\strom[*daten\cursor]\pos = 0
; ***
SetActiveGadget( id )
; ***
du = #True
EndIf
EndIf
EndIf
;}
Case #pure_keycode_pos
*daten\cursor = 1
Case #pure_keycode_end
*daten\cursor = *daten\length
Case #pure_keycode_up
;{
If *daten\intellivis = #False
If *daten\position = 0 And *daten\toplimit = 0
ProcedureReturn
EndIf
; ***
*daten\index = *daten\position + *daten\toplimit
; ***
update_current_syntax(*daten)
; ***
update_content( *daten, id, w, h )
; ***
*daten\content\set( *daten\index, getInputStringLine(*daten) )
; ***
*daten\position - 1
; ***
If *daten\position < 0
*daten\toplimit - 1
*daten\position = 0
; ***
If *daten\toplimit < 0
*daten\toplimit = 0
EndIf
; ***
*daten\condir = 1
update_content( *daten, id, w, h )
; ***
sb = #True
EndIf
; ***
*daten\index = *daten\position + *daten\toplimit
; ***
allocate_current_line( *daten )
; ***
If *daten\movetolast = #True
*daten\movetolast = #False
; ***
*daten\cursor = *daten\length
EndIf
; ***
du = #True
Else
*daten\intellicur - 1
; ***
If *daten\intellicur < 0
*daten\intellicur = 0
EndIf
EndIf
;}
Case #pure_keycode_enter, #pure_keycode_down
;{
If *daten\intellivis = #False
*daten\index = *daten\position + *daten\toplimit
; ***
update_current_syntax(*daten)
; ***
update_content( *daten, id, w, h )
; ***
*daten\content\set( *daten\index, getInputStringLine(*daten) )
; ***
If *daten\index > *daten\content\lines() -2
If key = #pure_keycode_down
ProcedureReturn
EndIf
EndIf
; ***
*daten\position + 1
; ***
If *daten\position > *daten\vislimit
*daten\toplimit + 1
; ***
If *daten\toplimit > *daten\content\length() - 1 - *daten\vislimit
*daten\toplimit = *daten\content\length() - 1 - *daten\vislimit
*daten\position = *daten\vislimit
Else
*daten\position - 1
EndIf
; ***
*daten\condir = 2
update_content( *daten, id, w, h )
; ***
sb = #True
EndIf
; ***
*daten\index = *daten\position + *daten\toplimit
; ***
du = #True
; ***
If key = #pure_keycode_enter
*daten\content\add(" ")
; ***
*daten\cursor = 1
ElseIf key = #pure_keycode_down
If *daten\index > *daten\content\length() - 1
*daten\index = *daten\content\length() - 1
*daten\toplimit = *daten\content\length() - *daten\vislimit
*daten\position = *daten\index - *daten\toplimit
EndIf
EndIf
; ***
allocate_current_line( *daten )
Else
If key = #pure_keycode_enter
If *daten\intellimar
tps + " "
EndIf
; ***
tps + *daten\intellitok
; ***
*daten\intellivis = 12
; ***
*daten\intellitok = ""
; ***
*daten\index = *daten\position + *daten\toplimit
; ***
*daten\content\set( *daten\index, getInputStringLine(*daten) + tps )
; ***
*daten\cursor + Len(tps)
*daten\length + Len(tps)
; ***
allocate_current_line( *daten )
; ***
update_current_syntax(*daten)
; ***
update_content( *daten, id, w, h )
; ***
du = #True
ElseIf key = #pure_keycode_down
*daten\intellicur + 1
; ***
If *daten\intellicur > *daten\intellitot -1
*daten\intellicur = *daten\intellitot -1
EndIf
EndIf
EndIf
;}
Case #pure_keycode_delete
;{
If *daten\cursor = 0
; Rauf auf die obere Zeile oder ignorieren
ElseIf *daten\cursor = *daten\length
*daten\strom[*daten\cursor]\char = ""
*daten\strom[*daten\cursor]\color = 0
*daten\strom[*daten\cursor]\pos = 0
*daten\cursor -1
*daten\length -1
Else
For p = *daten\cursor To *daten\length
*daten\strom[p-1]\char = *daten\strom[p]\char
*daten\strom[p-1]\color = *daten\strom[p]\color
*daten\strom[p-1]\pos = *daten\strom[p]\pos
Next
; ***
*daten\strom[*daten\length]\char = ""
*daten\strom[*daten\length]\color = 0
*daten\strom[*daten\length]\pos = 0
; ***
*daten\cursor -1
*daten\length -1
EndIf
; ***
If *daten\cursor = 1
If *daten\length <= 1
*daten\strom[0]\char = ""
*daten\strom[0]\color = 0
*daten\strom[0]\pos = 0
EndIf
EndIf
; ***
du = #True
;}
Case #pure_keycode_left
;{
If *daten\intellivis = #False
If *daten\cursor <= 1
*daten\movetolast = #True
update(*daten,id,#PB_EventType_KeyDown,#pure_keycode_up,0,0,0)
ProcedureReturn
Else
*daten\cursor - 1
; ***
If *daten\cursor < 0
*daten\cursor = 0
EndIf
; ***
*daten\curpos = *daten\cursor
; ***
du = #True
EndIf
; ***
;setKeyMarkStart(*daten)
Else
*daten\intellivis = 12
EndIf
;}
Case #pure_keycode_right
;{
If *daten\intellivis = #False
If *daten\cursor = *daten\length
update(*daten,id,#PB_EventType_KeyDown,#pure_keycode_down,0,0,0)
ProcedureReturn
Else
*daten\cursor + 1
; ***
If *daten\cursor > *daten\length
*daten\cursor = *daten\length
EndIf
; ***
*daten\curpos = *daten\cursor
; ***
du = #True
EndIf
; ***
;setKeyMarkStart(*daten)
Else
*daten\intellivis = 12
EndIf
;}
Case #pure_keycode_escape, #pure_keycode_space
;{
If *daten\intellivis = #True
*daten\intellivis = 12
EndIf
;}
EndSelect
; ***
If GetGadgetAttribute(id, #PB_Canvas_Modifiers) & #ControlUpMore
Select key
Case Asc("c"), Asc("C") ; Kopieren
ClearClipboard()
SetClipboardText(getMarkedText(*daten))
Case Asc("x"), Asc("X") ; Schneiden
ClearClipboard()
SetClipboardText(getMarkedText(*daten))
clearMarkedText(*daten)
clearImageArea(*daten,id,w,h)
Case Asc("v"), Asc("V") ; Einfügen
Debug "Paste"
Case Asc("a"), Asc("A") ; Alles markieren
Debug "Select all"
EndSelect
ElseIf GetGadgetAttribute(id, #PB_Canvas_Modifiers) & #PB_Canvas_Shift
tww = 0
; ***
Select key
Case #pure_keycode_up
If *daten\mark = #True
*daten\markstart - 1
; ***
If *daten\markstart < 0
*daten\markstart = 0
Else
*daten\markclose = *daten\markrel + 1
; ***
If *daten\markclose > *daten\vislimit
*daten\markclose = *daten\vislimit
EndIf
EndIf
EndIf
Case #pure_keycode_down
If *daten\mark = #True
*daten\markclose + 1
; ***
If *daten\markclose > *daten\vislimit
*daten\markclose = *daten\vislimit
Else
*daten\markstart = *daten\markrel
; ***
If *daten\markstart < 0
*daten\markstart = 0
EndIf
EndIf
EndIf
Case #pure_keycode_left, #pure_keycode_right
If *daten\mark = #False
setKeyMarkStart(key,*daten)
; ***
*daten\markrel = *daten\position
*daten\markrow = *daten\index
Else;If *daten\mark = #True And *daten\markmode = #False
If StartDrawing(ImageOutput(*daten\curlin))
If IsFont(100)
DrawingFont( FontID(100) )
EndIf
; ***
DrawingMode( #PB_2DDrawing_Transparent )
; ***
For p = 0 To 19999
If tww >= w - ImageWidth(*daten\tempor)
Break
EndIf
; ***
If *daten\cursor = p
Break
EndIf
; ***
*daten\marklen = p
*daten\markCursorInto = tww
; ***
If *daten\strom[p]\char
tww + TextWidth(*daten\strom[p]\char)
Else
tww + TextWidth(" ")
EndIf
Next
; ***
StopDrawing()
EndIf
EndIf
EndSelect
; ***
tww = 0
Else
*daten\mark = #False
*daten\markmode = #False
EndIf
EndSelect
; ***
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Cursor korrigieren
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; ***
;{
If *daten\cursor <= 0
*daten\cursor = 1
EndIf
; ***
If *daten\length < *daten\cursor
*daten\length = *daten\cursor
EndIf
;}
; ***
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Zeilennummernblock
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; ***
;{
If *daten\theight = 0
sb = #True
EndIf
; ***
If sb
du = #True
; ***
If CreateImage(*daten\tempor,w,h) And StartDrawing(ImageOutput(*daten\tempor))
If IsFont(100)
DrawingFont( FontID(100) )
EndIf
; ***
DrawingMode( #PB_2DDrawing_Transparent )
; ***
*daten\theight = TextHeight("A")
; ***
*daten\vislimit = (h / *daten\theight) - 1
; ***
If *daten\vislimit <= 0
*daten\vislimit = 1
EndIf
; ***
ti = TextWidth(Str(*daten\content\lines())) + 60
; ***
StopDrawing()
EndIf
; ***
If CreateImage(*daten\tempor,ti,h) And StartDrawing(ImageOutput(*daten\tempor))
If IsFont(100)
DrawingFont( FontID(100) )
EndIf
; ***
DrawingMode( #PB_2DDrawing_Transparent )
; ***
Box( 0, 0, ti, h, *daten\color_number_block_bkg )
; ***
For n = 0 To *daten\vislimit + 2
tx = Str(n + *daten\toplimit + 1)
; ***
DrawText( ti - 50 - TextWidth(tx), n * *daten\theight, tx, *daten\color_number_block_txt )
Next
; ***
StopDrawing()
EndIf
EndIf
;}
; ***
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Aktuelle Zeile zeichnen
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; ***
;{
If du
*daten\lastkey = ""
; ***
If CreateImage(*daten\curlin,w,*daten\theight) And StartDrawing(ImageOutput(*daten\curlin))
Box( 0, 0, w, h, $FFFFFF ) ; VORÜBRGEHEND
; ***
If IsFont(100)
DrawingFont( FontID(100) )
EndIf
; ***
DrawingMode( #PB_2DDrawing_Transparent )
; ***
If evt = #PB_EventType_Input
*daten\theight = TextHeight("A")
; ***
*daten\vislimit = (h / *daten\theight) - 1
; ***
If *daten\vislimit <= 0
*daten\vislimit = 1
EndIf
EndIf
; ***
For p = 0 To *daten\length -1
If p = 0
DrawText( 0, 0, *daten\strom[p]\char, *daten\strom[p]\color )
Else
DrawText( tw, 0, *daten\strom[p]\char, *daten\strom[p]\color )
EndIf
; ***
If *daten\strom[p]\char = " "
*daten\lastkey = ""
Else
*daten\lastkey + *daten\strom[p]\char
EndIf
; ***
*daten\strom[p]\pos = tw
; ***
tw + TextWidth(*daten\strom[p]\char)
; ***
If p = *daten\cursor -1
pos = tw
EndIf
Next
; ***
StopDrawing()
EndIf
EndIf
;}
; ***
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; CanvasGadget aktualisieren
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; ***
;{
top = *daten\position * *daten\theight
; ***
If du
*daten\curstate = pos + ImageWidth(*daten\tempor) + 6
EndIf
; ***
If StartDrawing(CanvasOutput(id))
;{ Abbilder für die Darstellung
Box( 0, 0, w, h, *daten\color_bkg )
; ***
If IsFont(100)
DrawingFont( FontID(100) )
EndIf
; ***
If IsImage(*daten\tempor)
DrawImage( ImageID(*daten\tempor), 0, 0 )
EndIf
; ***
If IsImage(*daten\visbkg)
DrawImage( ImageID(*daten\visbkg), ImageWidth(*daten\tempor) + 6, 0 )
EndIf
; ***
If IsImage(*daten\curlin)
DrawImage( ImageID(*daten\curlin), ImageWidth(*daten\tempor) + 6, top )
EndIf
; ***
If *daten\cursorDisplay; And *daten\intellivis = #False
Box( *daten\curstate, top, 2, *daten\theight, 0 )
EndIf
; ***
Box( ImageWidth(*daten\tempor) - 50 + 4, top, 46, *daten\theight, *daten\color_number_block_active )
;}
; ***
;{ Markierung zeichnen
DrawingMode( #PB_2DDrawing_Transparent )
; ***
If *daten\mark = #True
If *daten\markstart * *daten\theight - (*daten\markclose - *daten\markstart) * *daten\theight <> 6
Box( ImageWidth(*daten\tempor) - 50 + 4, *daten\markstart * *daten\theight, 46, (*daten\markclose - *daten\markstart) * *daten\theight, *daten\color_number_block_active )
; ***
DrawingMode( #PB_2DDrawing_AlphaBlend )
; ***
mmx = ImageWidth(*daten\visbkg) - (*daten\markCursorInto - *daten\markCursorFrom)
; ***
Box( ImageWidth(*daten\tempor) + 6 + *daten\markCursorFrom, *daten\markstart * *daten\theight, w - mmx, (*daten\markclose - *daten\markstart) * *daten\theight, *daten\color_marked_bkg )
; ***
DrawingMode( #PB_2DDrawing_Outlined )
; ***
Box( ImageWidth(*daten\tempor) + 6 + *daten\markCursorFrom, *daten\markstart * *daten\theight, w - mmx, (*daten\markclose - *daten\markstart) * *daten\theight, *daten\color_marked_border )
EndIf
EndIf
;}
; ***
;{ Cursor
Box( ImageWidth(*daten\tempor), 0, 6, h, *daten\color_bkg )
;}
; ***
; DIESEN PART IN EIN THREAD AUSLAGERN!!!
;{ Intellisence*
If *daten\intellivis = 12
*daten\intellivis = #False
ElseIf evt = #PB_EventType_KeyDown Or *daten\intellivis = #True
If key = 46 Or *daten\intellivis = #True Or TLCase(*daten\lastkey) = "belirle" Or TLCase(*daten\lastkey) = "dizilim" Or TLCase(*daten\lastkey) = "değişken"
If *daten\intellivis = #False
*daten\intellivis = #True
*daten\intellicur = 0
EndIf
; ***
If *daten\lastkey And *daten\intellisence And *daten\comment = 0 And *daten\stringi = 0
For p = 0 To *daten\intellisence\cnt -1
For x = 0 To *daten\intellisence\lst[p]\groupkeys\lines() -1
If Trim(TLCase(*daten\intellisence\lst[p]\groupkeys\get(x))) = Trim(TLCase(*daten\lastkey))
*daten\intelliLastWidth = *daten\intellisence\lst[p]\width + 16
; ***
If *daten\curstate + *daten\intelliLastWidth > w
*daten\curstate = w - *daten\intelliLastWidth
EndIf
; ***
If top > h - (4 * *daten\theight) - 16
top = h - (4 * *daten\theight) - 16
EndIf
; ***
Box( *daten\curstate + 10, top, *daten\intellisence\lst[p]\width + 6, (4 * *daten\theight) + 6, *daten\color_intelli_background )
; ***
DrawingMode( #PB_2DDrawing_Outlined )
; ***
Box( *daten\curstate + 10, top, *daten\intellisence\lst[p]\width + 5, (4 * *daten\theight) + 5, *daten\color_intelli_dborder )
Box( *daten\curstate + 10 + 1, top + 1, *daten\intellisence\lst[p]\width + 5, (4 * *daten\theight) + 5, *daten\color_intelli_lborder )
Box( *daten\curstate + 10, top, *daten\intellisence\lst[p]\width + 6, (4 * *daten\theight) + 6, *daten\color_intelli_border )
; ***
DrawingMode( #PB_2DDrawing_Transparent )
; ***
m = 0
; ***
*daten\intellimar = *daten\intellisence\lst[p]\space
; ***
*daten\intellitot = *daten\intellisence\lst[p]\content\lines()
; ***
ti = *daten\intellicur
; ***
If ti > *daten\intellitot - 4
ti = *daten\intellitot - 4
EndIf
; ***
For n = ti To ti + 3
If n = *daten\intellicur
Box( *daten\curstate + 13, top + 3 + (m * *daten\theight), *daten\intellisence\lst[p]\width, *daten\theight, *daten\color_intelli_sel_bkg )
DrawText( *daten\curstate + 10 + 6, top + 3 + (m * *daten\theight), *daten\intellisence\lst[p]\content\get(n), *daten\color_intelli_sel_txt )
*daten\intellitok = *daten\intellisence\lst[p]\content\get(n)
Else
DrawText( *daten\curstate + 10 + 6, top + 3 + (m * *daten\theight), *daten\intellisence\lst[p]\content\get(n), *daten\color_intelli_text )
EndIf
m + 1
Next
; ***
Break
EndIf
Next
Next
EndIf
EndIf
EndIf
;}
; ***
StopDrawing()
EndIf
;}
EndIf
EndProcedure
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
; Test
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
ExamineDesktops()
OpenWindow(#fenster,0,0,800,700,"Eingabe",
#PB_Window_SystemMenu|#PB_Window_Invisible)
CanvasGadget(#feld,0,0,800,700,#PB_Canvas_Keyboard)
SetActiveGadget(#feld)
ResizeWindow(#fenster,DesktopWidth(0)-800,
DesktopHeight(0)-800,800,700)
StickyWindow(#fenster,1)
HideWindow(#fenster,0)
AddWindowTimer(#fenster,#fenster,400)
Global ib.struct_intellisence_list
; ***
ib\cnt = 0
keyw.editor_dataset = editor_dataset()
mich.struct_pure_multiline_code_editor
mich\intellisence = ib
mich\content = editor_dataset()
For vi = 0 To 99
mich\content\add( "" )
Next
mich\color_comment = RGB( 147, 133, 148 )
mich\color_string = RGB( 106, 144, 166 )
mich\color_number = RGB( 204, 51, 153 )
mich\color_operator = RGB( 170, 148, 84 );RGB( 153, 51, 255 );RGB( 118, 92, 163 )
mich\color_bkg = RGB( 255, 255, 255 )
mich\color_selbkg = RGB( 238, 238, 238 )
mich\color_errorbkg = RGB( 239, 207, 203 )
mich\color_number_block_active = RGB( 228, 228, 228 )
mich\color_number_block_bkg = RGB( 238, 238, 238 );RGB( 154, 149, 166 );RGB( 137, 121, 158 );RGB( 98, 62, 133 )
mich\color_number_block_txt = RGB( 154, 149, 166 );RGB(255,255,255)
mich\color_intelli_background = RGB( 238, 238, 238 )
mich\color_intelli_border = RGB(140,150,160)
mich\color_intelli_lborder = RGB(245,248,251)
mich\color_intelli_dborder = RGB(160,170,180)
mich\color_intelli_text = 0
mich\color_intelli_sel_bkg = RGB( 0, 153, 204 )
mich\color_intelli_sel_txt = RGB( 243, 255, 255 )
mich\color_marked_border = RGB( 0, 153, 204 )
mich\color_marked_bkg = RGBA( 0, 153, 204, 20 )
mich\intellivis = #False
c = RGB( 51, 153, 204 );RGB( 36, 134, 255 )
keyw\add( "Define", c )
keyw\add( "Global", c )
keyw\add( "Protected", c )
keyw\add( "Static", c )
keyw\add( "Threaded", c )
keyw\add( "ElseIf", c )
keyw\add( "Else", c )
keyw\add( "EndIf", c )
keyw\add( "If", c )
keyw\add( "ForEach", c )
keyw\add( "For", c )
keyw\add( "Next", c )
keyw\add( "Break", c )
keyw\add( "Repeat", c )
keyw\add( "Forever", c )
keyw\add( "Until", c )
keyw\add( "EndProcedure", c )
keyw\add( "Procedure", c )
keyw\add( "EndInterface", c )
keyw\add( "Interface", c )
keyw\add( "EndStructure", c )
keyw\add( "Structure", c )
keyw\add( "ReDim", c )
keyw\add( "Dim", c )
keyw\add( "XIncludeFile", c )
keyw\add( "IncludeFile", c )
keyw\add( "Debug", c )
keyw\add( "CompilerElseIf", c )
keyw\add( "CompilerElse", c )
keyw\add( "CompilerIf", c )
keyw\add( "CompilerEndIf", c )
keyw\add( "And", c )
keyw\add( "Not", c )
keyw\add( "Or", c )
keyw\add( "CompilerEndSelect", c )
keyw\add( "CompilerCase", c )
keyw\add( "CompilerDefault", c )
keyw\add( "CompilerSelect", c )
keyw\add( "EndSelect", c )
keyw\add( "Case", c )
keyw\add( "Default", c )
keyw\add( "Select", c )
; ***
c = RGB( 102, 102, 153 )
keyw\add( "Len", c )
keyw\add( "Mid", c )
keyw\add( "Left", c )
keyw\add( "Right", c )
keyw\add( "Trim", c )
keyw\add( "LTrim", c )
keyw\add( "RTrim", c )
keyw\add( "ReplaceString", c )
keyw\add( "FindString", c )
keyw\add( "CountString", c )
keyw\add( "ReverseString", c )
keyw\add( "LCase", c )
keyw\add( "UCase", c )
keyw\add( "StrD", c )
keyw\add( "StrF", c )
keyw\add( "Str", c )
keyw\add( "ValD", c )
keyw\add( "ValF", c )
keyw\add( "Val", c )
keyw\add( "RunProgram", c )
keyw\add( "Delay", c )
keyw\add( "OpenWindow", c )
keyw\add( "ButtonGadget", c )
keyw\add( "ButtonImageGadget", c )
keyw\add( "CheckBoxGadget", c )
keyw\add( "OptionGadget", c )
keyw\add( "CanvasGadget", c )
keyw\add( "ImageGadget", c )
keyw\add( "PanelGadget", c )
keyw\add( "TreeGadget", c )
keyw\add( "ListViewGadget", c )
keyw\add( "ListIconGadget", c )
keyw\add( "SpinGadget", c )
keyw\add( "SplitterGadget", c )
keyw\add( "WebGadget", c )
keyw\add( "StringGadget", c )
keyw\add( "TextGadget", c )
keyw\add( "ComboBoxGadget", c )
keyw\add( "DateGadget", c )
keyw\add( "CalenderGadget", c )
; ***
c = RGB( 154, 71, 193 )
keyw\add( "PB_Compiler_OS", c )
keyw\add( "PB_OS_MacOS", c )
keyw\add( "PB_OS_Linux", c )
keyw\add( "PB_OS_Windows", c )
keyw\add( "PB_Event_Gadget", c )
keyw\add( "PB_Event_CloseWindow", c )
keyw\add( "PB_Event_SizeWindow", c )
keyw\add( "PB_Event_MoveWindow", c )
keyw\add( "PB_Event_MaximizeWindow", c )
keyw\add( "PB_Event_MinimizeWindow", c )
keyw\add( "True", c )
keyw\add( "False", c )
keyw\add( "PB_Any", c )
keyw\add( "PB_Ignore", c )
mich\comment_char = ";"
mich\string_char = Chr(34)
mich\double_separator = "."
mich\keywords = keyw
mich\visbkg = 10
mich\tmpbkg = 11
mich\curlin = 12
mich\tempor = 13
update(mich,#feld,0,0,0,0,0)
Repeat
ev.i = WaitWindowEvent()
; ***
If ev = #PB_Event_CloseWindow
;For r = 0 To mich\content\lines() -1
;Debug Str(r) + ":" + Str(r+1) + " >> " + mich\content\get(r)
;Next
EndIf
; ***
If ev = #PB_Event_Timer And EventTimer() = #fenster
Select mich\cursorDisplay
Case 0 : mich\cursorDisplay = 1
Case 1 : mich\cursorDisplay = 0
EndSelect
; ***
update(mich,#feld,0,0,0,0,0)
EndIf
; ***
If ev = #PB_Event_Gadget And EventGadget() = #feld
Select EventType()
Case #PB_EventType_Input, #PB_EventType_KeyDown, #PB_EventType_KeyUp,
#PB_EventType_LeftButtonDown, #PB_EventType_LeftButtonUp,
#PB_EventType_RightButtonUp, #PB_EventType_MouseMove,
#PB_EventType_MouseWheel
update(mich,#feld,EventType(),
GetGadgetAttribute(#feld,#PB_Canvas_Key),
GetGadgetAttribute(#feld,#PB_Canvas_Input),
GetGadgetAttribute(#feld,#PB_Canvas_MouseX),
GetGadgetAttribute(#feld,#PB_Canvas_MouseY))
EndSelect
EndIf
Until ev = #PB_Event_CloseWindow
End