Jump to content

how to create a autoit editor with syntax highlighting?


Recommended Posts

I found this too >>

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Maybe this Example will Help you >>

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Corrected

;========================================
;
; Program Name:     AutoIt Editor
; Description::     Text editor with Syntax highlighter
; Requirement(s):   RICHTEXT.RichTextCtrl
; Author(s):        RazerM
;
;========================================
#include <GUIConstants.au3>
#include <string.au3>
#include <file.au3>
#include <array.au3>
#include "ModernMenu.au3"

Global Const $WS_SIZEBOX = 0x00040000
Global Const $WS_MINIMIZEBOX = 0x00020000
Global Const $WS_CAPTION = 0x00C00000
Global Const $WS_SYSMENU = 0x00080000
Global Const $WS_POPUP = 0x80000000
Global Const $WS_MAXIMIZEBOX = 0x00010000
Global Const $GUI_SS_DEFAULT_GUI = BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)
Global Const $SS_SUNKEN = 0x1000
Global Const $BS_ICON = 0x0040

Global $RichText = ObjCreate("RICHTEXT.RichTextCtrl")
If Not IsObj($RichText) Then
    MsgBox(262144 + 16, "Error", "Your computer does not have the RICHTEXT.RichTextCtrl object.")
    Exit
EndIf

HotKeySet("{F10}", "debug")

Func debug()
    $mode = 0
    If $mode = 0 Then
        $sTemp = $RichText.Text
        $sTemp = StringReplace($sTemp, @CRLF, "|crlf|")
        $sTemp = StringReplace($sTemp, @CR, "|cr|")
        $sTemp = StringReplace($sTemp, @LF, "|lf|")
        ConsoleWrite("[" & $sTemp & "]" & @CRLF)
    Else
        $sTemp = $RichText.TextRTF
        $sTemp = StringReplace($sTemp, @CRLF, "|crlf|")
        $sTemp = StringReplace($sTemp, @CR, "|cr|")
        $sTemp = StringReplace($sTemp, @LF, "|lf|")
        ConsoleWrite("[" & $sTemp & "]" & @CRLF)
    EndIf
EndFunc   ;==>debug

$AppName = "AutoIt Editor - "
$AppEnd = " :: RazerM"
$GUI = GUICreate("Syntax Highlighter - ", 600, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX))

;Global open file
Global $sFile = -1

Global $stringStart = '{\cf0\b ';153, 153, 204
Global $stringEnd = '}';
Global $commentStart = '{\cf2\i '; 0, 153, 51
Global $commentEnd = '}';
Global $keywordStart = '{\\cf1\\b ';0, 0, 255
Global $keywordEnd = '}';
Global $functionStart = '{\\cf3\\i\\b ';0, 0, 144
Global $functionEnd = '}';
Global $numberStart = '{\\cf4\\i\\b ';214, 58, 169
Global $numberEnd = '}';
Global $macroStart = '{\\cf7\\b ';255, 51, 255
Global $macroEnd = '}';
Global $variableStart = '{\\cf5\\b ';170, 0, 0
Global $variableEnd = '}';
Global $hashStart = '{\cf6\i '; 240, 0, 255
Global $hashEnd = '}';
Global $operatorStart = '{\cf8 '; 240, 0, 255
Global $operatorEnd = '}';

GUICtrlCreateLabel("", 10, 5, 580, 40, $SS_SUNKEN)
GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKHEIGHT)
GUICtrlSetState(-1, $GUI_DISABLE)
FileChangeDir(@ScriptDir & "\Icons")
$IconNew = GUICtrlCreateButton("", 15, 10, 30, 30, $BS_ICON)
GUICtrlSetImage(-1, 'new.ico')
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
$IconOpen = GUICtrlCreateButton("", 50, 10, 30, 30, $BS_ICON)
GUICtrlSetImage(-1, 'open.ico')
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
$IconSave = GUICtrlCreateButton("", 85, 10, 30, 30, $BS_ICON)
GUICtrlSetImage(-1, 'save.ico')
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
GUICtrlCreateLabel("", 120, 10, 1, 30)
GUICtrlSetBkColor(-1, 0)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
$IconCut = GUICtrlCreateButton("", 125, 10, 30, 30, $BS_ICON)
GUICtrlSetImage(-1, 'cut.ico')
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
$IconCopy = GUICtrlCreateButton("", 160, 10, 30, 30, $BS_ICON)
GUICtrlSetImage(-1, 'copy.ico')
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)
$IconPaste = GUICtrlCreateButton("", 195, 10, 30, 30, $BS_ICON)
GUICtrlSetImage(-1, 'paste.ico')
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKSIZE)

