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