Scintila

Just starting out? Need help? Post your questions and find answers here.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Scintila

Post by Num3 »

I've tried with limited sucess to create a simple editor with scintila.

But the documentation and examples are null atm...

I even took a pick at japbe source code to understand a few things.

Is it possible for someone that has worked with scintila to posta a simple concrete example of how to use it under PB ?

By basic i mean, open the editor gadget, activate the auto-complete (much like pb), change font.

Thanks in advance!


--Edit--

When i arrive home tonight i'll post my modest code here, has a startup example ;)
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Peyman
Enthusiast
Enthusiast
Posts: 203
Joined: Mon Dec 24, 2007 4:15 pm
Location: Iran

Post by Peyman »

in This Example you must use Scintilla Library ( Made By Gonzal ) :

Code: Select all

;******************************************************
;   Program:          Scintilla Examp
;   Author:           Peyman
;   Date:             April 2, 2008
;   Target OS:        Windows All
;   Target Compiler:  PureBasic 4.0 +
;   License:          Freeware
;
;******************************************************


 ;{ Enumeration
Enumeration
#Window    = 0
#Scintilla = 1
#MinWidth  = 400
#MinHeight = 300
#MaxWidth  = 800
#MaxHeight = 600
EndEnumeration
;}

 ;{ KeyWord
Keyword.s = "aaa aad aam aas adc add and call cbw clc cld cli cmc cmp cmps cmpsb cmpsw cwd daa das dec div esc hlt idiv imul in inc int into iret ja jae jb jbe jc jcxz je jg jge jl jle jmp jna jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp jns jnz jo jp jpe jpo js jz lahf lds lea les lods lodsb lodsw loop loope loopew loopne loopnew loopnz loopnzw loopw loopz loopzw mov movs movsb movsw mul neg nop not or out pop popf push pushf rcl rcr ret retf retn rol ror sahf sal sar sbb scas scasb scasw shl shr stc std sti stos stosb stosw sub test wait xchg xlat xlatb xor bound enter ins insb insw leave outs outsb outsw popa pusha pushw arpl lar lsl sgdt sidt sldt smsw str verr verw clts lgdt lidt lldt lmsw ltr bsf bsr bt btc btr bts cdq cmpsd cwde insd iretd iretdf  iretf jecxz lfs lgs lodsd loopd  looped  loopned  loopnzd  loopzd  lss movsd movsx movzx outsd popad popfd pushad pushd  pushfd scasd seta setae setb setbe setc sete setg setge setl setle setna setnae setnb setnbe setnc setne setng setnge setnl setnle setno setnp setns setnz seto setp setpe setpo sets setz shld shrd stosd bswap cmpxchg invd  invlpg  wbinvd  xadd lock rep repe repne repnz repz cflush cpuid emms femms cmovo cmovno cmovb cmovc cmovnae cmovae cmovnb cmovnc cmove cmovz cmovne cmovnz cmovbe cmovna cmova cmovnbe cmovs cmovns cmovp cmovpe cmovnp cmovpo cmovl cmovnge cmovge cmovnl cmovle cmovng cmovg cmovnle cmpxchg486 cmpxchg8b  loadall loadall286 ibts icebp int1 int3 int01 int03 iretw popaw popfw pushaw pushfw rdmsr rdpmc rdshr rdtsc rsdc rsldt rsm rsts salc smi smint smintold svdc svldt svts syscall sysenter sysexit sysret ud0 ud1 ud2 umov xbts wrmsr wrshr"
Keyword2.s = "f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcom fcomp fcompp fdecstp fdisi fdiv fdivp fdivr fdivrp feni ffree fiadd ficom ficomp fidiv fidivr fild fimul fincstp finit fist fistp fisub fisubr fld fld1 fldcw fldenv fldenvw fldl2e fldl2t fldlg2 fldln2 fldpi fldz fmul fmulp fnclex fndisi fneni fninit fnop fnsave fnsavew fnstcw fnstenv fnstenvw fnstsw fpatan fprem fptan frndint frstor frstorw fsave fsavew fscale fsqrt fst fstcw fstenv fstenvw fstp fstsw fsub fsubp fsubr fsubrp ftst fwait fxam fxch fxtract fyl2x fyl2xp1 fsetpm fcos fldenvd fnsaved fnstenvd fprem1 frstord fsaved fsin fsincos fstenvd fucom fucomp fucompp fcomi fcomip ffreep fcmovb fcmove fcmovbe fcmovu fcmovnb fcmovne fcmovnbe fcmovnu"
Keyword3.s = "ah al ax bh bl bp bx ch cl cr0 cr2 cr3 cr4 cs cx dh di dl dr0 dr1 dr2 dr3 dr6 dr7 ds dx eax ebp ebx ecx edi edx es esi esp fs gs si sp ss st tr3 tr4 tr5 tr6 tr7 st0 st1 st2 st3 st4 st5 st6 st7 mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7"
Keyword4.s = ".186 .286 .286c .286p .287 .386 .386c .386p .387 .486 .486p .8086 .8087 .alpha .break .code .const .continue .cref .data .data?  .dosseg .else .elseif .endif .endw .err .err1 .err2 .errb .errdef .errdif .errdifi .erre .erridn .erridni .errnb .errndef .errnz .exit .fardata .fardata? .if .lall .lfcond .list .listall .listif .listmacro .listmacroall  .model .no87 .nocref .nolist .nolistif .nolistmacro .radix .repeat .sall .seq .sfcond .stack .startup .tfcond .type .until .untilcxz .while .xall .xcref .xlist alias align assume catstr comm comment db dd df dosseg dq dt dup dw echo else elseif elseif1 elseif2 elseifb elseifdef elseifdif elseifdifi elseife elseifidn elseifidni elseifnb elseifndef end endif endm endp ends eq equ even exitm extern externdef extrn for forc ge goto group gt high highword if if1 if2 ifb ifdef ifdif ifdifi ife  ifidn ifidni ifnb ifndef include includelib instr invoke irp irpc label le length lengthof local low lowword lroffset lt macro mask mod .msfloat name ne offset opattr option org %out page popcontext proc proto ptr public purge pushcontext record repeat rept seg segment short size sizeof sizestr struc struct substr subtitle subttl textequ this title type typedef union while width db dw dd dq dt resb resw resd resq rest incbin equ times %define %idefine %xdefine %xidefine %undef %assign %iassign %strlen %substr %macro %imacro %endmacro %rotate .nolist %if %elif %else %endif %ifdef %ifndef %elifdef %elifndef %ifmacro %ifnmacro %elifmacro %elifnmacro %ifctk %ifnctk %elifctk %elifnctk %ifidn %ifnidn %elifidn %elifnidn %ifidni %ifnidni %elifidni %elifnidni %ifid %ifnid %elifid %elifnid %ifstr %ifnstr %elifstr %elifnstr %ifnum %ifnnum %elifnum %elifnnum %error %rep %endrep %exitrep %include %push %pop %repl struct endstruc istruc at iend align alignb %arg %stacksize %local %line bits use16 use32 section absolute extern global common cpu org section group import export"
Keyword5.s = "$ ? @b @f addr basic byte c carry? dword far far16 fortran fword near near16 overflow? parity? pascal qword  real4  real8 real10 sbyte sdword sign? stdcall sword syscall tbyte vararg word zero? flat near32 far32 abs all assumes at casemap common compact cpu dotname emulator epilogue error export expr16 expr32 farstack flat forceframe huge language large listing ljmp loadds m510 medium memory nearstack nodotname noemulator nokeyword noljmp nom510 none nonunique nooldmacros nooldstructs noreadonly noscoped nosignextend nothing notpublic oldmacros oldstructs os_dos para private prologue radix readonly req scoped setif2 smallstack tiny use16 use32 uses a16 a32 o16 o32 byte word dword nosplit $ $$ seq wrt flat large small .text .data .bss near far %0 %1 %2 %3 %4 %5 %6 %7 %8 %9"
Keyword6.s = "addpd addps addsd addss andpd andps andnpd andnps cmpeqpd cmpltpd cmplepd cmpunordpd cmpnepd cmpnltpd cmpnlepd cmpordpd cmpeqps cmpltps cmpleps cmpunordps cmpneps cmpnltps cmpnleps cmpordps cmpeqsd cmpltsd cmplesd cmpunordsd cmpnesd cmpnltsd cmpnlesd cmpordsd cmpeqss cmpltss cmpless cmpunordss cmpness cmpnltss cmpnless cmpordss comisd comiss cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi cvtpd2ps cvtpi2pd cvtpi2ps cvtps2dq cvtps2pd cvtps2pi cvtss2sd cvtss2si cvtsd2si cvtsd2ss cvtsi2sd cvtsi2ss cvttpd2dq cvttpd2pi cvttps2dq cvttps2pi cvttsd2si cvttss2si divpd divps divsd divss fxrstor fxsave ldmxscr lfence mfence maskmovdqu maskmovdq maxpd maxps paxsd maxss minpd minps minsd minss movapd movaps movdq2q movdqa movdqu movhlps movhpd movhps movd movq movlhps movlpd movlps movmskpd movmskps movntdq movnti movntpd movntps movntq movq2dq movsd movss movupd movups mulpd mulps mulsd mulss orpd orps packssdw packsswb packuswb paddb paddsb paddw paddsw paddd paddsiw paddq paddusb paddusw pand pandn pause paveb pavgb pavgw pavgusb pdistib pextrw pcmpeqb pcmpeqw pcmpeqd pcmpgtb pcmpgtw pcmpgtd pf2id pf2iw pfacc pfadd pfcmpeq pfcmpge pfcmpgt pfmax pfmin pfmul pmachriw pmaddwd pmagw pmaxsw pmaxub pminsw pminub pmovmskb pmulhrwc pmulhriw pmulhrwa pmulhuw pmulhw pmullw pmuludq pmvzb pmvnzb pmvlzb pmvgezb pfnacc pfpnacc por prefetch prefetchw prefetchnta prefetcht0 prefetcht1 prefetcht2 pfrcp pfrcpit1 pfrcpit2 pfrsqit1 pfrsqrt pfsub pfsubr pi2fd pf2iw pinsrw psadbw pshufd pshufhw pshuflw pshufw psllw pslld psllq pslldq psraw psrad psrlw psrld psrlq psrldq psubb psubw psubd psubq psubsb psubsw psubusb psubusw psubsiw pswapd punpckhbw punpckhwd punpckhdq punpckhqdq punpcklbw punpcklwd punpckldq punpcklqdq pxor rcpps rcpss rsqrtps rsqrtss sfence shufpd shufps sqrtpd sqrtps sqrtsd sqrtss stmxcsr subpd subps subsd subss ucomisd ucomiss unpckhpd unpckhps unpcklpd unpcklps xorpd xorps"
;}

