Post Reply 

Share on Facebook Share on Twitter

AurelEdit o2 & sb versions
01-01-2020, 06:59 PM
Post: #1
AurelEdit o2 & sb versions
Code:
'*******************************************************************
' AurelEdit - v0.37, compiled with A043(progress) - win32
' Alternative code editor for Oxygen Basic - A043(progress)
' by Aurel 21.12.2019. ,sciLexer -> 3.7.4.0, awinh.inc v0.37
'*******************************************************************
$ Filename "AurelEditSB.exe"
Include "RTL32.inc"
Include "awinh037.inc"
#LOOKAHEAD ' for procedures

Type NMHDR
      hwndFrom as INT
      idFrom   as INT
      code     as INT
  End Type

INT win,hsci,wabout,optWin,fWindow,theme
INT winstyle,aboutWindow,optWinOn,findWinOn,stFW1,stFW2,stfw1ID=600,stfw2ID=601
INT fb1,fb2,fb3,fb1ID=501,fb2ID=502,fb3ID=503,fwed1,fwed1ID=504,fwed2,fwed2ID=505
INT button0,button1,button2,button3,button4,button5,button6,button7,button8,bGoto
INT edit1,edit2,edit3,edit4,edit5,editOpt
INT Lbox,static1,static2,static3,static4,ststic6,static7,static8,static9
INT ed1ID,ed2ID,ed3ID,edoID
INT b0ID,b1ID,b2ID,b3ID,b4ID,b5ID,b6ID,b7ID,b8ID=0,b9ID,b10ID
INT bo1,bo2,bo3,bo4,bo5,bo5,bo6,bo7
INT bo1ID=151,bo2ID=152,bo3ID=153,bo4ID=154,bo5ID=155,bo6ID=156
INT LboxID = 300,LBhdc,LBhdcMEM,LBox2,Lbox2ID = 301,fnBox=1
INT st1ID,st2ID,st6ID,st7ID,st8ID
int x,y,w,h : string CRLF = chr(13)+chr(10), CR = chr(13), intro
INT reID
bGotoID = 120
b0ID=99
b1ID=100
b2ID=101
b3ID=102
b4ID=103
b5ID=104
b6ID=105
b7ID=106
b8ID=107
'print str(b8ID)
b9ID =108
b10ID=110
% SW_RESIZE = 2
'-----------------
ed1ID=200
ed2ID=201
ed3ID=202
ed4ID=203
ed5ID=204
edoID=205
'----------------
st1ID=350
st2ID=351
st3ID=352
st4ID=353
st6ID=356
st7ID=357
'##### SCINTILLA CONSTANTS ###################################
INT hlibsci,hsci 'scintilla handlers
INT bip

% SCE_O2_DEFAULT = 0
% SCE_O2_LINECOMMENT = 1
% SCE_O2_NUMBER = 2
% SCE_O2_KEYWORD0 = 3  
% SCE_O2_STRING = 4
% SCE_O2_PREPROCESSOR = 5
% SCE_O2_OPERATOR = 6
% SCE_O2_IDENTIFIER = 7
% SCE_O2_DATE = 8
% SCE_O2_STRINGEOL = 9
% SCE_O2_KEYWORD1 = 10
% SCE_O2_KEYWORD2 = 11
% SCE_O2_KEYWORD3 = 12

% SCLEX_O2BASIC = 40 'fb lexer used 75

% SCI_SETLEXER = 4001
% SCI_COLOURISE = 4003
% SCI_STYLESETFORE = 2051
% SCI_STYLESETBACK = 2052
% SCI_STYLECLEARALL = 2050
% SCI_SETKEYWORDS = 4005
% SCI_STYLESETFONT = 2056
% SCI_STYLESETSIZE = 2055
% SCI_STYLESETBOLD = 2053
% SCI_SETMARGINWIDTHN = 2242
% SCI_SETMARGINTYPEN = 2240
% SCI_SETMARGINSENSITIVEN = 2246
% SCI_SETSELBACK = 2068
% SCI_SetSelFore = 2067
% SCI_GOTOLINE = 2024
% SCI_LINELENGTH = 2350
% SCI_GETLINE = 2153
% SCI_GETLINECOUNT = 2154
% SCI_GETCURLINE= 2027
% SCI_SCROLLCARET=2169
% SCI_SETCURRENTPOS = 2141
% SCI_SETANCHOR=2026
% SCI_SEARCHANCHOR=2366
% SCI_GETSELECTIONSTART=2143
'--------------------------------
% SCFIND_REGEXP=0x00200000
% SCFIND_WHOLEWORD=2
% SCFIND_MATCHCASE=4
% SCI_SEARCHNEXT=2367
% SCI_SEARCHPREV=2368
% SCI_REPLACESEL = 2170
'--------------------------------
% SCI_GOTOPOS=2025
% SCI_GETTEXT = 2182
% SCI_SETTEXT = 2181
% SCI_GETTEXTLENGTH = 2183

% SCI_CLEAR=2180
% SCI_CLEARALL=2004
% SCI_BRACEBADLIGHT=2352
% SCI_BRACEHIGHLIGHT=2351
% SCI_BRACEMATCH=2353
% SCI_GETSELECTIONEND=2145
% SCI_SETSELECTIONEND=2144
% SCI_SETCARETLINEVISIBLE=2096
% SCI_SETCARETFORE = 2069
% SCI_SETCARETLINEBACK = 2098
% SCI_SCROLLCARET=2169
% SCI_UNDO = 2176
% SCI_CUT = 2177
% SCI_COPY = 2178
% SCI_PASTE = 2179
% SCI_SELECTALL = 2013
% SCI_SETSAVEPOINT = 2014
% SCI_EMPTYUNDOBUFFER = 2175

% SC_MARGIN_SYMBOL = 0
% SC_MARGIN_NUMBER = 1
% SCI_SETMARGINMASKN = 2244

% TCN_SELCHANGE = -551
% SS_LEFT = 0x0

'init color strings
bstring sciBlue,sciRed,sciBrown
'Gosub oxyKeywords 'load oxygen basic keywords
'- tree view -------------
INT htv
'--------------------
STRING cOption="-c " ' default copt - gui No console "-c " for oxygen
STRING fName
char tx[500000]
string gxName="\sbasicg.exe"   ' for oxygen change path to \gxo2.exe
char cdPath[256]
'string cdPath
GetCurrentDir 256,strptr cdPath
'GetTempPath ( 256, strptr cdPath)
cdPath = cdPath + gxName
'MsgBox cdPath , "Compiler Path...OK!"
'-------------------------------------
'global file name
STRING fileName
INT tab
'--------------------------------------
'loadbmp
'##################################################
INT bmpB0,bmpB1,bmpB2,bmpB3,bmpB4,bmpB5,bmpB6,bmpB7,bmpB8
bmpB1 = LoadImage(0,"imgData\AELogoSB.bmp",0,400,300,16)
INT hIcon = LoadImage(0,"imgData\absmall4.ico", 1, 0, 0, &H10)
'......................................................

'##################################################
x=100:y=100:w=800:h=540
winstyle = WS_CLIPCHILDREN | WS_MINMAXSIZE
'create window **************************************************
win = SETWINDOW("AurelEditSB:",x,y,w,h,0,winstyle)
SendMessage(win, 0x0080, 0, hIcon)
'InitDrawing(win)
    'WindowColor( win, 220, 230, 250)
'****************************************************************
bGoto = SetButton(win,440,4,60,24,"GOTO-->",0x50000000,0x200,bGotoID)
edit2 = SetEditBox(win,504,5,48,22,"LINE",0x50004000,0x200,ed2ID)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'create single-line edit control
edit1 = SetEditBox(win,160,34,560,20,"path",0x50004000,0x200,ed1ID)
'tab item
'edit3 = SetEditBox(win,30,30,18,20,"64",0x50004000,0x200,ed3ID)
'tab name
edit4 = SetEditBox(win,8,34,134,20,"Functions",0x50004000,0x200,ed4ID)
'create listbox -> Functions/Subs  ================================
INT lbx,lby,lbw,lbh
lbx=6:lby=58:lbw=168:lbh=414
Lbox = SetListBox(win,lbx,lby,lbw,lbh,"",0x50000140|CTLISTNOTIFY|WS_VSCROLL,0x200,LboxID)
ControlFont(LBox, 15, 7, 300, "Courier New")
Dim LBitems[2000] as INT
Dim LBitem as INT
'create listbox -> ASCI Table  ===================================
Lbox2 = SetListBox(win,lbx,lby,lbw,lbh,"",0x50000140|CTLISTNOTIFY|WS_VSCROLL,0x200,Lbox2ID)
ControlFont(LBox2, 16, 8, 500, "Courier New")
ShowWindow LBox2,0  ' hide AsciTable Box -> 0 HIDE
CreateAsciTable()   ' build asci table
'=================================================================
'create static control
'static1 = SetStatic(win,6,32,24,13,"TAB:",0,0,st1ID)
'button  set compiler gxo2.exe path-------------------------------------------
static6 = SetButton(win,554,4,38,23,"SBG:",0,0x200,st6ID) ' gxo2 path button
ControlFont(static6, 16, 7, 500, "Courier New")
'option edit box
editOpt = SetEditBox(win,600,5,140,22,"C/I: smallBasic",0x50004000,0x200,edoID)