$GUIActiveX = GUICtrlCreateObj($RichText, 10, 50)
GUICtrlSetPos($GUIActiveX, 10, 50, 580, 420)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)

$FileMenu = GUICtrlCreateMenu("&File")
$FileNew = _GUICtrlCreateODMenuitem ('&New', $FileMenu, 'new.ico', 0)
$FileOpen = _GUICtrlCreateODMenuitem ("&Open", $FileMenu, 'open.ico', 0)
_GUICtrlCreateODMenuitem ("", $FileMenu, '', 0)
$FileSave = _GUICtrlCreateODMenuitem ("&Save", $FileMenu, 'save.ico', 0)
$FileSaveAs = _GUICtrlCreateODMenuitem ("Save &As", $FileMenu, 'saveas.ico', 0)
GUICtrlSetState($FileSaveAs, $GUI_DISABLE)
_GUICtrlCreateODMenuitem ("", $FileMenu, '', 0)
$FileExit = _GUICtrlCreateODMenuitem ("E&xit", $FileMenu, 'shell32.dll', 27)

$EditMenu = GUICtrlCreateMenu("&Edit")
$EditCut = _GUICtrlCreateODMenuitem ("Cu&t", $EditMenu, 'cut.ico', 0)
$EditCopy = _GUICtrlCreateODMenuitem ("&Copy", $EditMenu, 'copy.ico', 0)
$EditPaste = _GUICtrlCreateODMenuitem ("&Paste", $EditMenu, 'paste.ico', 0)
FileChangeDir(@ScriptDir)

GUISetState(@SW_SHOW)
GUISetState(@SW_MAXIMIZE)
AnimateTitle($GUI, $AppName & "Untitled" & $AppEnd, 100)

Global $oldMainText = "----"
While 1
    If $RichText.Text <> $oldMainText Then
        Global $oldSelStart = $RichText.SelStart, $oldSelLength = $RichText.SelLength
        _SyntaxHighlight()
        $oldMainText = $RichText.Text
        $RichText.SelStart = $oldSelStart
        $RichText.SelLength = $oldSelLength
    EndIf
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $FileExit
            Exit
        Case $FileNew, $IconNew
            $RichText.Text = ""
            WinSetTitle($GUI, "", $AppName & "Untitled")
        Case $FileOpen, $IconOpen
            $sTempFile = FileOpenDialog("Open", @MyDocumentsDir, "AutoIt Scripts(*.au3)", 1)
            $RichText.LoadFile ($sTempFile, 1)
            Local $NULL, $szFName
            _PathSplit($sTempFile, $NULL, $NULL, $szFName, $NULL)
            AnimateTitle($GUI, $AppName & $szFName & $AppEnd, 100)
            $sFile = $sTempFile
            GUICtrlSetState($FileSaveAs, $GUI_ENABLE)
        Case $FileSave, $IconSave
            If $sFile <> -1 Then
                If Not @error Then
                    FileDelete($sFile)
                    $RichText.SaveFile ($sFile, 1)
                    _CheckExt($sFile, StringRight($sFile, 4))
                    $sTempFile = $sFile
                EndIf
            Else
                $sTempFile = FileSaveDialog("Save", @MyDocumentsDir, "Rich Text File (*.rtf)|Text Files (*.txt)", 16, "Untitled.rtf")
                If Not @error Then
                    _CheckExt($sTempFile, ".au3")
                    $RichText.SaveFile ($sTempFile, 1)
                    $sFile = $sTempFile
                EndIf
            EndIf
            GUICtrlSetState($FileSaveAs, $GUI_ENABLE)
            Local $NULL, $szFName
            _PathSplit($sTempFile, $NULL, $NULL, $szFName, $NULL)
            AnimateTitle($GUI, $AppName & $szFName & $AppEnd, 100)
        Case $FileSaveAs
            $sTempFile = FileSaveDialog("Save As", @MyDocumentsDir, "Rich Text File (*.rtf)|Text Files (*.txt)", 16, $sFile)
            If Not @error Then
                _CheckExt($sTempFile, ".au3")
                If $sFile <> -1 Then
                    FileDelete($sTempFile)
                    $RichText.SaveFile ($sTempFile, 1)
                    Local $NULL, $szFName
                    _PathSplit($sTempFile, $NULL, $NULL, $szFName, $NULL)
                    AnimateTitle($GUI, $AppName & $szFName & $AppEnd, 100)
                EndIf
            EndIf
        Case $EditCut, $IconCut
            ClipPut($RichText.SelRTF)
            $RichText.SelRTF = ""
        Case $EditCopy, $IconCopy
            ClipPut($RichText.SelRTF)
        Case $EditPaste, $IconPaste
            $RichText.SelRTF = ClipGet()
    EndSwitch
WEnd

Func _CheckExt(ByRef $sFile, $sExt)
    Local $iCounter
    If StringInStr($sExt, ";") Then
        $sExt = StringSplit($sExt, ";")
        For $i = 1 To $sExt[0]
            If StringRight($sFile, StringLen($sExt[$i])) <> $sExt[$i] Then
                $iCounter += 1
            EndIf
        Next
        If $iCounter = $sExt[0] Then $sFile &= $sExt[1]
    Else
        If StringRight($sFile, StringLen($sExt)) <> $sExt Then $sFile = $sFile & $sExt
    EndIf
EndFunc   ;==>_CheckExt

Func AnimateTitle($hGUI, $sTitle, $iBuf)
    $sTitle = StringSplit($sTitle, "")
    For $i = $iBuf To 0 Step - 1
        WinSetTitle($hGUI, "", _StringRepeat(" ", $i) & $sTitle[1])
    Next
    Local $s
    For $i = 1 To $sTitle[0]
        $s &= $sTitle[$i]
        WinSetTitle($hGUI, "", $s)
        Sleep(5)
    Next
EndFunc   ;==>AnimateTitle

; Replaces the keywords
Func replaceKeywords(ByRef $p, $s)
    $p = StringRegExpReplace($p, '(?i)([^a-z0-9_])(' & $s & ')([^a-z0-9_])', '\1' & $keywordStart & $s & $keywordEnd & '\3');
EndFunc   ;==>replaceKeywords

