donc tu entre dans le 2 em algo (ou le meme recursivité ) qui verifie si le charactere suivant est aussi un chiffre si c'est le cas tu concatene ce chiffre avec celui d'avant dans la fameuse variable chaine
et tu recommence jusqu'a que le charactere observé ne soit plus compris entre 48 et 57
toujour a la mem coordonés , donc on appercois le reafichage de ces ligne avant que l'editeur se rafraichisse !
Code : Tout sélectionner
;Par Progi1984
; Libraire PureSyntaxColoration
NewList keyword.s()
AddElement(keyword())
keyword()="if"
AddElement(keyword())
keyword()="then"
AddElement(keyword())
keyword()="endif"
FirstElement(keyword())
#Editor = 1
Procedure Editor_CursorX(Gadget)
; returns X-Pos of Cursor
REG = GadgetID(Gadget)
SendMessage_(REG,#EM_EXGETSEL,0,Range.CHARRANGE)
ProcedureReturn (Range\cpMax-(SendMessage_(REG,#EM_LINEINDEX,SendMessage_(REG,#EM_EXLINEFROMCHAR,0,Range\cpMin),0))+1)
EndProcedure
Procedure Editor_CursorY(Gadget)
; returns Y-Pos of Cursor
REG = GadgetID(Gadget)
SendMessage_(REG,#EM_EXGETSEL,0,Range.CHARRANGE)
ProcedureReturn SendMessage_(REG,#EM_EXLINEFROMCHAR,0,Range\cpMin)+1
EndProcedure
Procedure Editor_CursorPos(Gadget)
; returns relative Position of Cursor
SendMessage_(GadgetID(Gadget),#EM_EXGETSEL,0,Range.CHARRANGE)
ProcedureReturn Range\cpMax
EndProcedure
Procedure Editor_Locate(Gadget,x,y)
; Set cursor position
REG = GadgetID(Gadget)
CharIdx = SendMessage_(REG,#EM_LINEINDEX,y-1,0)
LLength = SendMessage_(REG,#EM_LINELENGTH,CharIdx,0)
If LLength >= x-1
CharIdx + x-1
EndIf
Range.CHARRANGE
Range\cpMin = CharIdx
Range\cpMax = CharIdx
SendMessage_(REG,#EM_EXSETSEL,0,Range)
EndProcedure
Procedure Editor_Select(Gadget, LineStart.l, CharStart.l, LineEnd.l, CharEnd.l)
sel.CHARRANGE
sel\cpMin = SendMessage_(GadgetID(Gadget), #EM_LINEINDEX, LineStart, 0) + CharStart - 1
If LineEnd = -1
LineEnd = SendMessage_(GadgetID(Gadget), #EM_GETLINECOUNT, 0, 0)-1
EndIf
sel\cpMax = SendMessage_(GadgetID(Gadget), #EM_LINEINDEX, LineEnd, 0)
If CharEnd = -1
sel\cpMax + SendMessage_(GadgetID(Gadget), #EM_LINELENGTH, sel\cpMax, 0)
Else
sel\cpMax + CharEnd - 1
EndIf
SendMessage_(GadgetID(Gadget), #EM_EXSETSEL, 0, @sel)
EndProcedure
; Set the Text color for the Selection
; in RGB format
Procedure Editor_Color(Gadget, Color.l)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_COLOR
format\crTextColor = Color
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
; Set Font Size for the Selection
; in pt
Procedure Editor_FontSize(Gadget, Fontsize.l)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_SIZE
format\yHeight = FontSize*20
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
; Set Font for the Selection
; You must specify a font name, the font doesn't need
; to be loaded
Procedure Editor_Font(Gadget, FontName.s)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_FACE
PokeS(@format\szFaceName, FontName)
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
; Set Format of the Selection. This can be a combination of
; the following values:
; #CFM_BOLD
; #CFM_ITALIC
; #CFM_UNDERLINE
; #CFM_STRIKEOUT
Procedure Editor_Format(Gadget, Flags.l)
format.CHARFORMAT
format\cbSize = SizeOf(CHARFORMAT)
format\dwMask = #CFM_ITALIC|#CFM_BOLD|#CFM_STRIKEOUT|#CFM_UNDERLINE
format\dwEffects = Flags
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
Procedure Editor_ColorText(gadget,ydeb,xdeb,yfin,xfin,color)
Editor_Select(gadget,ydeb,xdeb,yfin,xfin)
Editor_Color(gadget,color)
EndProcedure
Procedure Highlight(xx,yy)
For i=0 To CountGadgetItems(#editor)-1
text$=LCase(GetGadgetItemText(#editor,i,0))
Debug text$
If Len(text$)>0
;Keyword
For j=0 To CountList(Keyword())
SelectElement(keyword(),j)
Debug keyword()
p=FindString(text$,keyword(),0)
If p>0
spacer$=Mid(text$,p-1,1)
If p=1 Or p=0 Or spacer$=" " Or spacer$="," Or spacer$="=" Or spacer$="("
spacer$=Mid(text$,p+Len(keyword()),1)
Debug spacer$
If spacer$=" " Or spacer$="(" Or spacer$=""; Or spacer$=Chr(13) Or spacer$=Chr(10) Or spacer$=" "
Editor_ColorText(#editor,i,p,i,p+Len(keyword())+1, RGB(0,255,0))
EndIf
EndIf
EndIf
Next
;strings
p=1
p=FindString(text$,Chr(34),p)
Debug "p1-"+Str(p)
If p>0
If p
p2=FindString(text$,Chr(34),p+1)
Debug "p2-"+Str(p2)
EndIf
If p2>p
Editor_ColorText(#editor,i,p,i,p2+1, RGB(255,0,0))
EndIf
EndIf
; commentaires
p=FindString(text$,";",0)
If p<>0
Editor_ColorText(#Editor,i,p,i,Len(text$)+1, RGB(0,0,255))
EndIf
EndIf
Next
Editor_Locate(#Editor,xx,yy)
EndProcedure
; -------------------------------------------------------------
; Source Example:
If OpenWindow(0, 0, 0, 500, 500, #PB_Window_SystemMenu|#PB_Window_ScreenCentered, "EditorGadget")
If CreateGadgetList(WindowID())
CallDebugger
EditorGadget(#Editor, 10, 10, 480, 480)
SetGadgetText(#Editor, "If you are ; a man if"+Chr(13)+Chr(10)+Chr(34)+";then go"+Chr(34)+" ; Aux hiotes"+Chr(13)+Chr(10)+";if not"+Chr(13)+Chr(10)+"not if")
SendMessage_(GadgetID(#Editor),#EM_SETBKGNDCOLOR,0,RGB($FF,$FF,$BF))
Editor_Select(#Editor, 0, 0, 0, 0) ; select nothing again
New.s=GetGadgetText(#Editor) ;<<<<<< ça pas dans la boucle !!!! DOBRO
Repeat
If New.s<>old.s
x=Editor_CursorX(#Editor)
y=Editor_CursorY(#Editor)
Highlight(x,y)
old=New
; Editor_Select(#Editor, i, line, i, lineb)
Editor_Color(#Editor, RGB(0,0,0))
EndIf
Until WaitWindowEvent() = #PB_EventCloseWindow
EndIf
EndIf
End
; ExecutableFormat=Windows
; EOF