'set sci dimensions
'INT rx,ry,rw,rh
'rx=160:ry=80:rw=466:rh=360

' TOOLBAR -----------------------------------------------------------
TBBUTTON tbb
TOOLINFO tti
Dim AddBmp as TBADDBITMAP
' setting common controls mode
Dim iccx as INITCOMMONCONTROLSEX_TYPE
  iccx.dwSize = sizeOf(icxx)
  iccx.dwICC  = 4
' initialize common controls 32
InitCommonControlsEx( iccx )

INT htbar
INT toolID = 99
'add handlers
INT  hImageList,hImage
'create toolbar
htbar = SetToolbar (win, 0,  0, toolID)
'def NMHDR header
NMHDR phdr
'set toolbar size
MoveWindow(htbar, 0, 0, 434, 32,0)
' Set the imagelist used with default images
  hImageList = ImageList_Create(24, 24, ILC_MASK OR ILC_COLOR8, 1, 0)
  hImage = LoadImage(0, "imgData\DARKTB24.bmp", 0, 336, 24, 24)
  ImageList_AddMasked (hImageList,hImage, RGB(231,223,231))
  DeleteObject hImage
'set image list  
SendMessage htbar, 1072,0, byval hImageList
'set button structure size
SendMessage htbar , 1054, sizeof(tbb), NULL

'TBUTTONS & TOOLTIPS -------------------------------------------------
INT tooltip
tooltip = SetToolTip(htbar)

AddTButton(htbar, 100, 0, "New File")
AddTButton(htbar, 101, 1, "Open File")
AddTButton(htbar, 102, 2, "Save As...")
AddTButton(htbar, 103, 3, "Save File")
AddTButton(htbar, 104, 4, "Close File")
AddTButton(htbar, 105, 5, "ASCI Table")
AddTButton(htbar, 106, 6, "Parser")
AddTButton(htbar, 107, 7, "Compile::")
AddTButton(htbar, 108, 8, "Run")
AddTButton(htbar, 109, 9, "Web Site")
AddTButton(htbar, 110, 10, "Info")
AddTButton(htbar, 111, 11, "Find")
AddTButton(htbar, 112, 12, "Options")
AddTButton(htbar, 113, 13, "Help")

'///// MENUS /////////////////////////////////////////////////////////
'Appendmenu hMenu , wFlags, wIDNewItem, lpNewItem
INT mainMenu,submenu1,submenu2
INT mImg1 = LoadImage(0, "imgData\iNew.bmp", 0, 16, 16, 24)
INT mImg2 = LoadImage(0, "imgData\iOpen.bmp", 0, 16, 16, 24)
INT mImg3 = LoadImage(0, "imgData\iSave.bmp", 0, 16, 16, 24)
INT mImg4 = LoadImage(0, "imgData\iQuit.bmp", 0, 16, 16, 24)
INT mImg5 = LoadImage(0, "imgData\iUndo.bmp", 0, 16, 16, 24)
INT mImg6 = LoadImage(0, "imgData\iCut.bmp", 0, 16, 16, 24)
INT mImg7 = LoadImage(0, "imgData\iCopy.bmp", 0, 16, 16, 24)
INT mImg8 = LoadImage(0, "imgData\iPaste.bmp", 0, 16, 16, 24)
INT mImg9 = LoadImage(0, "imgData\iSelectAll.bmp", 0, 16, 16, 24)
INT mImg10 = LoadImage(0, "imgData\iCompile.bmp", 0, 16, 16, 24)
INT mImg11 = LoadImage(0, "imgData\iBuild.bmp", 0, 16, 16, 24)
INT mImg12 = LoadImage(0, "imgData\iRun.bmp", 0, 16, 16, 24)
INT mImg13 = LoadImage(0, "imgData\iAsDLL.bmp", 0, 16, 16, 24)
INT mImg14 = LoadImage(0, "imgData\iAddGUI.bmp", 0, 16, 16, 24)


mainMenu = CreateMenu()
'...............................................
submenu1 = CreatePopupMenu ()
'addsub menu items with ID
    AppendMenu (submenu1, 0,120,strptr "New")
        SetMenuItemBitmaps(submenu1, 0,MF_BYPOSITION , mImg1, 0) 'add menu item bitmap
    AppendMenu (submenu1,0,121,strptr "Open")
        SetMenuItemBitmaps(submenu1, 1,MF_BYPOSITION , mImg2, 0)
    AppendMenu (submenu1,0,122,strptr "Save")
        SetMenuItemBitmaps(submenu1, 2,MF_BYPOSITION , mImg3, 0)
    AppendMenu (submenu1,0,123,strptr "Quit")
        SetMenuItemBitmaps(submenu1, 3,MF_BYPOSITION , mImg4, 0)
'set submwnu1 on main menu
AppendMenu (mainMenu,16,submenu1,strptr "File")
'...............................................
submenu2 = CreatePopupMenu ()
'addsub menu items with ID
    AppendMenu (submenu2,0,124,strptr "Undo")
        SetMenuItemBitmaps(submenu2, 0,MF_BYPOSITION , mImg5, 0)    
    AppendMenu (submenu2,0,125,strptr "Cut")
        SetMenuItemBitmaps(submenu2, 1,MF_BYPOSITION , mImg6, 0)
    AppendMenu (submenu2,0,126,strptr "Copy")
        SetMenuItemBitmaps(submenu2, 2,MF_BYPOSITION , mImg7, 0)
    AppendMenu (submenu2,0,127,strptr "Paste")
        SetMenuItemBitmaps(submenu2, 3,MF_BYPOSITION , mImg8, 0)
    AppendMenu (submenu2,0,128,strptr "Select All")
        SetMenuItemBitmaps(submenu2, 4,MF_BYPOSITION , mImg9, 0)

'set submwnu1 on main menu
AppendMenu (mainMenu,16,submenu2,strptr "Edit")
'...............................................
submenu3 = CreatePopupMenu ()
'addsub menu items with ID
    AppendMenu (submenu3,0,129,strptr "Compile")
        SetMenuItemBitmaps(submenu3, 0,MF_BYPOSITION , mImg10, 0)    
    AppendMenu (submenu3,0,130,strptr "Build")
        SetMenuItemBitmaps(submenu3, 1,MF_BYPOSITION , mImg11, 0)
    AppendMenu (submenu3,0,131,strptr "Run")
        SetMenuItemBitmaps(submenu3, 2,MF_BYPOSITION , mImg12, 0)
    AppendMenu (submenu3,0,132,strptr "As DLL")
        SetMenuItemBitmaps(submenu3, 3,MF_BYPOSITION , mImg13, 0)
    AppendMenu (submenu3,0,133,strptr "Add GUI")
        SetMenuItemBitmaps(submenu3, 4,MF_BYPOSITION , mImg14, 0)

'set submwnu1 on main menu
AppendMenu (mainMenu,16,submenu3,strptr "Compile")
'...............................................
SetMenu  win ,mainMenu

'TAB control ---------------------------------------------------------
INT tc,tcID=500
tc = SetTabControl(win,180,58,598,26,0,0,tcID)

indexbase 0
INT tbArr[64],tabIndex,ai,tabCount
STRING tabName[64],tabValue[64]
'reset tab info array >>>>>
For ai = 0 To 63
tabName[ai]  = ""
tabValue[ai] = ""
Next ai
'<<<<<<<<<<<<<<<<<<<<<<<<<<
tabIndex = -1 : tabCount = tabIndex
'add first tab.. index 0
CreateNewTab()

'Status bar ---------------------------------
INT status
status = SetStatusBar ( win, "Status-Bar...",0,0)
'--------------------------------------------------------------------
'nt hdc = getdc(win)
'nt iBrush = CreateSolidBrush (0xff0000)
'SelectObject Hdc, iBrush
'Rectangle Hdc, 0, 0, w,h
'SetBkColor hdc,ibrush
'ReleaseDC win,hdc

'CREATE SCINTILLA CONTROL ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
INT hlibsci,hsci
hlibsci = LoadLibrary "SciLexer.dll"
'print str(hlibsci)
INT rx,ry,rw,rh,ext,sci_style,sciID = 400
rx=180: ry=84 : rw=598 : rh=390 : ext=0x200
'rx=180: ry=80 : rw=540 : rh=340
sci_style =  WS_CHILD | WS_VISIBLE | ES_SUNKEN
hsci = CreateWindowEx(ext,"Scintilla","",sci_style,rx,ry,rw,rh,win,sciID,0,0)
'UpdateWindow hsci
'basic setings...
'SCLEX_O2BASIC
SENDMESSAGE(hsci, SCI_SETLEXER, 75 , 0)
'add oxyWords
oxyKeywords()
'set sci backColor
SENDMESSAGE(hsci, SCI_STYLESETBACK, 0,rgb(255,255,255)) 'white
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)

SENDMESSAGE(hsci, SCI_SETKEYWORDS, 0, strptr sciBlue )  :  'blue
SENDMESSAGE(hsci, SCI_SETKEYWORDS, 1, strptr sciRed  )   :  'red
SENDMESSAGE(hsci, SCI_SETKEYWORDS, 2, strptr  sciBrown )
'set font
For i = 0 to 12
    SENDMESSAGE (hsci,SCI_STYLESETFONT, i,strptr "Courier New")
    SENDMESSAGE (hsci,SCI_STYLESETSIZE, i,  10)
Next i
'set keywords group colors
'SENDMESSAGE(hsci, SCI_SETKEYWORDS, 0, strptr sciBlue )  :  'blue
'SENDMESSAGE(hsci, SCI_SETKEYWORDS, 1, strptr sciRed  )   :  'red
'SENDMESSAGE(hsci, SCI_SETKEYWORDS, 2,strptr  sciBrown ) :  'brown
'////////////////////////////////////////////////////////
'set number margin (for numnbers)------------------------------------
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)
'set SELECTIONED LINES COLOR-----------------------------------------
SendMessage hsci,SCI_SetSelBack,1, RGB(49, 106, 197)
SendMessage hsci,SCI_SetSelFore,1, RGB(255, 235, 225)
'caret line----------------------------------------------------------
'SendMessage hsci,SCI_SETCARETFORE,0xFFFFFF,0 'white carret
SENDMESSAGE hsci,SCI_SETCARETLINEBACK,RGB(235,235,255),0
'SENDMESSAGE hsci,SCI_SETCARETFORE,RGB(115,115,255),0
SENDMESSAGE hsci,SCI_SETCARETLINEVISIBLE,1,0
'--------------------------------------------------------------------
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DEFAULT,RGB(200,0,0))              '0 default
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_LINECOMMENT,rgb(0,120,0))          '1 line comment
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_NUMBER, rgb(160,0,0))             '2 number
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD0,RGB(0,0,200))            '3 keyword0 - blue
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRING,RGB(150,0,150))            '4 string
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_PREPROCESSOR,RGB(0,0,250))        '5 preproc
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_OPERATOR,rgb(180,0,0))            '6 operator
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_IDENTIFIER,RGB(0,0,0))             '7 identifier/var names
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DATE,RGB(0,0,0))                  '8 date
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRINGEOL,rgb(0,100,0))            '9 string EOL
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD1,RGB(220,0,0) )            '10 keyword1 -work red
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD2,RGB(160,80,0))            '11 keyword2 - as brown
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD3,RGB(220,0,220))            '12 keyword3 - magenta    
SetFocus hsci
'----------------------------------------------------------------------
'load configuration file .cfg -----------------------------------------
LoadConfig()


'->->->->->->->->->->->->->->->->->->

  WHILE GetMessage (wm,0,0,0)<>0
    TranslateMessage wm
    DispatchMessage wm
WEND

'<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-

Function WndProc(byval hWnd as INT,byval wMsg as INT, byval wParam as INT,byval lparam as sys) as sys callback


SELECT hWnd
'-----------
CASE win
'----------
Select wMsg

CASE WM_CREATE
'------------------
'------------------
CASE WM_DESTROY
PostQuitMessage 0
'------------------
case WM_SIZE
GetSize(win,x,y,w,h)
MoveWindow(hsci,180,80,(w-rw/2)+114,(h-76)-32 ,1)

MoveWindow(edit1,180,34,(w-rw/2)+84,20 ,1)
MoveWindow(Lbox,6,58,lbw,(h-76)-6 ,1)
MoveWindow(Lbox2,6,58,lbw,(h-76)-6 ,1)
MoveWindow(tc,180,55,(w-rw/2)+116,24,1)
'fix statusbar position on botom of window
MoveWindow ( status,0,(h-32),w,h,1)

'-------------------------------------------------------------
CASE WM_NOTIFY
  NMHDR notify at lparam
  Select notify.code
    case -552  'tcn_selchanging
    'leaving tab
    'int p = SendMessage(tc,TCM_GETCURSEL,0,0)
    'print "LEAVING-TAB->" + str(p)
    autoSave()

    case -551  'tcn_selchange
    'selected tab
    'int i = SendMessage(tc,TCM_GETCURSEL,0,0)
    'print "TAB:" + str(i)
     FindTab()

End Select


CASE WM_CTLCOLORLISTBOX
LBhdc = getDC(LBox)
If theme = 3 ' default
    INT lbColor = CreateSolidBrush(RGB(255,255,255))
    'SetBkMode(LBhdc,1)
    SetBkColor( wparam, RGB(255,255,255))
    SetTextColor( wparam,RGB(20,45,125))
    'InvalidateRect(Lbox, 1, 0)
    return lbColor
End if

If theme = 1 ' light blue - clear sea
    INT lbColor = CreateSolidBrush(RGB(240,240,255))
    'SetBkMode(LBhdc,1)
    SetBkColor( wparam, RGB(240,240,255))
    SetTextColor( wparam,RGB(0,5,0))
    'InvalidateRect(Lbox, 1, 0)
    return lbColor
End if

If theme = 2 ' soft yellow - soft desert
    INT lbColor = CreateSolidBrush(RGB(243,242,214))
    'SetBkMode(LBhdc,1)
    SetBkColor( wparam, RGB(243,242,214))
    SetTextColor( wparam,RGB(0,5,0))
    'InvalidateRect(Lbox, 1, 0)
    return lbColor
End if

If theme = 4 ' soft yellow - soft desert
    INT lbColor = CreateSolidBrush(RGB(43,42,54))
    'SetBkMode(LBhdc,1)
    SetBkColor( wparam, RGB(43,42,54))
    SetTextColor( wparam,RGB(240,230,230))
    'InvalidateRect(Lbox, 1, 0)
    return lbColor
End if

'-------------------------------------------------------------
    CASE WM_COMMAND    
    controlID = LoWord(wParam) 'get control ID
    notifyCode = HiWord(wParam) 'get notification message

    Select controlID
     CASE LBoxID
     'doubleClick listbox item -> jump to line
        IF notifycode = LBN_DBLCLICK
        'pos=GETSELECTED(w1,3)
         pos = SendMessage Lbox,LB_GETCURSEL,0,0
        
        For n=0 TO pos    
            IF pos = n
            fnpos=LBitems[pos]
            SetFocus hsci
            SendMessage hsci,SCI_GOTOLINE,fnpos,0
            END IF
        Next n
        pos=0
        END IF

     'get file from clicked tab
    'CASE tcID
    
    

       CASE b1ID
        'NEW
        If notifycode=0
            autoSave() 'save current content
            SendMessage hsci,SCI_SETTEXT,0,strptr ""   'clear scintila
              NewTab()  'create new tab      
        End If

       CASE b2ID
        'OPEN
        If notifycode=0  
            doOpen()
            fnParser()
        End If

       CASE b3ID
          'SAVE AS..
         If notifycode=0
        doSave()    
        End If

      CASE b4ID
        If notifycode=0
        autoSave()
         'Beep 1200,60
        End If

      CASE b5ID
        If notifycode=0
        doClose()
         'Beep 800,50: Beep 600,50: Beep 400,50
        End If

      CASE b6ID
        If notifycode=0
            If fnBox = 1
             SetText (edit4,"ASCI Table:")
              ShowWindow LBox,0 : fnBox = 0' hide function listbox
              ShowWindow LBox2,1           ' show Asictable listbox2
              return 0
            End if
           If fnBox = 0
             SetText (edit4,"Function List:")
              ShowWindow LBox2,0 : fnBox = 1  ' hide AsciTable list
              ShowWindow LBox,1               ' show function list
              return 0
            End if
        End If

      CASE b7ID ' *parser
        If notifycode=0
        'MsgBox "Not Implemented Yet!" , "@Parser"
          intro = " ' smallBasic program by : " + crlf +
                  " ' date : 1.1.2020." + crlf +
                  " ' program type : demo" + crlf
          SendMessage hsci,SCI_SETTEXT, 0, byval strptr(intro)
        End If

      CASE 107  'compile
        If notifycode=0
        doCompile()        
        End If

      CASE b9ID ' run
        If notifycode=0
        doRun()
        End If

      CASE 110 'about
        If notifycode=0
        'show About window
         AboutBox()
        End If

     CASE 109 ' web site
      If notifycode=0
        MsgBox "Not Implemented Yet!" , "@Web Site"
      End If

      CASE 111 ' open FindWindow
         If notifycode = 0
           FindWindow()
         End If

      CASE 112 ' Option Window
        If notifycode=0
        OptWindow()
        End If

      CASE 113 ' Help
        If notifycode=0
        print "Help"
        End If

     CASE st6ID ' set compiler path [ gxo2.exe ]
      If notifycode = 0
      'cdPath = GetText(editOpt)
      'MsgBox cdPath , "Compiler Path:"
      MsgBox "Open option window (Settings)" + crlf + "...and set compiler path" , "AurelEdit::INFO"
      End If

    CASE bGotoID
     JumpToLine()
  
    
End Select

' [[[ SELECT ->  MENU  ID-s  / WPARAM  ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
   SELECT wParam
      
        Case 120  'new
            autoSave() 'save current content
            SendMessage hsci,SCI_SETTEXT,0,strptr ""   'clear scintila
            NewTab()  'create new tab      

        Case 121  'open
            doOpen()
            fnParser()

        Case 122 'save as
            doSave()  

        Case 123 'Quit
            SendMessage win,WM_CLOSE,0,0
          ExitProcess 0

      'menu EDIT
        Case 124 'undo
       SendMessage hsci,SCI_UNDO,0,0

        Case 125 'cut
       SendMessage hsci,SCI_CUT,0,0

        Case 126 'copy
       SendMessage hsci,SCI_COPY,0,0

        Case 127 'paste
       SendMessage hsci,SCI_PASTE,0,0

        Case 128 'select all
       SendMessage hsci,SCI_SELECTALL,0,0

       'menu COMPILE
        Case 129 'compile
            doCompile()

        Case 130
          'doBuild()  'build
         MsgBox "Not Implemented Yet!" , "@Build"

        Case 131 'run
            doRun()

        Case 132 ' as DLL
            'doAsDLL()

        Case 132 'addGUI
            'doAddGUI()

   END SELECT



END SELECT
'------------------------------


'-----------------------
CASE wabout
'----------------------
Select wMsg
CASE WM_CLOSE
  IF aboutWindow = 1
    CloseWindow(wabout)
     aboutWindow=0
  END IF

End Select
'---------------------
CASE optWin   'option window events
'..........................
Select wMsg
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CASE WM_COMMAND
    controlID = LoWord(wParam) 'get control ID
    notifyCode = HiWord(wParam) 'get notification message

    Select controlID
    CASE bo1ID
        'theme Clear Sea
        If notifycode = 0
           MsgBox "You select theme -> CLEAR SEA", "THEME"
            theme = 1 : SetTheme1(): ControlFont(LBox, 15,7, 0, "Courier New")
            ControlFont(LBox2, 18, 9, 0, "Courier New"): SaveConfig()
            CloseWindow (optWin)
        End If
     CASE bo2ID
         'theme Soft Desert
        If notifycode = 0
          MsgBox "You select theme -> SOFT DESERT" , "THEME"
           theme = 2 : SetTheme2(): ControlFont (LBox, 16,8, 0, "Courier New")
           ControlFont( LBox2, 18, 9, 0, "Courier New" ): SaveConfig()
           CloseWindow (optWin)
        End If

    CASE bo3ID
         'theme Default
        If notifycode = 0
          MsgBox "You select theme -> DEFAULT" , "THEME"
           theme = 3 : SetTheme3(): ControlFont( LBox, 16,8, 0, "Courier New")
           ControlFont( LBox2, 18, 9, 0, "Courier New"): UpdateWindow(LBox2): SaveConfig()
           CloseWindow (optWin)
        End If

    CASE bo4ID
         'theme Dark Moon
        If notifycode = 0
        MsgBox "You select theme -> DARK MOON" ,"THEME"
         theme = 4 : SetTheme4(): ControlFont(LBox, 16,8, 0,"Lucida Console")
         ControlFont( LBox2, 17,9, 0,"Lucida Console"): UpdateWindow(Lbox2): SaveConfig()
         CloseWindow (optWin)
        End If

    End Select
    
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CASE WM_CLOSE
  IF optWinOn = 1
    CloseWindow (optWin)
     optWinOn=0
  END IF
End Select
'////////////// FIND WINDOW  ///////////////////////////////////
CASE fWindow
'///////////
Select wMsg ' for Find/Replace toolwindow
'////////////////////////////////////////////////////////////
CASE WM_COMMAND
    controlID = LoWord(wParam) 'get control ID
    notifyCode = HiWord(wParam) 'get notification message

    Select controlID

    CASE fb1ID
        'Find-next...
        If notifycode=0
        FindNext()        
        End If
     CASE fb2ID
         'ReplaceOnce
        If notifycode=0
        ReplaceOnce(0)          
        End If
    CASE fb3ID
        If notifycode=0
         ReplaceAll()
         End If


    End Select

'.............................
CASE WM_CLOSE
  IF findWinOn = 1
    CloseWindow(fWindow) ' close [Find/Replace] toolwindow
     findWinOn = 0
  END IF
End Select
'////////////////////////////////////////////////////////
'CASE Lbox
    'select  wMsg
        'case wm_paint
        'BitBlt(hDC, 0, 0, ww, hh, hdcMem, 0, 0, SRCCOPY)
        'InvalidateRect(Lbox, 1, 0)

    'end select

END SELECT


FUNCTION = DefWindowProc hwnd,wMsg,wParam,lParam


END FUNCTION


'----------------------------------------------------------
'>>>  OPEN FILE DIALOG   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub doOpen

INT hsize=0
'bstring tx="" ' use bstring for text on scintilla
string dir=""
string sep=chr(0)
'filter = "All Files"+sep+"*.*"+sep"Text files"+sep+"*.txt"+ sep
filter = "All files "+sep+"*.*"+sep+"SB files "+sep+"*.bas"
title="Open File... "
hwnd=0
fName = FileDialog(dir,filter,title,0,0,"bas")
'print "FNAME:" + fName
fileName = fName
IF LEN(fname) = 0
   MsgBox "File Opening Canceled!" , "AurelEdit :: INFO!"
Return
END IF

SendMessage edit1,WM_SETTEXT, 0, byval strptr(fname)
SendMessage status,WM_SETTEXT,0, byval strptr(fName)
tx =  GetFile fName
SendMessage hsci,SCI_SETTEXT, 0, byval strptr(tx)
SendMessage hsci,SCI_SETSAVEPOINT, 0, 0
SendMessage hsci,SCI_EMPTYUNDOBUFFER,0,0

IF fName <> ""
FindNewTab()
END IF

'print "theme: " + str(theme)

End Sub

'************************************************************
'save file
'************************************************************
SUB doSave
INT hsize=0,found,c
string dir="",filePath
'char tx[32768]
'bstring tx
string ext=".bas"

filter= "SB Files (*.bas)"
title="Save File... "    'for Oxygen change to *.o2bas
hwnd=0
fName = FileDialog(dir,filter,title,0,1,"bas")

'print fname
If fName="" then Return
  IF RightS(fname,4) <> ".bas"  'for Oxygen set number to 6 , .o2bas
    fname = fname + ext
  END IF
'print fname
hsize = SendMessage hsci, SCI_GETTEXTLENGTH, 0, 0
'exit if empty
IF hsize = 0
print "ERROR: -> Document is Empty!"
Return    ' ->->->
END IF

'SendMessage hsci,SCI_GETTEXT,hsize+1,tx
'PutFile fName,tx
'SendMessage(hsci, SCI_SETSAVEPOINT, 0, 0)
'filePath = fName

found=0
INT tab = GetSelectedTab(tc)
string tName = GetTabText(tc,tab)
tName = Trim(tName)
'print "SAVE:tabname;" + tname
'if file exists ...............................................................
For c = 0 To 63
    IF tName <> "*New"
        IF tabName[c] = tName
           filePath = tabValue[c]
            'SetTabText(tc,tab,tName)  'update tab name
             'ReOpenFile()             'reOpen file from filePath
             fnParser()               'parse code
            found=1                  'confirm found    
             Exit For      
        END IF
   END IF
Next c
'if is tab *New ...............................................................
IF found = 0
print "is there tab NEW?"
For c = 0 To 63
        IF tabName[c] = "*New"
            filePath = Trim(fName)
           tabValue[c] = filePath
              tName = GetFileName(filePath)   'extract file name from file Path
            SetTabText(tc,tab,tName)        'update tab name
              tabName[c] = tName              'update tab name element
             'ReOpenFile()                    'reOpen file from filePath
             fnParser()                       'parse code
            found=1                          'confirm found    
             Exit For      
        END IF
Next c
END IF
'if filename not exists and there is no tab *New -> create NEW tab
'IF found = 0
'END IF

IF found = 1
    SendMessage hsci,SCI_GETTEXT,hsize+1,tx
    PutFile filePath,tx
    Return
ELSE
    Print "ERROR: SAVE! - File Not Found!" + chr(10) + "Create [*New] Document!"
    Return
END IF


END SUB
'*************************************************************
'>>  AUTO SAVE
SUB autoSave
INT hsize,tab,found,c
STRING tName,filePath
'print "AutoSave->FNAME:" + fName

hsize = SendMessage hsci, SCI_GETTEXTLENGTH, 0, 0
'exit if empty
IF hsize = 0 Then Return    ' ->->->
found=0
INT tab = GetSelectedTab(tc)
string tName = GetTabText(tc,tab)
tName = Trim(tName)
'search...
For c = 0 To 63
        IF tabName[c] = tName
           filePath = tabValue[c]
            'SetTabText(tc,tab,tName)  'update tab name
             'ReOpenFile()             'reOpen file from filePath
             'fnParser()               'parse code
            found=1                  'confirm found    
            
             Exit For      
        END IF
Next c

IF found = 1
    SendMessage hsci,SCI_GETTEXT,hsize+1,strptr tx
    PutFile filePath,tx
    Return
ELSE
    Print "ERROR: AUTOSAVE! - File Not Found!"
    Return
END IF

END SUB
'*************************************************************
'do Close
SUB doClose
INT tab,c
STRING tName
'clear sci control
SendMessage hsci,SCI_SETTEXT,0,strptr ""
tabCount=GetTabCount(tc)
'print "TAB COUNT:" + str(tabCount)
IF tabCount > 0
    tab = GetSelectedTab(tc)
    'print "SELECTED TAB:" + str(tab)
        IF tab > -1 then
         tName = GetTabText(tc,tab)
         tName = Trim(tName) : DeleteTab(tc,tab)   ' delete selected tab        
             For c = 0 To 63
               IF  tabName[c] = tName         
                  tabName[c] = ""      ' clear
                    tabValue[c] = ""     ' clear            
                    Exit For
                 END IF
             Next c
        
             'print "TAB.INDEX:" + str(tabIndex)
             tabIndex = tabIndex -1 : tabCount=GetTabCount(tc)
             'print "TABCOUNT_AFTER: " + str(tabCount)
             SendMessage tc,TCM_SETCURSEL,tabIndex, 0
             '---------------------------
             IF tabCount > 0 then Findtab()
        End if
END IF
IF tabCount = 0
CreateNewTab()
END IF

END SUB
'*************************************************************
'do Copy / paste
SUB doCopy
SendMessage hsci,SCI_COPY,0,0
END SUB
'-------------------------------------------------------------
SUB doPaste
SendMessage hsci,SCI_PASTE,0,0
END SUB
'----------------------------------------------------------

SUB doCompile
char ln[256]
string fn=""
SendMessage edit1,WM_GETTEXT,256,strptr ln
fn = Trim(ln)
'print "FN:" + fn
IF LEN(fn) < 1
MsgBox "File Not Open!","Error::File"
Return
End If
int sRet
autosave()
'(sys hwnd, string lpOperation, lpFile, lpParameters, lpDirectory, sys nShowCmd) as sys
sRet = ShellExecute(0,"open", cdPath,chr(34)+ fName + chr(34) ,"" , 5) ' if work sRet = 42
If sRet = 2 then MsgBox "Compiler gxo2 Not Found!"+ crlf + "Enter new compiler path!" , "GXO2 Path"
'sRet = ShellExecute 0,"open","gxo2.exe","-c "+ fn,"",5
'sRet = ShellExecute 0,"open",cdPath,cOption & chr(34) & fName & chr(34),"",5 'fb

END SUB
'---------------------------------------------------------
' RUN >>>>>>>>>>>>>>>>
SUB doRun
STRING exepath=""
INT dotpos=0
dotpos=INSTR(fName,".")
exepath = Mid(fName,1,dotpos-1)
exepath=exepath + ".exe"
'MESSAGEBOX 0,"path:"+exepath,"OK"
ShellExecute(0,"open", exepath, "","" , 5)
END SUB

'--------------------------------------------------------
SUB GetFileName (src as string) as String

String fname,sign1,name
INT dotpos,bslashpos,nameLen
'print "ShowFName::TABCOUNT->:"+str(tabcount)
'C:\OxygenBasic\examples\GUI\SciEditor\WinControls.o2bas
src=Trim(src)
bslashpos = FieldCount(src,chr(92))
name = Mid(src,bslashpos+1,LEN(src))
dotpos = INSTR(name,".")
'print "DOTP:" + str(dotpos)
'nameLen = LEN(src)-(LEN(src)-dotpos)

name = Mid(name,1,dotpos-1)
'
'print "ShowName->:" + name

Return name
END SUB
'-----------------------------------------------------------
SUB JumpToLine
INT tmpLine : char ln[100]
SendMessage edit2,WM_GETTEXT,100,ln
tmpLine = VAL (ln)-1
SetFocus hsci
SendMessage hsci,SCI_GOTOLINE,tmpLine,0
END SUB
'-----------------------------------------------------------
SUB FieldCount(source As String,delimiter As String) as Int
    Dim delpos,nexpos,count As Int
    'delimiter=chr$(92)
    count=1
    delpos=1
    nexpos=InStr(source,delimiter)
    While nexpos
        delpos=nexpos
        nexpos=InStr(delpos+1,source,delimiter)
        count++
    Wend
    RETURN delpos
END SUB  

'-----------------------------------------------------------------

SUB FindNewTab
INT found,tempTab,c,pos
STRING tName,tempName,tabNum
pos = GetSelectedTab(tc)
found=0
'search for tab -> *New
For c = 0 To 63
    IF  tabName[c] = "*New"         
        tabValue[c] = filename
         tName = GetFileName(filename) ' extract file name from filePath/tab name/
         tabName[c] = tName             ' update tab name
         SetTabText(tc,pos,tName)       ' set updated as tab text
         fnParser()
         found=1
         Exit For            
    END IF
Next c
            
IF found=1
'print "tab *New found!->RETURN"
Return   'ret    
END IF
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      


IF found=1
'print "tabname already exists!->RETURN"
Return   'ret
END IF
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'print" ELSE -> create new tab ...."
'print "ELSE->CREATE NEW TAB"

tabIndex=tabIndex+1  ' increase tab count
AddTab( tc, tabIndex, "*New")
SendMessage tc,TCM_SETCURSEL,tabIndex,0  ' set newTab as SELECTED

IF found=0
INT epos = -1
'search for first empty tabName in tabName[]
        For c = 0 To 63
            IF  tabName[c] = ""         
                tabName[c] = "*New" ' set first empty place with *New
                  tabValue[c] = ""    ' reset
                  epos=c              
                  Exit For
              END IF
         Next c
'-------------------------------------------
IF epos = -1
print "ERROR: File List Out Of Range! -> 63"
RETURN
END IF
'------------------------------------------
'if is OK update new tab !
pos = GetSelectedTab(tc)
'print "GET SELECTED TAB:" + str(pos)
'search for tab -> *New
For c = 0 To 63
    IF  tabName[c] = "*New"         
        tabValue[c] = filename
         tName = GetFileName(filename) ' extract file name from filePath/tab name/
         tabName[c] = tName             ' update tab name
         SetTabText(tc,pos,tName)       ' set updated as tab text
         ReOpenFile()                   'reOpen file from filePath
         fnParser()    
         found=1
         Exit For            
    END IF
Next c

END IF
'~~~~~~~~~~~~~~~~~~~~~~
RETURN
END SUB
'----------------------------------------------------------
SUB FindTab
INT found,tempTab,c
STRING tName,tabItem

tempTab=GetSelectedTab(tc)
tabItem = str(tempTab)
SendMessage edit3,WM_SETTEXT,0,strptr(tabItem) ' show tab id /zero-based/
tName=GetTabText(tc,tempTab)
tName=Trim(tName)
'print "LEN:GETText:" + str(len(tname))
SendMessage edit4,WM_SETTEXT,0,strptr(tName)   'show tab name
'print "LEN_after_TRIM:" + str(len(tName))

IF tName = "*New"
SendMessage hsci,SCI_CLEARALL,0,0
Return
END IF

found = 0
'show filePath [EDIT 1]-> C:\folder\myfile.bas
SendMessage edit1,WM_SETTEXT,0,strptr(tabValue[tempTab])
'search tab name...
For c = 0 To 63
    IF  tabName[c] = tName
         'print "FOUND:" + tabName[c]         
        found=1:Exit For                
    END IF
Next c

IF found = 1
ReOpenFile()
fnParser()
Return                
END IF
'-------------------
IF found=0
print "::::: new file"
Return
END IF

END SUB

'----------------------------------------------------------
SUB ReOpenFile
'SendMessage hsci,SCI_CLEARALL,0,0
INT tempTab,c
STRING name,filePath
tempTab=GetSelectedTab(tc)
name=GetTabText(tc,tempTab)
name=Trim(name)
'print "RE-OPEN:" + name

For c = 0 To 63
    IF  tabName[c] = name          
        filePath = tabValue[c]
         Exit For            
    END IF
Next c
SendMessage edit1,WM_SETTEXT,0,strptr(filePath)
'print "REOPEN-GetName:" + name
tx =  GetFile filePath
IF LEN(tx) = 0
   print "File Opening canceled!"
Return
End if
SendMessage hsci,SCI_CLEARALL,0,0
SendMessage hsci,SCI_SETTEXT,0,strptr(tx)
SendMessage hsci,SCI_SETSAVEPOINT, 0, 0
SendMessage hsci,SCI_EMPTYUNDOBUFFER,0,0
fName = filePath

END SUB
'----------------------------------------------------------
SUB CreateNewTab
int tab,c=0 : string tabnum
tabIndex=tabIndex+1
'first stored info for tabArray AT pos->0
tabName[c]="*New"
tabValue[c] = ""
'create new tab
AddTab( tc, tabIndex,"*New")
SendMessage tc,TCM_SETCURSEL,tabIndex,0  'set selected new tab
Tab=GetSelectedTab(tc)                   'get selected tab
tabNum = str(tab)
SendMessage edit3,WM_SETTEXT,0,strptr(tabnum) 'show tab ID
tabCount = GetTabCount(tc)

'print "CreateNEW_TAB: " + str(tabCount)
Return
END SUB

'-----------------------------------------------------------
SUB NewTab
tabIndex=tabIndex+1  ' increase tab count
AddTab( tc, tabIndex, "*New")
SendMessage tc,TCM_SETCURSEL,tabIndex,0  ' set newTab as SELECTED
INT epos = -1
'search for first empty tabName in tabName[]
        For c = 0 To 63
            IF  tabName[c] = ""         
                tabName[c] = "*New" ' set first empty place with *New
                  tabValue[c] = ""    ' reset
                  epos=c              
                  Exit For
              END IF
         Next c
'-------------------------------------------
IF epos = -1
  print "ERROR: File List Out Of Range! -> 63"
  RETURN
END IF

END SUB
'-----------------------------------------------------------

SUB fnParser
'reset listbox content ***************************************
STRING o2script[100000] 'string array
SendMessage LBox,LB_RESETCONTENT,0,o2script[100000]
STRING i$,txt,d$=" "
STRING GW1,GW2
INT smax,start,lineNum,iLen,bo,ipos
start=0
smax = Sendmessage hsci,SCI_GETLINECOUNT, 0, 0

'parse line by line >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
FOR lineNum = 1 TO smax
    
int Pos=0
int EPos=0
int SPos=0
int WC=0

'get-line ........................................................

iLen = SendMessage hsci,SCI_LINELENGTH,lineNum,0    'get line length
o2script[lineNum] = String(iLen," ")                'set buffer space
Sendmessage hsci,SCI_GETLINE, lineNum, strPtr(o2script[lineNum])
'test ///////////////////////////////
'print "LINE:" + o2script[lineNum]
'///////////////////////////////////
o2script[lineNum] = Ltrim(o2script[lineNum])
'--------------------------------------------
WC = 1
    Pos = InStr(1,o2script[lineNum], d$)
    While Pos > 0
        WC = WC + 1
        Pos = InStr(pos+1,o2script[lineNum], d$)
    Wend
'test wc------------------------------------------
'print WC
IF wc>0      
    SPos = 1      
    EPos = InStr(SPos,o2script[lineNum], d$) - 1
    If EPos <= 0 Then EPos = LEN(o2script[lineNum])
    GW1 = RTrim(LTrim(Mid(o2script[lineNum], SPos, EPos - SPos + 1)))
'print "GW1:"+GW1
END IF
'--------------------------------------------------
IF wc>1      
    SPos=EPos+2      
    EPos = InStr(SPos,o2script[lineNum], d$) - 1
    If EPos <= 0 Then EPos = LEN(o2script[lineNum])
    GW2 = RTrim(LTrim(Mid(o2script[lineNum], SPos, EPos - SPos + 1)))
'print "GW2:"+GW2
END IF

'test string & add to listbox
'/// SUB ///
IF Ucase(GW1) = "SUB"
'remove bracket ((((((((((((((((
bo = Instr (GW2,"(")
'print str(Len(GW2))
'print "BO:"+str(bo)
IF bo<>0
   bo=bo-1
   GW2=Mid(GW2,1,bo)
   bo=0
END IF
i$ = "SUB:" + GW2

SendMessage Lbox,LB_ADDSTRING,0,strptr i$
LBitems[LBitem]=lineNum
LBitem=LBitem+1
END IF

'/// FUNCTION ///
IF (Ucase(GW1) = "FUNCTION") And (Left(GW2,1)<>"=") And (Mid(GW1,9)<>"=")
bo = Instr (GW2,"(")
IF bo<>0
   bo=bo-1
   GW2=Mid(GW2,1,bo)
   bo=0
END IF
i$ = "FN:" + GW2
SendMessage Lbox,LB_ADDSTRING,0,strptr i$
LBitems[LBitem]=lineNum
LBitem=LBitem+1
END IF
GW1="":GW2=""

NEXT LineNum
LBitem=0
END SUB

'///////////////////////////////////////////////
SUB CreateAsciTable
INT index : STRING symbol,item
'add symbol / asci value
For index = 0 to 255
  item =  chr(index) + " : " + str(index)
SendMessage Lbox2,LB_ADDSTRING,0,strptr item
Next index
END SUB
'////////////////////////////////////////////////
SUB AddTButton (byval twnd as int,byval id as int,byval iNum as int,byval tip as string)
'TOOLINFO tti

tti.cbSize = Sizeof(tti)
tti.uFlags = 0   'TTF_SUBCLASS | TTF_IDISHWND
tti.hwnd   = twnd
tti.uId    = id
tti.hinst  = 0
tti.lpszText = strPtr tip

SendMessage(SendMessage( htbar, 1059,0,0),1028, 0, tti)

'add button
tbb.iBitmap = iNum
tbb.idCommand = id
tbb.fsState = 4
tbb.fsStyle = 0    
tbb.dwData = 0


SendMessage htbar , TB_ADDBUTTONS, iNum, tbb  'addbutton
'SendMessage (htbar, 1952, 0, 0) 'autosize

END SUB


'//////////////////////////////////////
SUB oxyKeywords
'blue
sciblue="$ enum operator dim const local static global declare function sub method end if then else elseif endif "
sciblue=sciblue+"endsel do while enddo endwhile wend exit continue operation operations select case for to step next "
sciblue=sciblue+"goto gosub methods return block scope indexbase lib library extern that this "
sciblue=sciblue+"readstate writestate deff type val ltrim rtrim lcase ucase space left mid instr "
sciblue=sciblue+"asc len chr str hex print ellipse rgb sendmessage procedure endproc proc endfunc "
sciblue=sciblue+"with "
sciblue=sciblue+"noinit "
sciblue=sciblue+"byval "
sciblue=sciblue+"byref "
sciblue=sciblue+"economy "
sciblue=sciblue+"fpu "
sciblue=sciblue+"cpu "
sciblue=sciblue+"noprec "
sciblue=sciblue+"include "
sciblue=sciblue+"define "
sciblue=sciblue+"typedef "
sciblue=sciblue+"includepath "
sciblue=sciblue+"lookahead "
sciblue=sciblue+"view "
sciblue=sciblue+"endv "
sciblue=sciblue+"version "
sciblue=sciblue+"getmemory "
sciblue=sciblue+"freememory "
sciblue=sciblue+"getprocaddress "
sciblue=sciblue+"copy0 "
sciblue=sciblue+"copy00 "
sciblue=sciblue+"copyn "
sciblue=sciblue+"copy "
sciblue=sciblue+"mbox "
sciblue=sciblue+"comparestr "
'----------------------------
sciblue=sciblue+"alias macro as "
sciblue=sciblue+"incl "
sciblue=sciblue+"semicolon "
sciblue=sciblue+"indexers "
sciblue=sciblue+"retn "
sciblue=sciblue+"offset "
sciblue=sciblue+"skip "
sciblue=sciblue+"with "
sciblue=sciblue+"dataspace "
sciblue=sciblue+"data "
sciblue=sciblue+"o2 "
sciblue=sciblue+"bind "
sciblue=sciblue+"defs "
sciblue=sciblue+"def "
sciblue=sciblue+"struct "
sciblue=sciblue+"class "
sciblue=sciblue+"var "
sciblue=sciblue+"asm "
sciblue=sciblue+"o2h "
sciblue=sciblue+"librarypath "
sciblue=sciblue+"file "
sciblue=sciblue+"quote "
sciblue=sciblue+"union "
sciblue=sciblue+"leaf "
sciblue=sciblue+"autodim "
sciblue=sciblue+"minormajor "
sciblue=sciblue+"alert "
sciblue=sciblue+"pragma "
sciblue=sciblue+"unique "
sciblue=sciblue+"console "
sciblue=sciblue+"elif "
sciblue=sciblue+"fi "
sciblue=sciblue+"ifdef "
sciblue=sciblue+"ifndef "
sciblue=sciblue+"undef "
sciblue=sciblue+"undefine "
sciblue=sciblue+"blockdepth "
sciblue=sciblue+"new "
sciblue=sciblue+"del "
sciblue=sciblue+"terminate "
sciblue=sciblue+"freestrings "
sciblue=sciblue+"freelibs "
sciblue=sciblue+"inherits "
sciblue=sciblue+"of "
sciblue=sciblue+"from "
sciblue=sciblue+"has "
sciblue=sciblue+"export "
sciblue=sciblue+"external "
sciblue=sciblue+"com "
sciblue=sciblue+"virtual "
sciblue=sciblue+"endselect "
sciblue=sciblue+"load "
sciblue=sciblue+"and "
sciblue=sciblue+"or "
sciblue=sciblue+"xor "
sciblue=sciblue+"stdcall "
sciblue=sciblue+"cdecl "
sciblue=sciblue+"ms64 "
sciblue=sciblue+"at "
sciblue=sciblue+"not "
sciblue=sciblue+"once "
sciblue=sciblue+"public "
sciblue=sciblue+"private "
sciblue=sciblue+"strptr "
sciblue=sciblue+"getfile putfile loadlibrary getdc releasedc sizeof "
sciblue=sciblue+"createwindowex filedialog trim replace #lookahead "

'AWIH keywords in sciBrown  //////////////////////////////////////////////////////////////
sciBrown=sciBrown+"wndproc addtab getselectedtab settabtext gettabtext gettabcount setselectedtab deletetab controlfont setricheditbackcolor "
sciBrown=sciBrown+"setwindow seteditbox setrichedit setbutton setlistbox setcombobox setstatic settoolbar settabcontrol settooltip "
sciBrown=sciBrown+"gettext settext setstatusbar settrackbar gettruckpos settreeview tvinsertitem setprogressbar pbsetpos setradiobutton "
sciBrown=sciBrown+"setcheckbox initdrawing windowcolor msgbox default notifycode "

'sciRed - red - var types
sciRed=sciRed+"void "
sciRed=sciRed+"byte "
sciRed=sciRed+"astring "
sciRed=sciRed+"pstring "
sciRed=sciRed+"bstring "
sciRed=sciRed+"char "
sciRed=sciRed+"zstring "
sciRed=sciRed+"wstring "
sciRed=sciRed+"bstring2 "
sciRed=sciRed+"zstring2 "
sciRed=sciRed+"asciiz "
sciRed=sciRed+"short "
sciRed=sciRed+"int "
sciRed=sciRed+"integer "
sciRed=sciRed+"float "
sciRed=sciRed+"single "
sciRed=sciRed+"sys "
sciRed=sciRed+"double "
sciRed=sciRed+"quad "
sciRed=sciRed+"word "
sciRed=sciRed+"dword "
sciRed=sciRed+"qword "
sciRed=sciRed+"uint "
sciRed=sciRed+"__int8 "
sciRed=sciRed+"__int16 "
sciRed=sciRed+"__int32 "
sciRed=sciRed+"__int64 "
sciRed=sciRed+"int8_t "
sciRed=sciRed+"int16_t "
sciRed=sciRed+"int32_t "
sciRed=sciRed+"int64_t "
sciRed=sciRed+"uint8_t "
sciRed=sciRed+"uint16_t "
sciRed=sciRed+"uint32_t "
sciRed=sciRed+"uint64_t "
sciRed=sciRed+"any "
sciRed=sciRed+"sys"
sciRed=sciRed+"bool "
sciRed=sciRed+"signed "
sciRed=sciRed+"unsigned "
sciRed=sciRed+"string "
sciRed=sciRed+"long "

END SUB
'
'///// EDITOR  ABOUT WINDOW - AboutBox  ///////////////////////////////////////////
SUB AboutBox
String mbff=""
mbff=" Aurel Edit is alternative Code editor for smallBasic" + crlf + " Written with pure WIN32 API and Scintilla editing control" + crlf
'mbff=mbff + "Code Editor written..................."+chr(13)
mbff=mbff + " Created by Aurel v037 31.12.2019"
'create  about window ***********************************************
wabout = SetWindow("About AurelEdit...",300,160,412,400,0, 524288)
'create static control
static3 = SetStatic(wabout,2,2,400,300,"",0x5000030E,0,st3ID)
SendMessage static3, 370, 0, bmpB1
static4 = SetStatic(wabout,4,310,398,50,mbff,0x50000100 | SS_LEFT,0x200,st4ID)

aboutWindow = 1
END SUB
    
'/////// EDITOR OPTION WINDOW  ////////////////////////////////////////////////////0x5000010B
SUB OptWindow
INT static5,st5ID=355
STRING bff="",bf1=""
'create option window ***********************************************************
optWin = SetWindow("Aurel Edit configuration...", 300, 160, 412, 400, 0, 524288)
'*******************************************************************************​*
bff="Set color theme by choosing one of options..."
static5 = SetStatic(optWin, 0, 4, 398, 14, bff, 0x50000101, 0, st5ID)
'height , width , flag
ControlFont( static5, 16, 8, 400,"Courier New")  
'----------------------------------------------------------------------------------
INT st6ID=336,st7ID=338,st8ID=339,st9ID=340
INT static6b,st6bID=337,static7b,st7bID=337,st8bID=440,st9bID=441
'----------------------------------------------------------------------------------
static6 = SetStatic(optWin, 8, 30, 180, 14,"Theme : Clear Sea",0x50000100,0,st6ID)
          ControlFont( static6, 16, 8, 400,"Consolas")
bo1 = SetButton(optWin, 200, 25, 100, 24," CLEAR SEA  ",0x50000000,0x200,bo1ID)
static6b = SetStatic(optWin, 330, 24, 26, 26,"",0x5000030E,0,st6bID)
SendMessage static6b, 370, 0, bmpB2

'---------------------------------------------------------------------------------
static7 = SetStatic(optWin,8, 60, 180, 14,"Theme : Soft Desert",0x50000100,0,st7ID)
        ControlFont( static7, 16, 8, 400,"Consolas")
bo2 = SetButton(optWin, 200, 55, 100, 24," SOFT DESERT  ",0x50000000,0x200,bo2ID)
static7b = SetStatic(optWin, 330, 55, 26, 26,"",0x5000030E,0,st7bID)
SendMessage static7b, 370, 0, bmpB3
'----------------------------------------------------------------------------------
static8 = SetStatic(optWin,8,90,180,14,"Theme : Default White",0x50000100,0,st8ID)
        ControlFont ( static8, 16, 8, 400,"Consolas")
bo3 = SetButton(optWin, 200, 85, 100,24," DEFAULT  ",0x50000000,0x200,bo3ID)
static8b = SetStatic(optWin, 330, 55, 26, 26,"",0x5000030E,0,st8bID)
SendMessage static8b, 370, 0, bmpB4
'----------------------------------------------------------------------------------
static9 = SetStatic(optWin,8,120,180,14,"Theme : Dark Moon",0x50000100,0,st9ID)
        ControlFont ( static9, 16, 8, 400,"Consolas")
bo4 = SetButton(optWin,200,115,100,24," DARK MOON ",0x50000000,0x200,bo4ID)
static9b = SetStatic(optWin, 330, 55, 26, 26,"",0x5000030E,0,st9bID)
SendMessage static9b, 370, 0, bmpB5

optWinOn = 1
END SUB
'===============================================================================​==
SUB FindWindow ' create Find/Replace window As TOOLWINDOW?
print "sub findwindow"
'INT fb1,fb2,fb3,fb1ID=501,fb2ID=502,fb3ID=503,fwed1,fwed1ID=504,fwed2,fwed2ID=505
'create ToolWindow require exetended window style to be set
INT hinst = GetModuleHandle 0
fWindow = CreateWindowEx ( WS_TOOLWINDOW|WS_EX_TOPMOST,"Oxygen","Find/Replace...", 524288 , 600, 160, 412, 300, 0, 0, null, 0)
print "FINDWINDOW" + str fWindow
ShowWindow fWindow,SW_SHOW : UpdateWindow fWindow
fb1=SetButton(fWindow,20,240,100,24,"[ Find ]",0x50000000,0x200,fb1ID)
fb2=SetButton(fWindow,150,240,100,24,"[ Replace ]",0x50000000,0x200,fb2ID)
fb3=SetButton(fWindow,280,240,100,24,"[ Replace All ]",0x50000000,0x200,fb3ID)
'create single-line edit control and static control
stFW1 = SetStatic(fWindow,20,30,100,26,"Search Word >>>",0x50000001,0,stfw1ID)
fwed1 = SetEditBox(fWindow,150,30,200,23,"",0x50004000,0x200,fwed1ID)
stFW2 = SetStatic(fWindow,20,80,100,26,"Replace With >>>",0x50000001,0,stfw2ID)
fwed2 = SetEditBox(fWindow,150,80,200,23,"",0x50004000,0x200,fwed2ID)
findWinOn = 1
END SUB
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub FindNext () as long
INT loc=1,temp
if loc
loc=SENDMESSAGE hsci,SCI_GETSELECTIONEND,0,0
'print "is selected-LOC: " + str(loc)
else
loc=SENDMESSAGE hsci,SCI_GETSELECTIONSTART,0,0
' print "selection start-LOC: " + str(loc)
end if

SENDMESSAGE hsci, SCI_SETANCHOR, loc ,0
SENDMESSAGE hsci, SCI_SETCURRENTPOS,loc,0
SENDMESSAGE hsci, SCI_SEARCHANCHOR,0,0

temp = SCFIND_WHOLEWORD
' print "TEMP: " + str(temp)
loc=SENDMESSAGE hsci,SCI_SEARCHNEXT,temp,GetText(fwed1)
' print "SEARCH-NEXT: " + str(loc)
'---------------------------------------------
IF loc > -1
      SENDMESSAGE hsci,SCI_SCROLLCARET,0,0
ELSE
    Msgbox "No matches found","Search"
Return 0
END IF
'-------------------------------------------
Return loc
End Sub
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function ReplaceOnce(RepeatS As Long) As Long
If FindNext() = 0    
    Return 0
End if
SENDMESSAGE hsci,SCI_REPLACESEL,0,GetText(fwed2)
Return 1
End Function
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub ReplaceAll
   dim iResult As Long
   'If FindNext() = 0 then
   ' Exit Function
   'End If
   iResult = ReplaceOnce(1)
If iResult = 0 then Exit Sub
   While iResult =1
      FindNext()
      iResult = ReplaceOnce(1)                  
   Wend
   MsgBox " All words Replaced!","Info"
End Sub
'/////////////////////////////////////////////////////////////////////
'//////////////////   theme  CLEAR SEA          //////////////////////
Sub SetTheme1

SENDMESSAGE(hsci, SCI_STYLESETBACK,32, RGB(240,240,255)) 'clear sea
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)
'set scintilla font
For i = 0 to 12
    SENDMESSAGE (hsci, SCI_STYLESETFONT, i, strptr "Consolas")
    SENDMESSAGE (hsci, SCI_STYLESETSIZE, i, 11)
Next i
'Margins ////////////////////////////////////////////////////////
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)
SendMessage(hsci, SCI_STYLESETBACK , 33, RGB(230,230,245))     ' set back-color of margin
SendMessage(hsci, SCI_STYLESETFORE ,33, RGB(40,20,10))         ' set front-color of margin
SENDMESSAGE (hsci, SCI_STYLESETSIZE , 33, 11)                '   set font size of margin
'caret line
SendMessage hsci,SCI_SETCARETFORE,RGB(0,0,0),0
SENDMESSAGE hsci,SCI_SETCARETLINEBACK,RGB(245,245,200),0
SENDMESSAGE hsci,SCI_SETCARETLINEVISIBLE,1,0
'SetFocus win
'--------------------------------------------------------------------
SetThemeColors()        
'SetFocus Lbox
End Sub