Func _SyntaxHighlight()
    Local $keywords[36] = ['If', 'Then', 'ElseIf', 'Else', 'EndIf', 'Select', 'Switch', 'Case', 'EndSwitch', 'EndSelect', _
            'For', 'In', 'Next', 'Step', 'With', 'EndWith', 'While', 'WEnd', 'Do', 'Until', 'Func', 'Endfunc', 'Const', 'ContinueCase', _
            'ContinueLoop', 'Default', 'Dim', 'Enum', 'Exit', 'ExitLoop', 'False', 'Global', 'Local', 'ReDim', 'Return', 'True']
    Local $operators[11] = ['+', '-', '/', '*', '[', ']', '(', ')', '=', '&', '^']
    Local $macros = StringSplit(IniRead(@ScriptDir & "\definitions.ini", "Definitions", "Macros", ""), " ")
    Local $d = $RichText.Text
    $d = StringReplace($d, "\", "\\") ;these chars have special meanings in rtf
    $d = StringReplace($d, "{", "\{")
    $d = StringReplace($d, "}", "\}")
    ; Split into lines...
    ; Windows line ending   --> Unix line ending.
    $sLine = StringSplit($d, @CRLF, 1);
;~  _ArrayDisplay($sLine, "")
    $sOutput = ''; The output.
    For $i = 1 To $sLine[0]
        $sParsed = ''; Current parsed line.
;~      If $i > 1 Then $sParsed = "\line "
        $sText = ''; Text notation.
        ; For each character...
        For $j = 1 To StringLen($sLine[$i])
            ; Set the current char...
            $cchar = StringMid($sLine[$i], $j, 1);
            ; If we found the double quote
            If ($cchar = '"') Then
                ; If no text opened then open the text.
                If ($sText = '') Then
                    $sText = '"'
                    $sParsed &= $stringStart & '"'
                    ; If the text is opened using the " then close the text.
                ElseIf ($sText = '"') Then
                    $sText = ''
                    $sParsed &= '"' & $stringEnd
                    ; Else (e.g. opened using the ', or comment mode), print as normal.
                Else
                    $sParsed &= '"'
                EndIf
                ; But if we found the single quote
            ElseIf ($cchar = "'") Then
                ; If no text is opened then open the text.
                If ($sText = '') Then
                    $sText = "'"
                    $sParsed &= $stringStart & "'"
                    ; If the text if opened using the ' then close the text.
                ElseIf ($sText = "'") Then
                    $sText = ''
                    $sParsed &= "'" & $stringEnd
                    ; Else, print as normal.
                Else
                    $sParsed &= "'";
                EndIf
                ; If we found a ; and no text is opened, it is a comment.
            ElseIf ($cchar = ';' And $sText = '') Then
                $sText = ';'
                $sParsed &= $commentStart & ';'
                ; If we found a # and no text is opened, it is a hash statement.
            ElseIf ($cchar = '#' And $sText = '') Then
                $sText = '#'
                $sParsed &= $hashStart & '#'
                ; Other characters...
            Else
                ; If current text is normal text, print normally.
                ; This way we can hilight keywords correctly.
                For $iOperator = 0 To UBound($operators) - 1
                    If $cchar = $operators[$iOperator] And $sText <> "'" And $sText <> '"' Then
                        $sParsed &= $operatorStart & $cchar & $operatorEnd
                        $cchar = ''
                    EndIf
                Next
                $sParsed &= $cchar
            EndIf
        Next
        ; OKay, we finished the loop, we closed the unclosed string.
        If ($sText = '"' Or $sText = "'") Then
            $sParsed &= $stringEnd
            ; .. and we close the comment.
        ElseIf ($sText = ';') Then
            $sParsed &= $commentEnd
            ; .. and we close the hash.
        ElseIf ($sText = '#') Then
            $sParsed &= $hashEnd
        EndIf
        ; We indent the text, so it's easier to parse.
        $sParsed = ' ' & $sParsed & ' '
        ; Highlight the keyword. $sParsed is byref.
        For $i = 0 To UBound($keywords) - 1
            replaceKeywords($sParsed, $keywords[$i])
        Next
        ; Highlight the number.
        $sParsed = StringRegExpReplace($sParsed, '([^A-Za-z0-9_#])([0-9]+)([^A-Za-z0-9_])', '\1' & $numberStart & '\2' & $numberEnd & '\3')
        ; .. and the hexadecimal too.
        $sParsed = StringRegExpReplace($sParsed, '([^A-Za-z0-9_#])(0x)([0-9]+)([^A-Za-z0-9_])', '\1' & $numberStart & '\2\3' & $numberEnd & '\4')
        ; Now, highlight the function.
        $sParsed = StringRegExpReplace($sParsed, '([A-Za-z0-9_]+)(\s*?)\(', $functionStart & '\1' & $functionEnd & '\2(')
        ; Then, highlight the macro.
        $sParsed = StringRegExpReplace($sParsed, '@([A-Za-z0-9_]+)', $macroStart & '@\1' & $macroEnd)
        ; And some variable.
        $sParsed = StringRegExpReplace($sParsed, '\$([A-Za-z0-9_]+)', $variableStart & '$\1' & $variableEnd)
        ;Correct macro case - e.g. @appdatacommondir > @AppDataCommonDir
        For $iMacro = 1 To $macros[0]
            $sParsed = StringReplace($sParsed, StringReplace($macroStart & $macros[$iMacro] & $macroEnd, "\\", "\"), StringReplace($macroStart & $macros[$iMacro] & $macroEnd, "\\", "\"))
        Next
        ; Finally, outdent the text.
        $sParsed = StringMid($sParsed, 2, StringLen($sParsed) - 2)
        $sOutput &= $sParsed & "\par "
    Next
;~  MsgBox(0, 0, "[" & $sOutput & "]")
    $sTemp = "{\rtf1\ansi\deff0{\fonttbl{\f0\froman Courier New;}}{\colortbl{"
    $sTemp &= _RTFColor (153, 153, 204) ;0 - String
    $sTemp &= _RTFColor (0, 0, 255)     ;1 - Keyword
    $sTemp &= _RTFColor (0, 153, 51)    ;2 - Comment
    $sTemp &= _RTFColor (0, 0, 144)     ;3 - Function
    $sTemp &= _RTFColor (214, 58, 169)  ;4 - Number
    $sTemp &= _RTFColor (170, 0, 0)     ;5 - Variable
    $sTemp &= _RTFColor (240, 0, 255)   ;6 - Hash
    $sTemp &= _RTFColor (255, 51, 255)  ;7 - Macro
    $sTemp &= _RTFColor (255, 0, 0)     ;8 - Operator
    $sTemp &= "}}\deflang1033\plain\fs20 " & $sOutput & "}"
    $RichText.TextRTF = $sTemp
EndFunc   ;==>_SyntaxHighlight

Func _RTFColor ($iRed, $iGreen, $iBlue)
    Return "\red" & $iRed & "\green" & $iGreen & "\blue" & $iBlue & ";"
EndFunc   ;==>_RTFColor

Func _StringOccurences ($sStr, $sSubStr)
    StringReplace($sStr, $sSubStr, "")
    Return @extended
EndFunc   ;==>_StringOccurences

Func SwitchColor ($iColor)
    Local $iMask
    $iMask = BitXOR(BitAND($iColor, 0xFF) , ($iColor / 0x10000))
    Return BitXOR($iColor, ($iMask * 0x10001))
EndFunc   ;==>SwitchColor

Func __ArrayCharMatch ($avArray, $iCounter, $svMatch)
    Local $sText
    For $i = $iCounter To $iCounter + StringLen($svMatch) - 1
        If $i >= UBound($avArray) - 1 Then Return SetError(1, 0, 0)
        $sText &= $avArray[$i]
    Next
    If $sText = $svMatch Then Return 1
EndFunc   ;==>__ArrayCharMatch

ModernMenu.au3

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...