Procedure.l Scintilla(hsci.l, p1.l, p2.l=0, p3.l=0)
  ProcedureReturn ScintillaSendMessage(hsci, p1, p2, p3)
EndProcedure

ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)

  If *scinotify\nmhdr\code = #SCN_MODIFIED
    
   LenghofLines =  Len(StrU(Scintilla(#Scintilla, #SCI_GETLINECOUNT), #Long))

    If LenghofLines > 3
    
      Scintilla(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37+(LenghofLines-3)*10)
      
    Else
      
      Scintilla(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
 
    EndIf 
 
  EndIf
 
EndProcedure

Procedure WindowCallback(WindowID, Message, wParam, lParam)
  ReturnValue = #PB_ProcessPureBasicEvents
 
    If Message = #WM_MOVE
   
   
    ElseIf Message = #WM_GETMINMAXINFO
   
        *pMinMax.MINMAXINFO = lParam
        *pMinMax\ptMinTrackSize\x=#MinWidth
        *pMinMax\ptMinTrackSize\y=#MinHeight
        *pMinMax\ptMaxTrackSize\x=#MaxWidth
        *pMinMax\ptMaxTrackSize\y=#MaxHeight
        ReturnValue = 0


    ElseIf Message = #WM_SIZE

       
        ResizeGadget(#Scintilla,0,0,WindowWidth(#Window),WindowHeight(#Window))
   
    
    ElseIf Message = #WM_ACTIVATE
    
        SetFocus_(GadgetID(#Scintilla))
    
    EndIf
       
   
    ProcedureReturn  ReturnValue

EndProcedure

Procedure LoadFile(filename.s)
    If filename <> ""
        file.l = ReadFile(#PB_Any, filename)
        If file <> 0
            len.l = Lof(file)
            *mem = AllocateMemory(len)
            If *mem
                ReadData(file, *mem, len)
                Scintilla(#Scintilla, #SCI_SETTEXT, 0, *mem)
                FreeMemory(*mem)
            EndIf
            CloseFile(file)
        EndIf
      LenghofLines =  Len(StrU(Scintilla(#Scintilla, #SCI_GETLINECOUNT), #Long))
       
      If LenghofLines > 3
    
        Scintilla(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37+(LenghofLines-3)*10)
      
      Else
      
        Scintilla(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
 
      EndIf 
     
    EndIf
EndProcedure

OpenWindow(#Window, 130, 50, 655, 445, "CommenntedASM By Peyman", #PB_Window_SizeGadget|#PB_Window_SystemMenu)

SetWindowCallback(@WindowCallback())

CreateGadgetList(WindowID(#Window))

InitScintillaStaticFull()

GetClientRect_(WindowID(#Window), rect.RECT)

ScintillaGadget(#Scintilla, 0, 0, rect\right, rect\bottom, @ScintillaCallBack())



; Delete Tab Key For Tab in Scintilla
RemoveKeyboardShortcut(#Window, #PB_Shortcut_Tab)
RemoveKeyboardShortcut(#Window, #PB_Shortcut_Tab | #PB_Shortcut_Shift)

; Other
Scintilla(#Scintilla, #SCI_SETINDENT, 2)


; Font And Size
Scintilla(#Scintilla, #SCI_STYLESETFONT, #STYLE_DEFAULT, @"Courier New")
Scintilla(#Scintilla, #SCI_STYLESETSIZE, #STYLE_DEFAULT, 10)
Scintilla(#Scintilla, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
Scintilla(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 50)
Scintilla(#Scintilla, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
Scintilla(#Scintilla, #SCI_SETMARGINMASKN, 2, #SC_MASK_FOLDERS)
Scintilla(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
Scintilla(#Scintilla, #SCI_SETMARGINWIDTHN, 1, 1)
Scintilla(#Scintilla, #SCI_SETMARGINWIDTHN, 2, 7)
Scintilla(#Scintilla, #SCI_SETMARGINSENSITIVEN, 2, #True)


;lex setup
Scintilla(#Scintilla, #SCI_SETLEXER, #SCLEX_ASM, 0)
Scintilla(#Scintilla, #SCI_SETSTYLEBITS, 5, 0)
Scintilla(#Scintilla,#SCI_STYLESETFORE, #STYLE_DEFAULT, RGB(0,0,0));
Scintilla(#Scintilla,#SCI_STYLESETBACK, #STYLE_DEFAULT, RGB(255,255,255));
Scintilla(#Scintilla,#SCI_STYLECLEARALL);

; Set caret line colour
Scintilla(#Scintilla, #SCI_SETCARETLINEBACK, 16771304)
Scintilla(#Scintilla, #SCI_SETCARETLINEVISIBLE, #True)



; Set styles for custom lexer
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_DEFAULT, 0) ; Default Color
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_COMMENT, 32768) ; Coment Color
Scintilla(#Scintilla, #SCI_STYLESETFONT, #SCE_ASM_COMMENT, @"Comic Sans MS") ; Coment Font
Scintilla(#Scintilla, #SCI_STYLESETSIZE, #SCE_ASM_COMMENT, 8) ; Coment Size
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_NUMBER, 33023)
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_STRING, 8421504)
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_OPERATOR, 8388608)
Scintilla(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_OPERATOR, #True) ; set operator Bold
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_IDENTIFIER, 0)
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_CPUINSTRUCTION, 16711680)
Scintilla(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_CPUINSTRUCTION, #True) ; set Cpuinstruction Bold
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_MATHINSTRUCTION, 12615680)
Scintilla(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_MATHINSTRUCTION, #True)
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_REGISTER, 16744576) ; Set Front Register Color
Scintilla(#Scintilla, #SCI_STYLESETBACK, #SCE_ASM_REGISTER, 13434879) ; Set Back Register Color
Scintilla(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_REGISTER, #True)
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_DIRECTIVE, 16744448)
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_DIRECTIVEOPERAND, 8388608)
Scintilla(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_DIRECTIVEOPERAND, #True)
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_COMMENTBLOCK, 32768)
Scintilla(#Scintilla, #SCI_STYLESETFONT, #SCE_ASM_COMMENTBLOCK, @"Comic Sans MS")
Scintilla(#Scintilla, #SCI_STYLESETSIZE, #SCE_ASM_COMMENTBLOCK, 8)
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_CHARACTER, 32896)
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_STRINGEOL, 8421504)
Scintilla(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_EXTINSTRUCTION, 16512)
Scintilla(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_EXTINSTRUCTION, #True)


; Color Of Selection
Scintilla(#Scintilla, #SCI_SETSELBACK, #True, RGB(49, 106, 197))
Scintilla(#Scintilla, #SCI_SETSELFORE, #True, RGB(255, 255, 255))


; Code Wraper
;Scintilla(#Scintilla, #SCI_SETWRAPMODE, #SC_WRAP_WORD, 0)
;Scintilla(#Scintilla, #SCI_SETWRAPVISUALFLAGS, #SC_WRAPVISUALFLAG_START | #SC_WRAPVISUALFLAG_END, 0)


; Keyword
Scintilla(#Scintilla, #SCI_SETKEYWORDS, 0, @Keyword)  ; Set KeyWord 1
Scintilla(#Scintilla, #SCI_SETKEYWORDS, 1, @Keyword2) ; Set KeyWord 2
Scintilla(#Scintilla, #SCI_SETKEYWORDS, 2, @Keyword3) ; Set KeyWord 3
Scintilla(#Scintilla, #SCI_SETKEYWORDS, 3, @Keyword4) ; Set KeyWord 4
Scintilla(#Scintilla, #SCI_SETKEYWORDS, 4, @Keyword5) ; Set KeyWord 5
Scintilla(#Scintilla, #SCI_SETKEYWORDS, 5, @Keyword6) ; Set KeyWord 6


SetFocus_(GadgetID(#Scintilla))



Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow  
ferty
User
User
Posts: 70
Joined: Fri Jun 03, 2005 8:22 pm
Location: Glos,Uk

Scintilla

Post by ferty »

Hi,would it be possible to show us an example like above covering keyword,using the inbuilt scintilla,and not Gonzal`s lib.
Thank you.
They Say You Never Stop Learning,Well I Can`t Seem To Start. :(
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

WOOW!

Great stuff indeed! Simpler than i thought :D
Peyman
Enthusiast
Enthusiast
Posts: 203
Joined: Mon Dec 24, 2007 4:15 pm
Location: Iran

Re: Scintilla

Post by Peyman »

ferty wrote:Hi,would it be possible to show us an example like above covering keyword,using the inbuilt scintilla,and not Gonzal`s lib.
Thank you.
Yea its possible (Every thing Possible), i write it and Post it.
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

The code of Peyman doesn't run with Purebasic without Gnozal lib :

Code: Select all

;******************************************************
;   Program:          Scintilla Examp
;   Author:           Peyman
;   Date:             April 2, 2008
;   Target OS:        Windows All
;   Target Compiler:  PureBasic 4.0 +
;   License:          Freeware
;   History            Modified by Progi1984 for PB without Gnozal Lib
;******************************************************

 ;{ Enumeration
Enumeration
#Window    = 0
#Scintilla = 1
#MinWidth  = 400
#MinHeight = 300
#MaxWidth  = 800
#MaxHeight = 600
EndEnumeration
;}

 ;{ KeyWord
Keyword.s = "aaa aad aam aas adc add and call cbw clc cld cli cmc cmp cmps cmpsb cmpsw cwd daa das dec div esc hlt idiv imul in inc int into iret ja jae jb jbe jc jcxz je jg jge jl jle jmp jna jnae jnb jnbe jnc jne jng jnge jnl jnle jno jnp jns jnz jo jp jpe jpo js jz lahf lds lea les lods lodsb lodsw loop loope loopew loopne loopnew loopnz loopnzw loopw loopz loopzw mov movs movsb movsw mul neg nop not or out pop popf push pushf rcl rcr ret retf retn rol ror sahf sal sar sbb scas scasb scasw shl shr stc std sti stos stosb stosw sub test wait xchg xlat xlatb xor bound enter ins insb insw leave outs outsb outsw popa pusha pushw arpl lar lsl sgdt sidt sldt smsw str verr verw clts lgdt lidt lldt lmsw ltr bsf bsr bt btc btr bts cdq cmpsd cwde insd iretd iretdf  iretf jecxz lfs lgs lodsd loopd  looped  loopned  loopnzd  loopzd  lss movsd movsx movzx outsd popad popfd pushad pushd  pushfd scasd seta setae setb setbe setc sete setg setge setl setle setna setnae setnb setnbe setnc setne setng setnge setnl setnle setno setnp setns setnz seto setp setpe setpo sets setz shld shrd stosd bswap cmpxchg invd  invlpg  wbinvd  xadd lock rep repe repne repnz repz cflush cpuid emms femms cmovo cmovno cmovb cmovc cmovnae cmovae cmovnb cmovnc cmove cmovz cmovne cmovnz cmovbe cmovna cmova cmovnbe cmovs cmovns cmovp cmovpe cmovnp cmovpo cmovl cmovnge cmovge cmovnl cmovle cmovng cmovg cmovnle cmpxchg486 cmpxchg8b  loadall loadall286 ibts icebp int1 int3 int01 int03 iretw popaw popfw pushaw pushfw rdmsr rdpmc rdshr rdtsc rsdc rsldt rsm rsts salc smi smint smintold svdc svldt svts syscall sysenter sysexit sysret ud0 ud1 ud2 umov xbts wrmsr wrshr"
Keyword2.s = "f2xm1 fabs fadd faddp fbld fbstp fchs fclex fcom fcomp fcompp fdecstp fdisi fdiv fdivp fdivr fdivrp feni ffree fiadd ficom ficomp fidiv fidivr fild fimul fincstp finit fist fistp fisub fisubr fld fld1 fldcw fldenv fldenvw fldl2e fldl2t fldlg2 fldln2 fldpi fldz fmul fmulp fnclex fndisi fneni fninit fnop fnsave fnsavew fnstcw fnstenv fnstenvw fnstsw fpatan fprem fptan frndint frstor frstorw fsave fsavew fscale fsqrt fst fstcw fstenv fstenvw fstp fstsw fsub fsubp fsubr fsubrp ftst fwait fxam fxch fxtract fyl2x fyl2xp1 fsetpm fcos fldenvd fnsaved fnstenvd fprem1 frstord fsaved fsin fsincos fstenvd fucom fucomp fucompp fcomi fcomip ffreep fcmovb fcmove fcmovbe fcmovu fcmovnb fcmovne fcmovnbe fcmovnu"
Keyword3.s = "ah al ax bh bl bp bx ch cl cr0 cr2 cr3 cr4 cs cx dh di dl dr0 dr1 dr2 dr3 dr6 dr7 ds dx eax ebp ebx ecx edi edx es esi esp fs gs si sp ss st tr3 tr4 tr5 tr6 tr7 st0 st1 st2 st3 st4 st5 st6 st7 mm0 mm1 mm2 mm3 mm4 mm5 mm6 mm7 xmm0 xmm1 xmm2 xmm3 xmm4 xmm5 xmm6 xmm7"
Keyword4.s = ".186 .286 .286c .286p .287 .386 .386c .386p .387 .486 .486p .8086 .8087 .alpha .break .code .const .continue .cref .data .data?  .dosseg .else .elseif .endif .endw .err .err1 .err2 .errb .errdef .errdif .errdifi .erre .erridn .erridni .errnb .errndef .errnz .exit .fardata .fardata? .if .lall .lfcond .list .listall .listif .listmacro .listmacroall  .model .no87 .nocref .nolist .nolistif .nolistmacro .radix .repeat .sall .seq .sfcond .stack .startup .tfcond .type .until .untilcxz .while .xall .xcref .xlist alias align assume catstr comm comment db dd df dosseg dq dt dup dw echo else elseif elseif1 elseif2 elseifb elseifdef elseifdif elseifdifi elseife elseifidn elseifidni elseifnb elseifndef end endif endm endp ends eq equ even exitm extern externdef extrn for forc ge goto group gt high highword if if1 if2 ifb ifdef ifdif ifdifi ife  ifidn ifidni ifnb ifndef include includelib instr invoke irp irpc label le length lengthof local low lowword lroffset lt macro mask mod .msfloat name ne offset opattr option org %out page popcontext proc proto ptr public purge pushcontext record repeat rept seg segment short size sizeof sizestr struc struct substr subtitle subttl textequ this title type typedef union while width db dw dd dq dt resb resw resd resq rest incbin equ times %define %idefine %xdefine %xidefine %undef %assign %iassign %strlen %substr %macro %imacro %endmacro %rotate .nolist %if %elif %else %endif %ifdef %ifndef %elifdef %elifndef %ifmacro %ifnmacro %elifmacro %elifnmacro %ifctk %ifnctk %elifctk %elifnctk %ifidn %ifnidn %elifidn %elifnidn %ifidni %ifnidni %elifidni %elifnidni %ifid %ifnid %elifid %elifnid %ifstr %ifnstr %elifstr %elifnstr %ifnum %ifnnum %elifnum %elifnnum %error %rep %endrep %exitrep %include %push %pop %repl struct endstruc istruc at iend align alignb %arg %stacksize %local %line bits use16 use32 section absolute extern global common cpu org section group import export"
Keyword5.s = "$ ? @b @f addr basic byte c carry? dword far far16 fortran fword near near16 overflow? parity? pascal qword  real4  real8 real10 sbyte sdword sign? stdcall sword syscall tbyte vararg word zero? flat near32 far32 abs all assumes at casemap common compact cpu dotname emulator epilogue error export expr16 expr32 farstack flat forceframe huge language large listing ljmp loadds m510 medium memory nearstack nodotname noemulator nokeyword noljmp nom510 none nonunique nooldmacros nooldstructs noreadonly noscoped nosignextend nothing notpublic oldmacros oldstructs os_dos para private prologue radix readonly req scoped setif2 smallstack tiny use16 use32 uses a16 a32 o16 o32 byte word dword nosplit $ $$ seq wrt flat large small .text .data .bss near far %0 %1 %2 %3 %4 %5 %6 %7 %8 %9"
Keyword6.s = "addpd addps addsd addss andpd andps andnpd andnps cmpeqpd cmpltpd cmplepd cmpunordpd cmpnepd cmpnltpd cmpnlepd cmpordpd cmpeqps cmpltps cmpleps cmpunordps cmpneps cmpnltps cmpnleps cmpordps cmpeqsd cmpltsd cmplesd cmpunordsd cmpnesd cmpnltsd cmpnlesd cmpordsd cmpeqss cmpltss cmpless cmpunordss cmpness cmpnltss cmpnless cmpordss comisd comiss cvtdq2pd cvtdq2ps cvtpd2dq cvtpd2pi cvtpd2ps cvtpi2pd cvtpi2ps cvtps2dq cvtps2pd cvtps2pi cvtss2sd cvtss2si cvtsd2si cvtsd2ss cvtsi2sd cvtsi2ss cvttpd2dq cvttpd2pi cvttps2dq cvttps2pi cvttsd2si cvttss2si divpd divps divsd divss fxrstor fxsave ldmxscr lfence mfence maskmovdqu maskmovdq maxpd maxps paxsd maxss minpd minps minsd minss movapd movaps movdq2q movdqa movdqu movhlps movhpd movhps movd movq movlhps movlpd movlps movmskpd movmskps movntdq movnti movntpd movntps movntq movq2dq movsd movss movupd movups mulpd mulps mulsd mulss orpd orps packssdw packsswb packuswb paddb paddsb paddw paddsw paddd paddsiw paddq paddusb paddusw pand pandn pause paveb pavgb pavgw pavgusb pdistib pextrw pcmpeqb pcmpeqw pcmpeqd pcmpgtb pcmpgtw pcmpgtd pf2id pf2iw pfacc pfadd pfcmpeq pfcmpge pfcmpgt pfmax pfmin pfmul pmachriw pmaddwd pmagw pmaxsw pmaxub pminsw pminub pmovmskb pmulhrwc pmulhriw pmulhrwa pmulhuw pmulhw pmullw pmuludq pmvzb pmvnzb pmvlzb pmvgezb pfnacc pfpnacc por prefetch prefetchw prefetchnta prefetcht0 prefetcht1 prefetcht2 pfrcp pfrcpit1 pfrcpit2 pfrsqit1 pfrsqrt pfsub pfsubr pi2fd pf2iw pinsrw psadbw pshufd pshufhw pshuflw pshufw psllw pslld psllq pslldq psraw psrad psrlw psrld psrlq psrldq psubb psubw psubd psubq psubsb psubsw psubusb psubusw psubsiw pswapd punpckhbw punpckhwd punpckhdq punpckhqdq punpcklbw punpcklwd punpckldq punpcklqdq pxor rcpps rcpss rsqrtps rsqrtss sfence shufpd shufps sqrtpd sqrtps sqrtsd sqrtss stmxcsr subpd subps subsd subss ucomisd ucomiss unpckhpd unpckhps unpcklpd unpcklps xorpd xorps"
;}

ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)

  If *scinotify\nmhdr\code = #SCN_MODIFIED
   
   LenghofLines =  Len(StrU(ScintillaSendMessage(#Scintilla, #SCI_GETLINECOUNT), #Long))

    If LenghofLines > 3
   
      ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37+(LenghofLines-3)*10)
     
    Else
     
      ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
 
    EndIf
 
  EndIf
 
EndProcedure

Procedure WindowCallback(WindowID, Message, wParam, lParam)
  ReturnValue = #PB_ProcessPureBasicEvents
 
    If Message = #WM_MOVE
   
   
    ElseIf Message = #WM_GETMINMAXINFO
   
        *pMinMax.MINMAXINFO = lParam
        *pMinMax\ptMinTrackSize\x=#MinWidth
        *pMinMax\ptMinTrackSize\y=#MinHeight
        *pMinMax\ptMaxTrackSize\x=#MaxWidth
        *pMinMax\ptMaxTrackSize\y=#MaxHeight
        ReturnValue = 0


    ElseIf Message = #WM_SIZE

       
        ResizeGadget(#Scintilla,0,0,WindowWidth(#Window),WindowHeight(#Window))
   
   
    ElseIf Message = #WM_ACTIVATE
   
        SetFocus_(GadgetID(#Scintilla))
   
    EndIf
       
   
    ProcedureReturn  ReturnValue

EndProcedure

Procedure LoadFile(filename.s)
    If filename <> ""
        file.l = ReadFile(#PB_Any, filename)
        If file <> 0
            len.l = Lof(file)
            *mem = AllocateMemory(len)
            If *mem
                ReadData(file, *mem, len)
                ScintillaSendMessage(#Scintilla, #SCI_SETTEXT, 0, *mem)
                FreeMemory(*mem)
            EndIf
            CloseFile(file)
        EndIf
      LenghofLines =  Len(StrU(ScintillaSendMessage(#Scintilla, #SCI_GETLINECOUNT), #Long))
       
      If LenghofLines > 3
   
        ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37+(LenghofLines-3)*10)
     
      Else
     
        ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
 
      EndIf
     
    EndIf
EndProcedure

OpenWindow(#Window, 130, 50, 655, 445, "CommenntedASM By Peyman", #PB_Window_SizeGadget|#PB_Window_SystemMenu)
InitScintilla("C:\Program Files\PureBasic\Compilers\Scintilla.dll")
SetWindowCallback(@WindowCallback())

CreateGadgetList(WindowID(#Window))


GetClientRect_(WindowID(#Window), rect.RECT)

ScintillaGadget(#Scintilla, 0, 0, rect\right, rect\bottom, @ScintillaCallBack())



; Delete Tab Key For Tab in Scintilla
RemoveKeyboardShortcut(#Window, #PB_Shortcut_Tab)
RemoveKeyboardShortcut(#Window, #PB_Shortcut_Tab | #PB_Shortcut_Shift)

; Other
ScintillaSendMessage(#Scintilla, #SCI_SETINDENT, 2)


; Font And Size
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFONT, #STYLE_DEFAULT, @"Courier New")
ScintillaSendMessage(#Scintilla, #SCI_STYLESETSIZE, #STYLE_DEFAULT, 10)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 50)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINMASKN, 2, #SC_MASK_FOLDERS)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 1, 1)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 2, 7)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINSENSITIVEN, 2, #True)


;lex setup
ScintillaSendMessage(#Scintilla, #SCI_SETLEXER, #SCLEX_ASM, 0)
ScintillaSendMessage(#Scintilla, #SCI_SETSTYLEBITS, 5, 0)
ScintillaSendMessage(#Scintilla,#SCI_STYLESETFORE, #STYLE_DEFAULT, RGB(0,0,0));
ScintillaSendMessage(#Scintilla,#SCI_STYLESETBACK, #STYLE_DEFAULT, RGB(255,255,255));
ScintillaSendMessage(#Scintilla,#SCI_STYLECLEARALL);

; Set caret line colour
ScintillaSendMessage(#Scintilla, #SCI_SETCARETLINEBACK, 16771304)
ScintillaSendMessage(#Scintilla, #SCI_SETCARETLINEVISIBLE, #True)



; Set styles for custom lexer
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_DEFAULT, 0) ; Default Color
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_COMMENT, 32768) ; Coment Color
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFONT, #SCE_ASM_COMMENT, @"Comic Sans MS") ; Coment Font
ScintillaSendMessage(#Scintilla, #SCI_STYLESETSIZE, #SCE_ASM_COMMENT, 8) ; Coment Size
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_NUMBER, 33023)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_STRING, 8421504)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_OPERATOR, 8388608)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_OPERATOR, #True) ; set operator Bold
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_IDENTIFIER, 0)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_CPUINSTRUCTION, 16711680)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_CPUINSTRUCTION, #True) ; set Cpuinstruction Bold
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_MATHINSTRUCTION, 12615680)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_MATHINSTRUCTION, #True)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_REGISTER, 16744576) ; Set Front Register Color
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBACK, #SCE_ASM_REGISTER, 13434879) ; Set Back Register Color
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_REGISTER, #True)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_DIRECTIVE, 16744448)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_DIRECTIVEOPERAND, 8388608)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_DIRECTIVEOPERAND, #True)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_COMMENTBLOCK, 32768)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFONT, #SCE_ASM_COMMENTBLOCK, @"Comic Sans MS")
ScintillaSendMessage(#Scintilla, #SCI_STYLESETSIZE, #SCE_ASM_COMMENTBLOCK, 8)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_CHARACTER, 32896)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_STRINGEOL, 8421504)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_ASM_EXTINSTRUCTION, 16512)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBOLD, #SCE_ASM_EXTINSTRUCTION, #True)


; Color Of Selection
ScintillaSendMessage(#Scintilla, #SCI_SETSELBACK, #True, RGB(49, 106, 197))
ScintillaSendMessage(#Scintilla, #SCI_SETSELFORE, #True, RGB(255, 255, 255))


; Code Wraper
;ScintillaSendMessage(#Scintilla, #SCI_SETWRAPMODE, #SC_WRAP_WORD, 0)
;ScintillaSendMessage(#Scintilla, #SCI_SETWRAPVISUALFLAGS, #SC_WRAPVISUALFLAG_START | #SC_WRAPVISUALFLAG_END, 0)


; Keyword
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 0, @Keyword)  ; Set KeyWord 1
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 1, @Keyword2) ; Set KeyWord 2
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 2, @Keyword3) ; Set KeyWord 3
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 3, @Keyword4) ; Set KeyWord 4
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 4, @Keyword5) ; Set KeyWord 5
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 5, @Keyword6) ; Set KeyWord 6


SetFocus_(GadgetID(#Scintilla))



Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow 
Peyman
Enthusiast
Enthusiast
Posts: 203
Joined: Mon Dec 24, 2007 4:15 pm
Location: Iran

Another Example

Post by Peyman »

If you dont use Scintilla Lib 100% must Use and Call Scintilla DLL Out of Your Program. i using Lib because it is Up to dated.
This is Another Example with Folding Functions (For Autoit3):

Without Lib :

Code: Select all

;******************************************************
;   Program:          Scintilla Examp2 (With fold)
;   Author:           Peyman
;   Date:             April 2, 2008
;   Target OS:        Windows All
;   Target Compiler:  PureBasic 4.0 +
;   License:          Freeware
;******************************************************

 ;{ Enumeration
Enumeration
#Window    = 0
#Scintilla = 1
#MinWidth  = 400
#MinHeight = 300
#MaxWidth  = 800
#MaxHeight = 600
EndEnumeration
;}

 ;{ KeyWord
Keyword.s = "and byref case continueloop dim do else elseif endfunc endif endselect exit exitloop for func global if local next not or return select step then to until wend while exit"
Keyword2.s = "abs acos adlibdisable adlibenable asc asin atan autoitsetoption autoitwingettitle autoitwinsettitle bitand bitnot bitor bitshift bitxor blockinput break call cdtray chr clipget clipput controlclick controlcommand controldisable controlenable controlfocus controlgetfocus controlgetpos controlgettext controlhide controlmove controlsend controlsettext controlshow cos dec dircopy dircreate dirmove dirremove drivegetdrive drivegetfilesystem drivegetlabel drivegetserial drivegettype drivesetlabel drivespacefree drivespacetotal drivestatus envget envset envupdate eval exp filechangedir fileclose filecopy filecreateshortcut filedelete fileexists filefindfirstfile filefindnextfile filegetattrib filegetlongname filegetshortname filegetsize filegettime filegetversion fileinstall filemove fileopen fileopendialog fileread filereadline filerecycle filerecycleempty filesavedialog fileselectfolder filesetattrib filesettime filewrite filewriteline guicreate guicreateex guidefaultfont guidelete guigetcontrolstate guihide guimsg guiread guirecvmsg guisendmsg guisetcontrol guisetcontroldata guisetcontrolex guisetcontrolfont guisetcontrolnotify guisetcoord guisetcursor guishow guiwaitclose guiwrite hex hotkeyset inidelete iniread iniwrite inputbox int isadmin isarray isdeclared isfloat isint isnumber isstring log memgetstats mod mouseclick mouseclickdrag mousedown mousegetcursor mousegetpos mousemove mouseup mousewheel msgbox number pixelchecksum pixelgetcolor pixelsearch processclose processexists processsetpriority processwait processwaitclose progressoff progresson progressset random regdelete regenumkey regenumval regread regwrite round run runasset runwait send seterror shutdown sin sleep soundplay soundsetwavevolume splashimageon splashoff splashtexton sqrt statusbargettext string stringaddcr stringformat stringinstr stringisalnum stringisalpha stringisascii stringisdigit stringisfloat stringisint stringislower stringisspace stringisupper stringisxdigit stringleft stringlen stringlower stringmid stringreplace stringright stringsplit stringstripcr stringstripws stringtrimleft stringtrimright stringupper tan timerstart timerstop tooltip traytip ubound urldownloadtofile winactivate winactive winclose winexists wingetcaretpos wingetclasslist wingetclientsize wingethandle wingetpos wingetstate wingettext wingettitle winkill winmenuselectitem winminimizeall winminimizeallundo winmove winsetontop winsetstate winsettitle winwait winwaitactive winwaitclose winwaitnotactive"
Keyword3.s = "@appdatacommondir @appdatadir @autoitversion @commonfilesdir @compiled @computername @comspec @cr @crlf @desktopcommondir @desktopdir @desktopheight @desktopwidth @documentscommondir @error @favoritescommondir @favoritesdir @homedrive @homepath @homeshare @hour @ipaddress1 @ipaddress2 @ipaddress3 @ipaddress4 @lf @logondnsdomain @logondomain @logonserver @mday @min @mon @mydocumentsdir @osbuild @oslang @osservicepack @ostype @osversion @programfilesdir @programscommondir @programsdir @scriptdir @scriptfullpath @scriptname @sec @startmenucommondir @startmenudir @startupcommondir @startupdir @sw_hide @sw_maximize @sw_minimize @sw_restore @sw_show @systemdir @tab @tempdir @userprofiledir @username @wday @windowsdir @workingdir @yday @year"
Keyword4.s = "{!} {#} {^} {{} {}} {+} {alt} {altdown} {altup} {appskey} {asc} {backspace} {browser_back} {browser_favorites} {browser_forward} {browser_home} {browser_refresh} {browser_search} {browser_stop} {bs} {capslock} {ctrlbreak} {ctrldown} {ctrlup} {del} {delete} {down} {end} {enter} {esc} {escape} {f1} {f10} {f11} {f12} {f2} {f3} {f4} {f5} {f6} {f7} {f8} {f9} {home} {ins} {insert} {lalt} {launch_app1} {launch_app2} {launch_mail} {launch_media} {lctrl} {left} {lshift} {lwin} {lwindown} {media_next} {media_play_pause} {media_prev} {media_stop} {numlock} {numpad0} {numpad1} {numpad2} {numpad3} {numpad4} {numpad5} {numpad6} {numpad7} {numpad8} {numpad9} {numpadadd} {numpaddiv} {numpaddot} {numpadenter} {numpadmult} {numpadsub} {pause} {pgdn} {pgup} {printscreen} {ralt} {rctrl} {right} {rshift} {rwin} {rwindown} {scrolllock} {shiftdown} {shiftup} {sleep} {space} {tab} {up} {volume_down} {volume_mute} {volume_up}"
Keyword5.s = "#include #include-once"
Keyword6.s = "#region #endregion"
;}

ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)

  If *scinotify\nmhdr\code = #SCN_MARGINCLICK
    modifiers = *scinotify\modifiers
    position = *scinotify\position
    margin = *scinotify\margin
    linenumber = ScintillaSendMessage(#Scintilla, #SCI_LINEFROMPOSITION, position)
    Select margin
        Case 2
            ScintillaSendMessage(#Scintilla, #SCI_TOGGLEFOLD, linenumber)
    EndSelect
    
  
;  ElseIf *scinotify\nmhdr\code = #SCN_MODIFIED

;    Debug *scinotify\ch
;    Debug *scinotify\modifiers

   ElseIf *scinotify\nmhdr\code = #SCN_MODIFIED

    LenghofLines =  Len(StrU(ScintillaSendMessage(#Scintilla, #SCI_GETLINECOUNT), #Long))
    
    If LenghofLines > 3
    
      ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37+(LenghofLines-3)*10)
      
    Else
      
      ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
 
    EndIf
 
 
  EndIf
  
EndProcedure

Procedure WindowCallback(WindowID, Message, wParam, lParam)
  ReturnValue = #PB_ProcessPureBasicEvents
 
    If Message = #WM_MOVE
   
   
    ElseIf Message = #WM_GETMINMAXINFO
   
        *pMinMax.MINMAXINFO = lParam
        *pMinMax\ptMinTrackSize\x=#MinWidth
        *pMinMax\ptMinTrackSize\y=#MinHeight
        *pMinMax\ptMaxTrackSize\x=#MaxWidth
        *pMinMax\ptMaxTrackSize\y=#MaxHeight
        ReturnValue = 0


    ElseIf Message = #WM_SIZE

       
        ResizeGadget(#Scintilla,0,0,WindowWidth(#Window),WindowHeight(#Window))
   
   
    ElseIf Message = #WM_ACTIVATE
   
        SetFocus_(GadgetID(#Scintilla))
   
    EndIf
       
   
    ProcedureReturn  ReturnValue

EndProcedure

Procedure LoadFile(filename.s)
    If filename <> ""
        file.l = ReadFile(#PB_Any, filename)
        If file <> 0
            len.l = Lof(file)
            *mem = AllocateMemory(len)
            If *mem
                ReadData(file, *mem, len)
                ScintillaSendMessage(#Scintilla, #SCI_SETTEXT, 0, *mem)
                FreeMemory(*mem)
            EndIf
            CloseFile(file)
        EndIf
      LenghofLines =  Len(StrU(ScintillaSendMessage(#Scintilla, #SCI_GETLINECOUNT), #Long))
       
      If LenghofLines > 3
   
        ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37+(LenghofLines-3)*10)
     
      Else
     
        ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
 
      EndIf
     
    EndIf
EndProcedure

OpenWindow(#Window, 130, 50, 655, 445, "AutoIt 3.0 By Peyman", #PB_Window_SizeGadget|#PB_Window_SystemMenu)
InitScintilla("C:\Program Files\PureBasic\Compilers\Scintilla.dll")
SetWindowCallback(@WindowCallback())

CreateGadgetList(WindowID(#Window))


GetClientRect_(WindowID(#Window), rect.RECT)

ScintillaGadget(#Scintilla, 0, 0, rect\right, rect\bottom, @ScintillaCallBack())



; Delete Tab Key For Tab in Scintilla
RemoveKeyboardShortcut(#Window, #PB_Shortcut_Tab)
RemoveKeyboardShortcut(#Window, #PB_Shortcut_Tab | #PB_Shortcut_Shift)

; Other
ScintillaSendMessage(#Scintilla, #SCI_SETINDENT, 2)


; Font And Size
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFONT, #STYLE_DEFAULT, @"Courier New") 
ScintillaSendMessage(#Scintilla, #SCI_STYLESETSIZE, #STYLE_DEFAULT, 10) 
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER) 
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 50)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINMASKN, 2, #SC_MASK_FOLDERS)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 1, 1)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 2, 18)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINSENSITIVEN, 2, #True)


; Choose folding icons
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEROPEN, #SC_MARK_BOXMINUS)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDER, #SC_MARK_BOXPLUS)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERSUB, #SC_MARK_VLINE)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERTAIL, #SC_MARK_LCORNER)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEREND, #SC_MARK_BOXPLUSCONNECTED)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEROPENMID, #SC_MARK_BOXMINUSCONNECTED)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERMIDTAIL, #SC_MARK_TCORNER)
;

; Choose folding icon colours
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETFORE, #SC_MARKNUM_FOLDEROPEN, RGB(236, 233, 216))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDEROPEN, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETFORE, #SC_MARKNUM_FOLDER, RGB(236, 233, 216))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDER, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDERSUB, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDERTAIL, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETFORE, #SC_MARKNUM_FOLDEREND, RGB(236, 233, 216))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDEREND, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETFORE, #SC_MARKNUM_FOLDEROPENMID, RGB(236, 233, 216))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDEROPENMID, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDERMIDTAIL, RGB(128, 128, 128))


;lex setup
ScintillaSendMessage(#Scintilla, #SCI_SETLEXER, #SCLEX_AU3, 0)
ScintillaSendMessage(#Scintilla, #SCI_SETSTYLEBITS, 5, 0)
ScintillaSendMessage(#Scintilla,#SCI_STYLESETFORE, #STYLE_DEFAULT, RGB(0,0,0));
ScintillaSendMessage(#Scintilla,#SCI_STYLESETBACK, #STYLE_DEFAULT, RGB(255,255,255));
ScintillaSendMessage(#Scintilla,#SCI_STYLECLEARALL);

; Set caret line colour
ScintillaSendMessage(#Scintilla, #SCI_SETCARETLINEBACK, 16771304)
ScintillaSendMessage(#Scintilla, #SCI_SETCARETLINEVISIBLE, #True)



; Set styles for custom lexer
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_DEFAULT, 0) ; Default Color
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_COMMENT, 32768) ; Coment Color
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFONT, #SCE_AU3_COMMENT, @"Comic Sans MS") ; Coment Font
ScintillaSendMessage(#Scintilla, #SCI_STYLESETSIZE, #SCE_AU3_COMMENT, 8) ; Coment Size
ScintillaSendMessage(#Scintilla, #SCI_STYLESETSIZE, #SCE_AU3_COMMENTBLOCK, 8) ; Coment Size
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_COMMENTBLOCK, 32768) ; Coment Color
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFONT, #SCE_AU3_COMMENTBLOCK, @"Comic Sans MS") ; Coment Font
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_NUMBER, 33023)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_FUNCTION, 16711808)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_MACRO, 16711808)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_STRING, 8421504)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_OPERATOR, 8388608)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBOLD, #SCE_AU3_OPERATOR, #True) ; set operator Bold
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_VARIABLE, 8388863)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETITALIC, #SCE_AU3_VARIABLE, #True)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_SENT, 12615808)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_PREPROCESSOR, 16512)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_SPECIAL, 0)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_KEYWORD, 16711680)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBOLD, #SCE_AU3_KEYWORD, #True)



; Color Of Selection
ScintillaSendMessage(#Scintilla, #SCI_SETSELBACK, #True, RGB(49, 106, 197))
ScintillaSendMessage(#Scintilla, #SCI_SETSELFORE, #True, RGB(255, 255, 255))


; Code Wraper
;ScintillaSendMessage(#Scintilla, #SCI_SETWRAPMODE, #SC_WRAP_WORD, 0)
;ScintillaSendMessage(#Scintilla, #SCI_SETWRAPVISUALFLAGS, #SC_WRAPVISUALFLAG_START | #SC_WRAPVISUALFLAG_END, 0)


; Keyword
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 0, @Keyword)  ; Set KeyWord 1
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 1, @Keyword2) ; Set KeyWord 2
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 2, @Keyword3) ; Set KeyWord 3
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 3, @Keyword4) ; Set KeyWord 4
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 4, @Keyword5) ; Set KeyWord 5
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 5, @Keyword6) ; Set KeyWord 6



; Working Fold 
ScintillaSendMessage(#Scintilla, #SCI_SETPROPERTY, @"fold", @"1")
ScintillaSendMessage(#Scintilla, #SCI_SETPROPERTY, @"fold.compact", @"0")
;ScintillaSendMessage(#Scintilla, #SCI_SETPROPERTY, @"fold.comment", @"1") ; If enable this Line Your Comment get Fold
ScintillaSendMessage(#Scintilla, #SCI_SETPROPERTY, @"fold.preprocessor", @"1")


SetFocus_(GadgetID(#Scintilla))



Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
With Lib (Gonzal Library) :

Code: Select all

;******************************************************
;   Program:          Scintilla Examp2 (With fold)
;   Author:           Peyman
;   Date:             April 2, 2008
;   Target OS:        Windows All
;   Target Compiler:  PureBasic 4.0 +
;   License:          Freeware
;******************************************************

 ;{ Enumeration
Enumeration
#Window    = 0
#Scintilla = 1
#MinWidth  = 400
#MinHeight = 300
#MaxWidth  = 800
#MaxHeight = 600
EndEnumeration
;}

 ;{ KeyWord
Keyword.s = "and byref case continueloop dim do else elseif endfunc endif endselect exit exitloop for func global if local next not or return select step then to until wend while exit"
Keyword2.s = "abs acos adlibdisable adlibenable asc asin atan autoitsetoption autoitwingettitle autoitwinsettitle bitand bitnot bitor bitshift bitxor blockinput break call cdtray chr clipget clipput controlclick controlcommand controldisable controlenable controlfocus controlgetfocus controlgetpos controlgettext controlhide controlmove controlsend controlsettext controlshow cos dec dircopy dircreate dirmove dirremove drivegetdrive drivegetfilesystem drivegetlabel drivegetserial drivegettype drivesetlabel drivespacefree drivespacetotal drivestatus envget envset envupdate eval exp filechangedir fileclose filecopy filecreateshortcut filedelete fileexists filefindfirstfile filefindnextfile filegetattrib filegetlongname filegetshortname filegetsize filegettime filegetversion fileinstall filemove fileopen fileopendialog fileread filereadline filerecycle filerecycleempty filesavedialog fileselectfolder filesetattrib filesettime filewrite filewriteline guicreate guicreateex guidefaultfont guidelete guigetcontrolstate guihide guimsg guiread guirecvmsg guisendmsg guisetcontrol guisetcontroldata guisetcontrolex guisetcontrolfont guisetcontrolnotify guisetcoord guisetcursor guishow guiwaitclose guiwrite hex hotkeyset inidelete iniread iniwrite inputbox int isadmin isarray isdeclared isfloat isint isnumber isstring log memgetstats mod mouseclick mouseclickdrag mousedown mousegetcursor mousegetpos mousemove mouseup mousewheel msgbox number pixelchecksum pixelgetcolor pixelsearch processclose processexists processsetpriority processwait processwaitclose progressoff progresson progressset random regdelete regenumkey regenumval regread regwrite round run runasset runwait send seterror shutdown sin sleep soundplay soundsetwavevolume splashimageon splashoff splashtexton sqrt statusbargettext string stringaddcr stringformat stringinstr stringisalnum stringisalpha stringisascii stringisdigit stringisfloat stringisint stringislower stringisspace stringisupper stringisxdigit stringleft stringlen stringlower stringmid stringreplace stringright stringsplit stringstripcr stringstripws stringtrimleft stringtrimright stringupper tan timerstart timerstop tooltip traytip ubound urldownloadtofile winactivate winactive winclose winexists wingetcaretpos wingetclasslist wingetclientsize wingethandle wingetpos wingetstate wingettext wingettitle winkill winmenuselectitem winminimizeall winminimizeallundo winmove winsetontop winsetstate winsettitle winwait winwaitactive winwaitclose winwaitnotactive"
Keyword3.s = "@appdatacommondir @appdatadir @autoitversion @commonfilesdir @compiled @computername @comspec @cr @crlf @desktopcommondir @desktopdir @desktopheight @desktopwidth @documentscommondir @error @favoritescommondir @favoritesdir @homedrive @homepath @homeshare @hour @ipaddress1 @ipaddress2 @ipaddress3 @ipaddress4 @lf @logondnsdomain @logondomain @logonserver @mday @min @mon @mydocumentsdir @osbuild @oslang @osservicepack @ostype @osversion @programfilesdir @programscommondir @programsdir @scriptdir @scriptfullpath @scriptname @sec @startmenucommondir @startmenudir @startupcommondir @startupdir @sw_hide @sw_maximize @sw_minimize @sw_restore @sw_show @systemdir @tab @tempdir @userprofiledir @username @wday @windowsdir @workingdir @yday @year"
Keyword4.s = "{!} {#} {^} {{} {}} {+} {alt} {altdown} {altup} {appskey} {asc} {backspace} {browser_back} {browser_favorites} {browser_forward} {browser_home} {browser_refresh} {browser_search} {browser_stop} {bs} {capslock} {ctrlbreak} {ctrldown} {ctrlup} {del} {delete} {down} {end} {enter} {esc} {escape} {f1} {f10} {f11} {f12} {f2} {f3} {f4} {f5} {f6} {f7} {f8} {f9} {home} {ins} {insert} {lalt} {launch_app1} {launch_app2} {launch_mail} {launch_media} {lctrl} {left} {lshift} {lwin} {lwindown} {media_next} {media_play_pause} {media_prev} {media_stop} {numlock} {numpad0} {numpad1} {numpad2} {numpad3} {numpad4} {numpad5} {numpad6} {numpad7} {numpad8} {numpad9} {numpadadd} {numpaddiv} {numpaddot} {numpadenter} {numpadmult} {numpadsub} {pause} {pgdn} {pgup} {printscreen} {ralt} {rctrl} {right} {rshift} {rwin} {rwindown} {scrolllock} {shiftdown} {shiftup} {sleep} {space} {tab} {up} {volume_down} {volume_mute} {volume_up}"
Keyword5.s = "#include #include-once"
Keyword6.s = "#region #endregion"
;}

ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)

  If *scinotify\nmhdr\code = #SCN_MARGINCLICK
    modifiers = *scinotify\modifiers
    position = *scinotify\position
    margin = *scinotify\margin
    linenumber = ScintillaSendMessage(#Scintilla, #SCI_LINEFROMPOSITION, position)
    Select margin
        Case 2
            ScintillaSendMessage(#Scintilla, #SCI_TOGGLEFOLD, linenumber)
    EndSelect
    
  
;  ElseIf *scinotify\nmhdr\code = #SCN_MODIFIED

;    Debug *scinotify\ch
;    Debug *scinotify\modifiers

   ElseIf *scinotify\nmhdr\code = #SCN_MODIFIED

    LenghofLines =  Len(StrU(ScintillaSendMessage(#Scintilla, #SCI_GETLINECOUNT), #Long))
    
    If LenghofLines > 3
    
      ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37+(LenghofLines-3)*10)
      
    Else
      
      ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
 
    EndIf
 
 
  EndIf
  
EndProcedure

Procedure WindowCallback(WindowID, Message, wParam, lParam)
  ReturnValue = #PB_ProcessPureBasicEvents
 
    If Message = #WM_MOVE
   
   
    ElseIf Message = #WM_GETMINMAXINFO
   
        *pMinMax.MINMAXINFO = lParam
        *pMinMax\ptMinTrackSize\x=#MinWidth
        *pMinMax\ptMinTrackSize\y=#MinHeight
        *pMinMax\ptMaxTrackSize\x=#MaxWidth
        *pMinMax\ptMaxTrackSize\y=#MaxHeight
        ReturnValue = 0


    ElseIf Message = #WM_SIZE

       
        ResizeGadget(#Scintilla,0,0,WindowWidth(#Window),WindowHeight(#Window))
   
   
    ElseIf Message = #WM_ACTIVATE
   
        SetFocus_(GadgetID(#Scintilla))
   
    EndIf
       
   
    ProcedureReturn  ReturnValue

EndProcedure

Procedure LoadFile(filename.s)
    If filename <> ""
        file.l = ReadFile(#PB_Any, filename)
        If file <> 0
            len.l = Lof(file)
            *mem = AllocateMemory(len)
            If *mem
                ReadData(file, *mem, len)
                ScintillaSendMessage(#Scintilla, #SCI_SETTEXT, 0, *mem)
                FreeMemory(*mem)
            EndIf
            CloseFile(file)
        EndIf
      LenghofLines =  Len(StrU(ScintillaSendMessage(#Scintilla, #SCI_GETLINECOUNT), #Long))
       
      If LenghofLines > 3
   
        ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37+(LenghofLines-3)*10)
     
      Else
     
        ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
 
      EndIf
     
    EndIf
EndProcedure

OpenWindow(#Window, 130, 50, 655, 445, "AutoIt 3.0 By Peyman", #PB_Window_SizeGadget|#PB_Window_SystemMenu)
InitScintillaStaticFull()
SetWindowCallback(@WindowCallback())

CreateGadgetList(WindowID(#Window))


GetClientRect_(WindowID(#Window), rect.RECT)

ScintillaGadget(#Scintilla, 0, 0, rect\right, rect\bottom, @ScintillaCallBack())



; Delete Tab Key For Tab in Scintilla
RemoveKeyboardShortcut(#Window, #PB_Shortcut_Tab)
RemoveKeyboardShortcut(#Window, #PB_Shortcut_Tab | #PB_Shortcut_Shift)

; Other
ScintillaSendMessage(#Scintilla, #SCI_SETINDENT, 2)


; Font And Size
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFONT, #STYLE_DEFAULT, @"Courier New") 
ScintillaSendMessage(#Scintilla, #SCI_STYLESETSIZE, #STYLE_DEFAULT, 10) 
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER) 
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 50)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINMASKN, 2, #SC_MASK_FOLDERS)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 0, 37)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 1, 1)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINWIDTHN, 2, 18)
ScintillaSendMessage(#Scintilla, #SCI_SETMARGINSENSITIVEN, 2, #True)


; Choose folding icons
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEROPEN, #SC_MARK_BOXMINUS)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDER, #SC_MARK_BOXPLUS)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERSUB, #SC_MARK_VLINE)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERTAIL, #SC_MARK_LCORNER)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEREND, #SC_MARK_BOXPLUSCONNECTED)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDEROPENMID, #SC_MARK_BOXMINUSCONNECTED)
ScintillaSendMessage(#Scintilla, #SCI_MARKERDEFINE, #SC_MARKNUM_FOLDERMIDTAIL, #SC_MARK_TCORNER)
;

; Choose folding icon colours
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETFORE, #SC_MARKNUM_FOLDEROPEN, RGB(236, 233, 216))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDEROPEN, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETFORE, #SC_MARKNUM_FOLDER, RGB(236, 233, 216))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDER, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDERSUB, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDERTAIL, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETFORE, #SC_MARKNUM_FOLDEREND, RGB(236, 233, 216))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDEREND, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETFORE, #SC_MARKNUM_FOLDEROPENMID, RGB(236, 233, 216))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDEROPENMID, RGB(128, 128, 128))
ScintillaSendMessage(#Scintilla, #SCI_MARKERSETBACK, #SC_MARKNUM_FOLDERMIDTAIL, RGB(128, 128, 128))


;lex setup
ScintillaSendMessage(#Scintilla, #SCI_SETLEXER, #SCLEX_AU3, 0)
ScintillaSendMessage(#Scintilla, #SCI_SETSTYLEBITS, 5, 0)
ScintillaSendMessage(#Scintilla,#SCI_STYLESETFORE, #STYLE_DEFAULT, RGB(0,0,0));
ScintillaSendMessage(#Scintilla,#SCI_STYLESETBACK, #STYLE_DEFAULT, RGB(255,255,255));
ScintillaSendMessage(#Scintilla,#SCI_STYLECLEARALL);

; Set caret line colour
ScintillaSendMessage(#Scintilla, #SCI_SETCARETLINEBACK, 16771304)
ScintillaSendMessage(#Scintilla, #SCI_SETCARETLINEVISIBLE, #True)



; Set styles for custom lexer
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_DEFAULT, 0) ; Default Color
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_COMMENT, 32768) ; Coment Color
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFONT, #SCE_AU3_COMMENT, @"Comic Sans MS") ; Coment Font
ScintillaSendMessage(#Scintilla, #SCI_STYLESETSIZE, #SCE_AU3_COMMENT, 8) ; Coment Size
ScintillaSendMessage(#Scintilla, #SCI_STYLESETSIZE, #SCE_AU3_COMMENTBLOCK, 8) ; Coment Size
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_COMMENTBLOCK, 32768) ; Coment Color
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFONT, #SCE_AU3_COMMENTBLOCK, @"Comic Sans MS") ; Coment Font
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_NUMBER, 33023)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_FUNCTION, 16711808)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_MACRO, 16711808)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_STRING, 8421504)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_OPERATOR, 8388608)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBOLD, #SCE_AU3_OPERATOR, #True) ; set operator Bold
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_VARIABLE, 8388863)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETITALIC, #SCE_AU3_VARIABLE, #True)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_SENT, 12615808)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_PREPROCESSOR, 16512)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_SPECIAL, 0)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETFORE, #SCE_AU3_KEYWORD, 16711680)
ScintillaSendMessage(#Scintilla, #SCI_STYLESETBOLD, #SCE_AU3_KEYWORD, #True)



; Color Of Selection
ScintillaSendMessage(#Scintilla, #SCI_SETSELBACK, #True, RGB(49, 106, 197))
ScintillaSendMessage(#Scintilla, #SCI_SETSELFORE, #True, RGB(255, 255, 255))


; Code Wraper
;ScintillaSendMessage(#Scintilla, #SCI_SETWRAPMODE, #SC_WRAP_WORD, 0)
;ScintillaSendMessage(#Scintilla, #SCI_SETWRAPVISUALFLAGS, #SC_WRAPVISUALFLAG_START | #SC_WRAPVISUALFLAG_END, 0)


; Keyword
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 0, @Keyword)  ; Set KeyWord 1
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 1, @Keyword2) ; Set KeyWord 2
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 2, @Keyword3) ; Set KeyWord 3
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 3, @Keyword4) ; Set KeyWord 4
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 4, @Keyword5) ; Set KeyWord 5
ScintillaSendMessage(#Scintilla, #SCI_SETKEYWORDS, 5, @Keyword6) ; Set KeyWord 6



; Working Fold 
ScintillaSendMessage(#Scintilla, #SCI_SETPROPERTY, @"fold", @"1")
ScintillaSendMessage(#Scintilla, #SCI_SETPROPERTY, @"fold.compact", @"0")
;ScintillaSendMessage(#Scintilla, #SCI_SETPROPERTY, @"fold.comment", @"1") ; If enable this Line Your Comment get Fold
ScintillaSendMessage(#Scintilla, #SCI_SETPROPERTY, @"fold.preprocessor", @"1")


SetFocus_(GadgetID(#Scintilla))



Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Without Lib, the code doesn't run : no syntax highlighting, no folding
With Lib, no problem !
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Ok, here's what i've done (without any help or manual to read from)

Not quite sure how to trigger the autocomplete thing when user types :?

Code: Select all

Enumeration
EndEnumeration

Enumeration
  #Panel_0
  #Window_0
EndEnumeration

Global  Scintilla_1, Web_0


 InitScintilla("E:\programing\PB4\Compilers\Scintilla.dll") ; <-------- Change Here!!!


ProcedureDLL ScintillaCallBack(Gadget, *scinotify.SCNotification)
  
  
EndProcedure

Procedure Open_Window_0()
  
  AutoText$ = "PB_Window_ScreenCentered"
  AutoText$ + " PB_Window_WindowCentered"
  AutoText$ + " PB_Window_SystemMenu"
  AutoText$ + " PB_Window_Maximize"
  AutoText$ + " PB_Window_MaximizeGadget"
  AutoText$ + " PB_Window_Minimize"
  AutoText$ + " PB_Window_TitleBar"
  AutoText$ + " PB_Window_MinimizeGadget"
  AutoText$ + " PB_Window_SizeGadget"
  AutoText$ + " PB_Window_Invisible"
  AutoText$ + " PB_Window_BorderLess" 
  
  Window_0 = OpenWindow(#PB_Any, 71, 33, 619, 417, "Editor",  #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
  If Window_0
    If CreateGadgetList(WindowID(Window_0))
      PanelGadget(#Panel_0, 0, 15, 612, 373)
        AddGadgetItem(#Panel_0, 1, "Code")
        Scintilla_1 = ScintillaGadget(#PB_Any, 3, 3, 602, 343 ,@ScintillaCallBack())
        AddGadgetItem(Panel_0, 2, "Tab 2")
        Web_0 = WebGadget(#PB_Any, 3, 3, 602, 343, "about:blank")
      CloseGadgetList()
      ScintillaSendMessage(Scintilla_1,#SCI_AUTOCSETIGNORECASE,#True)
      ScintillaSendMessage(Scintilla_1,#SCI_AUTOCSHOW,1,@AutoText$)
      ScintillaSendMessage(Scintilla_1,#SCI_SETLEXER,#SCLEX_CONTAINER)
      ScintillaSendMessage(Scintilla_1,#SCI_SETEOLMODE,#SC_EOL_CRLF)
      ScintillaSendMessage(Scintilla_1,#SCI_SETMODEVENTMASK,#SC_MOD_INSERTTEXT|#SC_MOD_DELETETEXT|#SC_PERFORMED_USER|#SC_PERFORMED_UNDO|#SC_PERFORMED_REDO|#SC_LASTSTEPINUNDOREDO|#SC_MOD_BEFOREINSERT|#SC_MOD_BEFOREDELETE)
      ScintillaSendMessage(Scintilla_1,#SCI_SETUSETABS,#False)  
      ScintillaSendMessage(Scintilla_1,#SCI_SETTABINDENTS,#True)
      
    EndIf
  EndIf
EndProcedure

Open_Window_0()

Repeat
  
  Event  = WaitWindowEvent()
  
Until Event = #PB_Event_CloseWindow

End
Peyman
Enthusiast
Enthusiast
Posts: 203
Joined: Mon Dec 24, 2007 4:15 pm
Location: Iran

Post by Peyman »

Progi1984 wrote:Without Lib, the code doesn't run : no syntax highlighting, no folding
With Lib, no problem !
Bacause your version of Scintilla.dll is very old(1.7.3), you must use 1.7.5 or newer.
if you use lib you never need Scintilla.dll, but if you dont like use lib must use newer version of Scintilla.dll.
you can download it from http://www.scintilla.org/
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

The download at http://www.scintilla.org/ only includes scilexer.dll

If you download & install my Elementary Reports and look in the dir where the program is installed you will find the latest scintilla.dll (v1.7.6), it's only 194k.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

Peyman wrote:
Progi1984 wrote:Without Lib, the code doesn't run : no syntax highlighting, no folding
With Lib, no problem !
Bacause your version of Scintilla.dll is very old(1.7.3), you must use 1.7.5 or newer.
if you use lib you never need Scintilla.dll, but if you dont like use lib must use newer version of Scintilla.dll.
you can download it from http://www.scintilla.org/
Exactly...
Thanks :-)
Peyman
Enthusiast
Enthusiast
Posts: 203
Joined: Mon Dec 24, 2007 4:15 pm
Location: Iran

Post by Peyman »

DoubleDutch wrote:The download at http://www.scintilla.org/ only includes scilexer.dll

If you download & install my Elementary Reports and look in the dir where the program is installed you will find the latest scintilla.dll (v1.7.6), it's only 194k.
I Recommended You use scilexer.dll, because this is better than scintilla.dll.
You can download it from http://scintilla.sourceforge.net/SciTEDownload.html or http://prdownloads.sourceforge.net/scin ... p?download

download this ZIP and extract it. Rename SciLexer.dll to scintilla.dll and copy it into Your Compiler Folder, you must close PureBasic (For examp : C:\Program Files\PureBasic\Compilers\ )

Use It , EnJoy :wink:
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

I Recommended You use scilexer.dll, because this is better than scintilla.dll.
Better? The only difference between them is that SciLexer.dll has the lexers built-in.

The Scintilla.dll is a lot smaller and if you don't need/want the lexers then why make your install file bigger (if you include scintilla with your app)?

In which case scintilla.dll is better. ;)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply