AURELSOFT Friday, 2017-11-24, 4:06 PM
Welcome Guest | RSS
Site menu

Statistics

Total online: 1
Guests: 1
Users: 0

Home » 2016 » February » 3 » ASciEditor
0:25 AM
ASciEditor

Here is source code for ASiEdtor:

$ Filename "ASciO2.exe"
Include "RTL32.inc"
Include "awinh.inc"
#LOOKAHEAD ' for procedures
 Type NMHDR
      hwndFrom as sys
      idFrom   as sys
      code     as sys
  End Type

sys win,wabout,optWin
INT winstyle,aboutWindow,optWinOn
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,hsci
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
INT st1ID,st2ID,st6ID,st7ID
int x,y,w,h
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 ###################################
sciID=400  'scintilla ID
INT hlibsci,hsci 'scintilla handlers
INT bip

% SCE_OB_DEFAULT = 0
% SCE_OB_LINECOMMENT = 1
% SCE_OB_BLOCKCOMMENT = 2
% SCE_OB_NUMBER = 3
% SCE_OB_KEYWORD = 4
% SCE_OB_TYPE = 5
% SCE_OB_SETID = 6
% SCE_OB_PREPROCESSOR = 7
% SCE_OB_STRING = 8
% SCE_OB_OPERATOR = 9
% SCE_OB_IDENTIFIER = 10
% SCE_OB_LABEL = 11
% SCE_OB_ASM = 12

% SCLEX_OBASIC = 40

% SCI_SETLEXER = 4001
% 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_GOTOLINE = 2024
% SCI_LINELENGTH = 2350
% SCI_GETLINE = 2153
% SCI_GETLINECOUNT = 2154
% SCI_GETCURLINE= 2027
% SCI_SCROLLCARET=2169
% 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_SETSAVEPOINT = 2014
% SCI_EMPTYUNDOBUFFER = 2175

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

% TCN_SELCHANGE = -551

'init color strings
bSTRING sciblue,scired,scibrown
Gosub oxyKeywords
'- tview -------------
INT htv
'--------------------
STRING cOption="-c " ' default copt - gui No console "-c " for oxygen
STRING fName
char tx[500000]
string gxName="\gxo2.exe"   ' for oxygen change path to \gxo2.exe
char cdPath[256]
GetCurrentDir 256,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
bmpB0 = LoadImage(0,"bPanel.bmp",0,80,24,16)
bmpB1 = LoadImage(0,"data/rcImg.bmp",0,400,300,16)
'......................................................
bmpB2 = LoadImage(0,"data/guiApp.bmp",0,24,24,16)
bmpB3 = LoadImage(0,"data/consoleApp.bmp",0,24,24,16)
bmpB4 = LoadImage(0,"data/btCut.bmp",0,30,30,16)
bmpB5 = LoadImage(0,"data/btCopy.bmp",0,30,30,16)
bmpB6 = LoadImage(0,"data/btPaste.bmp",0,30,30,16)
bmpB7 = LoadImage(0,"data/btCompile.bmp",0,30,30,16)
bmpB8 = LoadImage(0,"data/btRun.bmp",0,30,30,16)
'##################################################
x=100:y=100:w=640:h=480
winstyle = WS_MINMAXSIZE or WS_CLIPCHILDREN
'create window **************************************************
win = SetWindow("AScio2:",x,y,w,h,0,winstyle)
'****************************************************************
bGoto = SetButton(win,388,4,60,24,"GOTO-->",0x50000000,0x200,bGotoID)
edit2 = SetEditBox(win,450,5,48,22,"edit2",0x50004000,0x200,ed2ID)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'create single-line edit control
edit1 = SetEditBox(win,160,30,466,23,"edit 1",0x50004000,0x200,ed1ID)
'tab item
edit3 = SetEditBox(win,30,30,18,20,"64",0x50004000,0x200,ed3ID)
'tab name
edit4 = SetEditBox(win,50,30,104,20,"TabName",0x50004000,0x200,ed4ID)
'create listbox ===================================================
INT lbx,lby,lbw,lbh
lbx=6:lby=54:lbw=148:lbh=366
Lbox = SetListBox(win,lbx,lby,lbw,lbh,"",0x50000140|CTLISTNOTIFY|WS_VSCROLL,0x200,LboxID)
Dim LBitems[2000] as INT
Dim LBitem as INT
'=================================================================
'create static control
static1 = SetStatic(win,6,32,24,13,"TAB:",0,0,st1ID)
'static text OPT$
static6 = SetStatic(win,500,8,32,13,"OPT->",0,0,st6ID)
'option edit box
editOpt = SetEditBox(win,540,4,60,21,"-s gui ",0x50004000,0x200,edoID)

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

'TOOLBAR-------------------------------------------------------------
Dim tbb as TBBUTTON
Dim AddBmp as TBADDBITMAP
' setting common control mode
Dim iccx as INITCOMMONCONTROLSEXtype
  iccx.dwSize = sizeOf(iccx )
  iccx.dwICC  = 4
' initialize common controls 32
InitCommonControlsEx( iccx )
with Addbmp
  .hinst = -1
  .nID   =  0
end with
INT htbar
INT toolID=99
'add handlers
INT  hImageList,hImage,iNum,id
'create toolbar -----------------------------------------------------
htbar = SetToolbar (win, 0 ,0,toolID)
'create tooltip -----------------------------------------------------
NMHDR pHdr
'set toolbar size ---------------------------------------------------
MoveWindow(htbar, 0, 0, 380, 28,0)
' Set the imagelist used with default images
  hImageList = ImageList_Create(20, 20, ILC_MASK OR ILC_COLOR8, 1, 0)
  hImage = LoadImage(0, "rCodetb.bmp", 0, 280, 20, 24)
  ImageList_AddMasked hImageList, hImage, RGB(231,223,231)
  DeleteObject hImage
'set image list  
SendMessage htbar,TB_SETIMAGELIST,0, 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, "Copy -->")
AddTButton(htbar, 106, 6, "<Paste>")
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")

'TAB control ---------------------------------------------------------
INT tc,tcID=500
tc = SetTabControl(win,160,55,466,26,0,0,tcID)
indexbase 0
INT tbArr[64],tabIndex,ai
STRING tabName[64],tabValue[64]
'reset tab info array >>>>>
For ai = 0 To 63
tabName[ai]  = ""
tabValue[ai] = ""
Next ai
'<<<<<<<<<<<<<<<<<<<<<<<<<<
tabIndex = -1
'add first tab.. index 0
CreateNewTab()

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

'---------------------------------------------------------------------
'Create Scintilla control ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
INT hlibsci,hsci,i
hlibsci = LoadLibrary "SciLexer.dll"
'print str(hlibsci)
INT rx,ry,rw,rh,ext,sci_style
rx=160: ry=80 : rw=466 : rh=340 : ext=0x200
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...
SENDMESSAGE(hsci, SCI_SETLEXER, SCLEX_OBASIC, 1)
SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_DEFAULT,100)
'set sci backColor
'SENDMESSAGE(hsci, SCI_STYLESETBACK,32,RGB(245,245,250)) 'yellow
SENDMESSAGE(hsci, SCI_STYLESETBACK,32,RGB(245,245,250)) 'white
SENDMESSAGE(hsci, SCI_STYLECLEARALL, 0, 1)
'set font
For i = 0 to 12
    SENDMESSAGE (hsci, SCI_STYLESETFONT, i, "Courier New")
    SENDMESSAGE (hsci, SCI_STYLESETSIZE, i, 9)
Next i
'set keyword colors
SENDMESSAGE(hsci, SCI_SETKEYWORDS, 3,scibrown) :'darkred
SENDMESSAGE(hsci, SCI_SETKEYWORDS, 1, sciblue ):'blue
 'Margins ////////////////////////////////////////////////////////
'set number margin (for numnbers)
SendMessage(hsci, SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER)
SendMessage(hsci, SCI_SETMARGINWIDTHN, 0, 46)
'caret line
SENDMESSAGE hsci,SCI_SETCARETLINEBACK,RGB(235,235,255),0
'SENDMESSAGE hsci,SCI_SETCARETFORE,RGB(115,115,255),0
SENDMESSAGE hsci,SCI_SETCARETLINEVISIBLE,1,0
SetFocus win

'--------------------------------------------------------------------
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_LINECOMMENT,rgb(0,120,0))
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_BLOCKCOMMENT, rgb(0,120,0))
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_NUMBER,RGB(0,0,0))
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_KEYWORD,RGB(200,0,0))
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_TYPE,RGB(0,0,200)) :'keywords
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_SETID,rgb(160,0,0)):'orange/to dark blue
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_PREPROCESSOR,rgb(220,0,0))
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_STRING, 0x880088 )
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_OPERATOR,rgb(0,0,180))
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_IDENTIFIER, 0x000000 )
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_LABEL,rgb(0,0,0))
    SENDMESSAGE(hsci, SCI_STYLESETFORE, SCE_OB_ASM, 0x555555 )

'ControlFont(hsci,16,400,0,"Courier New")

'->->->->->->->->->->->->->->->->->->
sys bRet
  '
  WHILE GetMessage (&wm,0,0,0)<>0
  TranslateMessage &wm
  DispatchMessage &wm
 WEND
'<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-

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


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

CASE WM_DESTROY
PostQuitMessage 0
'------------------
case WM_SIZE
GetSize(win,x,y,w,h)
MoveWindow(hsci,160,80,(w-rw/2)+64,(h-76)-32 ,1)
MoveWindow(edit1,160,30,(w-rw/2)+64,23 ,1)
MoveWindow(Lbox,6,54,lbw,(h-76)-6 ,1)
MoveWindow(tc,160,55,(w-rw/2)+64,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_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
         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
        doCopy()
        End If

      CASE b7ID
        If notifycode=0
        doPaste()
        End If

      CASE 107
        If notifycode=0
        doCompile()
        End If

      CASE b9ID
        If notifycode=0
        doRun()
        End If

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

      CASE 112
        If notifycode=0
        OptWindow()
        End If

    CASE bGotoID
     JumpToLine()

End Select

 

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


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

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

    Select controlID

    CASE bo1ID
        'opt -s gui
        If notifycode=0
        print "Compile As GUI App"
         cOption="-s gui "
         SendMessage editOpt,WM_SETTEXT,0,strptr "-s gui"   'set OPT BOX    
        End If
     CASE bo2ID
         'opt -s console
        If notifycode=0
        print "Compile As Console App"
         cOption="-s console"
         SendMessage editOpt,WM_SETTEXT,0,strptr "-s console"   'set OPT BOX    
        End If

    End Select

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CASE WM_CLOSE
  IF optWinOn = 1
    CloseWindow(optWin)
     optWinOn=0
  END IF
End Select
'----------------------------------------------------------
END SELECT


FUNCTION = DefWindowProc hwnd,wMsg,wParam,lParam


END FUNCTION


'************************************************************
'open file
Sub doOpen

INT hsize=0
fName=""
string dir=""
string sep=chr(0)
'filter = "All Files"+sep+"*.*"+sep"Text files"+sep+"*.txt"+ sep
filter = "All files "+sep+"*.*"+sep+"o2 files "+sep+"*.o2bas"
title="Open File... "
hwnd=0
fName = FileDialog(dir,filter,title,0,0,"o2bas")
fileName = fName
IF fName = "" Then Return
SendMessage edit1,WM_SETTEXT,0,strptr(fName)
 tx =  GetFile fName
SendMessage hsci,SCI_SETTEXT,0,strptr(tx)
SendMessage hsci,SCI_SETSAVEPOINT, 0, 0
SendMessage hsci,SCI_EMPTYUNDOBUFFER,0,0

If fName <> ""
FindNewTab()
End If

End Sub

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

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

'print fname
If fName="" then Return
  IF RightS(fname,6) <> ".o2bas"  '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,tx
    PutFile filePath,tx
    Return
ELSE
    Print "ERROR: AUTOSAVE! - File Not Found!"
    Return
END IF

END SUB
'*************************************************************
'do Close
SUB doClose
INT tab,tabCount,c
STRING tName
'clear sci control
SendMessage hsci,SCI_SETTEXT,0,strptr ""
tabCount=GetTabCount(tc)
'print "TAB COUNT:" tabCount
IF tabCount > 0
    tab = GetSelectedTab(tc)
    'print "SELECTED TAB:" + str(tab)
        If tab > -1
         tName = GetTabText(tc,tab)
         tName = Trim(tName)
        DeleteTab(tc,tab)   ' delete selected tab
            'delete tab info from tabArray[]
             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
         SendMessage tc,TCM_SETCURSEL,tabIndex,0
        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[255]
SendMessage edit1,WM_GETTEXT,255,ln
fName=Trim(ln)
IF fName = ""
MsgBox "File Not Open!","Error::File"
Return
End If
int sRet
autosave()
'(sys hwnd, string lpOperation, lpFile, lpParameters, lpDirectory, sys nShowCmd) as sys
'ShellExecute(0,"open",cdPath,fName,"" , 5) "-s console "
sRet = ShellExecute 0,"open","/gxo2.exe","-c"+fName,"",5
'sRet = ShellExecute 0,"open",cdPath,cOption + chr(34)+fName+chr(34),"",5 'fb

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

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 tabname already exists !
'IF found=0    
'tName = GetTabText(tc,pos)
'tName = Trim(tName)
/*
For c = 0 To 63
        IF tabName[c] = tName
           tabValue[c] = filename
            SetTabText(tc,pos,tName)  'update tab name
             ReOpenFile()             'reOpen file from filePath
             fnParser()               'parse code
            found=1                  'confirm found           
        END IF
Next c
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
'MESSAGEBOX 0,"New File!","Message..."
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
SendMessage hsci,SCI_SETTEXT,0,strptr(tx)
SendMessage hsci,SCI_SETSAVEPOINT, 0, 0
SendMessage hsci,SCI_EMPTYUNDOBUFFER,0,0


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

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,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,i$
LBitems[LBitem]=lineNum
LBitem=LBitem+1
END IF
GW1="":GW2=""

NEXT
LBitem=0
END SUB


'///////////////////////////////////////
SUB AddTButton(twnd as sys,id as sys,iNum as sys,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 , 1044, 1, &tbb


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 closewindow "
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 msgbox "
'--/////////  AWIH keywords in blue  ///////////////////---------------------------------
sciblue=sciblue+"wndproc addtab getselectedtab settabtext gettabtext gettabcount "
sciblue=sciblue+"setwindow seteditbox setrichedit setbutton setlistbox setcombobox setstatic settoolbar settabcontrol "
'############ RUBEN
sciblue=sciblue+"set wform txcolor pix shift loopto wtext line circle rect jump label "
sciblue=sciblue+"sin cos tan sqr rnd rand "

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

END SUB

SUB AboutBox
String mbff=""
mbff="Scintilla based code editor written with pure WIN32 API"+chr(13)
'mbff=mbff + "Code Editor written..................."+chr(13)
mbff=mbff + "Created by Aurel v01-2015"+chr(13)
'create  about window **************************
wabout = SetWindow("About ASciEdit...",300,160,412,400,0,WS_SYSMENU)
'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,0x50000101,0x200,st4ID)

aboutWindow = 1
END SUB    
'---------------------------------------------------------------------------------
SUB OptWindow
INT static5,st5ID=355
STRING bff,bf1
'create option window **************************
optWin = SetWindow("Compiler options...",300,160,412,400,0,WS_SYSMENU)
bff="SET compiler by choosing one of options..."
static5 = SetStatic(optWin,4,4,398,14,bff,0x50000101,0,st5ID)
'----------------------------------------------------------------------------------
INT static6,st6ID=336,INT static7,st7ID=338
INT static6b,st6bID=337,static7b,st7bID=337
static6 = SetStatic(optWin,8,30,126,14,"Select as GUI ->",0x50000100,0,st6ID)
static6b = SetStatic(optWin,330,24,26,26,"",0x5000030E,0,st6bID)
SendMessage static6b, 370, 0, bmpB2
bo1 = SetButton(optWin,160,25,100,24,"[-s gui ] -",0x50000000,0x200,bo1ID)
static7 = SetStatic(optWin,8,60,126,14,"Select as CONSOLE ->",0x50000100,0,st7ID)
bo2 = SetButton(optWin,160,55,100,24,"[-s console ] -",0x50000000,0x200,bo2ID)
static7b = SetStatic(optWin,330,55,26,26,"",0x5000030E,0,st7bID)
SendMessage static7b, 370, 0, bmpB3
'----------------------------------------------------------------------------------
optWinOn = 1
END SUB

Views: 71 | Added by: Zlatko | Rating: 0.0/0
Total comments: 0
Name *:
Email *:
Code *:
Log In

Search

Calendar
«  February 2016  »
SuMoTuWeThFrSa
 123456
78910111213
14151617181920
21222324252627
2829

Entries archive

Site friends
  • Official Blog
  • uCoz Community
  • FAQ
  • Textbook

  • Copyright MyCorp © 2017Free web hostinguCoz