'//////////////////////////////////////////////////////////////////////
'////// theme  SOFT DESERT  ///////////////////////////////////////////

Sub SetTheme2
SENDMESSAGE(hsci, SCI_STYLESETBACK,32, rgb(243,242,214)) 'soft desert
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)
'set scintilla font
For i = 0 to 24
    SENDMESSAGE (hsci, SCI_STYLESETFONT, i,strptr "Courier New")
    SENDMESSAGE (hsci, SCI_STYLESETSIZE, i, 12)
     'SENDMESSAGE hsci, SCI_STYLESETBOLD, i, 12 'uncomment if you wish bold text
Next i
'Margins ////////////////////////////////////////////////////////
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)
SendMessage(hsci, SCI_STYLESETBACK , 33, RGB(237,236,208))     ' set back-color of margin
SendMessage(hsci, SCI_STYLESETFORE ,33, RGB(40,20,10))  ' set front-color of margin
SENDMESSAGE (hsci, SCI_STYLESETSIZE , 33, 12-1)              '   set font size of margin
'caret line
SendMessage hsci,SCI_SETCARETFORE,RGB(0,0,0),0
SENDMESSAGE hsci,SCI_SETCARETLINEBACK,RGB(220,220,245),0
SENDMESSAGE hsci,SCI_SETCARETLINEVISIBLE,1,0
'--------------------------------------------------------------------
SetThemeColors()
End Sub

'///////////////////////////////////////////////////////////////////////
'////// theme DEFAULT   /////////////////////////////////////////////////
Sub SetTheme3
SENDMESSAGE(hsci, SCI_STYLESETBACK,32, rgb(255,255,255)) 'default
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)
'set scintilla font
For i = 0 to 24
    SENDMESSAGE (hsci, SCI_STYLESETFONT, i,strptr "Lucida Console")
    SENDMESSAGE (hsci, SCI_STYLESETSIZE, i, 10)
    'SENDMESSAGE hsci, SCI_STYLESETBOLD, i, 12 'uncomment if you wish bold text
Next i
'set keyword colors
'Margins ////////////////////////////////////////////////////////
'set number margin (for numnbers)
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)
SendMessage(hsci, SCI_STYLESETBACK , 33, RGB(240,240,240))     ' set back-color of margin
SendMessage(hsci, SCI_STYLESETFORE ,33, RGB(10,20,10))  ' set front-color of margin
'caret line
SendMessage hsci,SCI_SETCARETFORE,RGB(0,0,0),0
SENDMESSAGE hsci,SCI_SETCARETLINEBACK,RGB(245,245,200),0
SENDMESSAGE hsci,SCI_SETCARETLINEVISIBLE,1,0

'--------------------------------------------------------------------
SetThemeColors()    

End Sub

'//////////////////////////////////////////////////////////////////////////
'///// theme DARK MOON   //////////////////////////////////////////////////
Sub SetTheme4
SENDMESSAGE(hsci, SCI_STYLESETBACK,32, RGB(40,40,55)) 'dark moon
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)
'set scintilla font
For i = 0 to 31
    SENDMESSAGE (hsci, SCI_STYLESETFONT, i, strptr "Lucida Console")
    SENDMESSAGE (hsci, SCI_STYLESETSIZE, i, 12)
     'SENDMESSAGE hsci, SCI_STYLESETBOLD, i, 12 'uncomment if you wish bold text
Next i
'set keyword colors
'Margins ////////////////////////////////////////////////////////
'set number margin (for numnbers)
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)
SendMessage(hsci, SCI_STYLESETBACK , 33, RGB(35,35,55))     ' set back-color of margin
SendMessage(hsci, SCI_STYLESETFORE ,33, RGB(160,120,100))  ' set front-color of margin
SENDMESSAGE (hsci, SCI_STYLESETSIZE , 33, 12)              '   set font size of margin

'caret line
SendMessage hsci,SCI_SETCARETFORE,0xFFFFFF,0
SENDMESSAGE hsci,SCI_SETCARETLINEBACK,RGB(65,60,100),0
SENDMESSAGE hsci,SCI_SETCARETLINEVISIBLE,1,0
'--------------------------------------------------------------------
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DEFAULT,RGB(191,193,198))          '0 default
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_LINECOMMENT,rgb(0,120,0))          '1 line comment
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_NUMBER, rgb(160,120,100))          '2 number
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD0,RGB(49, 106, 197) )         '3 keyword0 - blue
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRING,RGB(150,100,150))            '4 string
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_PREPROCESSOR,RGB(0,0,250)) :       '5 preproc
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_OPERATOR,rgb(220,180,120)):            '6 operator
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_IDENTIFIER,RGB(171,195,150))       '7 identifier/var names
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DATE,RGB(0,0,100))                  '8 date
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRINGEOL,rgb(0,100,0))            '9 string EOL
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD1,RGB(200,100,100) )            '10 keyword1 -work red
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD2,RGB(160,80,0))            '11 keyword2 - as brown
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD3,RGB(220,0,220))            '12 keyword3 - magenta    
'SetFocus Lbox
End Sub

'/////////////////////////////////////////////////////////////////////
'//  SET THEME COLORS
'////////////////////////////////////////////////////////////////////
Sub SetThemeColors
'------------------------------------------------------------------------------------------------------
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DEFAULT,0)                         '0 default
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_LINECOMMENT,rgb(0,120,0))          '1 line comment
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_NUMBER, rgb(160,0,0))             '2 number
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD0,RGB(0,0,200))            '3 keyword0 - blue
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRING,RGB(150,0,150))            '4 string
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_PREPROCESSOR,RGB(0,0,250)) :       '5 preproc
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_OPERATOR,rgb(250,,0)):            '6 operator
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_IDENTIFIER,RGB(0,0,0))             '7 identifier/var names
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_DATE,RGB(0,0,0))                  '8 date
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_STRINGEOL,rgb(0,0,0))            '9 string EOL
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD1,RGB(250,0,0) )            '10 keyword1 -work red
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD2,RGB(160,80,0))            '11 keyword2 - as brown
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_O2_KEYWORD3,RGB(220,0,220))            '12 keyword3 - magenta    
'-------------------------------------------------------------------------------------------------------
End Sub

'/////////////////////////////////////////////////////////////////////
'////  SAVE EDITOR CONFIGURATION - aka save theme
'//////////////////////////////////////////////////////////////////////

SUB SaveConfig

string sConfig , dest
char   cdBuff[256]
GetCurrentDir 256, strptr cdBuff
'print cdBuff   'show current folder
sConfig = "~theme" + "[" + str(theme) + "]"   ' res ->  ~theme[1]

   dest = cdBuff + "\AurelEditConf.cfg"
   putfile dest, sConfig
   MsgBox "Theme saved >>>" + crlf + "OK!","AurelEdit::INFO"
  Return

END SUB

'/////////////////////////////////////////////////////////////////////

SUB LoadConfig

string sConfig , dest
char   cdBuff[256]
GetCurrentDir 256, strptr cdBuff
'print cdBuff   'show current folder
'sConfig = "~theme" + "[" + str(theme) + "]"   ' res ->  ~theme[1]

   dest = cdBuff + "\AurelEditConf.cfg"
's_cfg = getfile configdir & "\O2HEdit.cfg"
   'if s_cfg then
    ' o2dir=extractData s_cfg, "$o2dir "
    ' compiler=extractData s_cfg, "$compiler "
sConfig = getfile dest
IF sConfig = ""
   MsgBox "Configuration file is EMPTY" + crlf +
          "create new file by opening Option Window!" , "AurelEdit::INFO"
   Return
END IF

IF sConfig = "~theme[1]"
theme = 1 : SetTheme1(): ControlFont (LBox, 16,8, 0, "Courier New")
ControlFont( LBox2, 18, 9, 0, "Courier New" )
END IF
  
IF sConfig = "~theme[2]"
    theme = 2 : SetTheme2(): ControlFont (LBox, 16,8, 0, "Courier New")
    ControlFont( LBox2, 18, 9, 0, "Courier New" )
END IF

IF sConfig = "~theme[3]"
     theme = 3 : SetTheme3(): ControlFont( LBox, 16,8, 0, "Courier New")
     ControlFont( LBox2, 18, 9, 0, "Courier New"): UpdateWindow(LBox2)
END IF

IF sConfig = "~theme[4]"
     theme = 4 : SetTheme4(): ControlFont( LBox, 16,8, 0, "Courier New")
     ControlFont( LBox2, 18, 9, 0, "Courier New"): UpdateWindow(LBox2)
END IF

END SUB

'////////////////////////////////////////////////////////////////////
Function ExtractData(string s,k) as string
  'format: $keyword [data]
  sys a = instr(s,k)
  if a=0 then exit function
  a = instr a,s,"["
  b = instr a,s,"]"
  IF a THEN
    a++
    return mid s,a,b-a
  END IF
End Function
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
AurelEdit o2 & sb versions - Aurel - 01-01-2020 06:59 PM

Forum Jump:


User(s) browsing this thread: