Author Topic: scintilla editor and compiling?  (Read 4759 times)

0 Members and 1 Guest are viewing this topic.

Frankolinox

  • Guest
scintilla editor and compiling?
« on: October 09, 2012, 09:08:08 AM »
hi charles, last night I've started to build a simple sdk window with scintilla include file. my stupid question is now if it's possible to compile this script example with this new editor embedding all oxygen power? or do I need to implement an include file for building and execution this little buffer string? I used "putfile" for the buffer string to show. "endofline" and "close" (file) doesn't yet exist in oxygen.

"compile(source)" is a command as I know and that's working. I have include it already. But how I can make "go" or "run" as command for this separately editor? my idea was to start an own little scintilla editor for oxygen, but that's not so easy I can see now ;)

best regards, frank

Aurel

  • Guest
Re: scintilla editor and compiling?
« Reply #1 on: October 09, 2012, 10:27:00 AM »
Heh...
Frank you can look into my scintilla test editor written in oxygen.
For now he can only load a source file into it.
but of course you can use ShellExecute() to run compiler and then parse path
and start new executable...
look here:
Oxygen Basic > Programming > Example Code > User Interface > Sci Test

Aurel

Frankolinox

  • Guest
Re: scintilla editor and compiling?
« Reply #2 on: October 11, 2012, 09:50:55 AM »
thanks aurel, I will check your example.

I would liike to know if it's possible to compiel an oxygen code example without saving modus. I have a string buffer in my source code I wanted to compile. that# s not possible without saving so far as I know. It was just an experimental code exmple with my scintilla sdk window to show if that's possible to do that one. I have not idea what I have to do to make a "build" options or "go" with oxygen. and for "charles", why the scintilla editor you're using don't know all that "source code " commands like "makepe (string, string)" or "prepexec(ute)" for this freebasic editor? I am a little confused about that one, sorry. thanks for feedback aurel. only a little comment line, I have tried to convert all oxygenbasic to powerbasic. I have finished nearly 75 per Cents and I am curious to see what happens If I have finished all ;) My silly idea was to convert some parts of oxygen (I think I have to convert all source code) for my funbasic project :-)

best regards, good night from cold autumn germany, frank

X

Aurel

  • Guest
Re: scintilla editor and compiling?
« Reply #3 on: October 11, 2012, 11:40:16 AM »
Frank...
To many  questions without right direction...
I understand what you have (so-so) in your mind but things not work
on that way,i know that from my own expirience.

Ok.
First if you whish made code -> work STOP thinking on PowerBasic way.
I made same mistake when i try to think like i use EmergenceBasic way.
I hope that you get point about this. ;)

Second ...
In my scintila example you can see load function.
I not add save option because in this momment i don't need this one but
for compiling code written in sci editor you must save changes in code before
compile -> run step, right?

When i catch some time i will add to my sci-editor save option,compile-option,run-option
If you look better there are already buttons for that,right?
For save option you probably need SCI_GETTEXT and fill buffer with code,then
put this buffer with PutFile() oxygen function into file,Right?
( i do not test this yet BUT probably will work ok).

Oh my--maybe i talk to much ::)
But i just try to explain the best I can... ;D
good luck...
if you have any question just ask... ;)

Frankolinox

  • Guest
Re: scintilla editor and compiling?
« Reply #4 on: October 13, 2012, 01:19:14 AM »
thanks aurel, I have got it now for "loading file" and compiling with oxygen for my scintilla/oxygen editor. but I wanted to send the buffer from scintilla editor for direct compiling/running/building. I will make a save file dialog for next time. I will looking for right solution and check more scintilla files on my hd :-) nice week-end, frank

Aurel

  • Guest
Re: scintilla editor and compiling?
« Reply #5 on: October 13, 2012, 01:53:46 AM »
You probably mean under direct compiling/building- as interpreting code for your funBasic?

Frankolinox

  • Guest
Re: scintilla editor and compiling?
« Reply #6 on: October 13, 2012, 05:26:40 AM »
yes "direct interpreting with buffer string" that's working in my funproject without problems, but I wanted to understand what's going on with my oxygen scintilla example :-)

here's my new attempt. I took your example ("doOpen") and manipulate it. I think that's only one or two little things are missing to save a scintilla file. my example works on oxygen that I can give the file a name but I cannot see the file in my folder (it doesn't exist).. compiling task after open the file I have already managed to build it :-)

Code: [Select]
'--------------- experimental code example
Sub doSaveFile
'--------------- experimental code example

    INT hsize=0 : dim as sys hsci, nfile, buffer,nlen
    string fR,dir,filter,title,tx,cr,tab
    cr=chr(13)+chr(10)
    tab=chr(9)
    dir=""
    string sep=chr(0)

    filter = " All files  "+sep+" *.*"+sep+"Oxygen files "+sep+" *.o2bas"

    title="Save File... "
    hwnd=0
   
    fR = FileDialog(dir,filter,title,"txt",0,0,0)

    'nFile = FREEFILE ' how to set FREEFILE for oxygen?
    'OPEN f FOR BINARY AS nFile ' ???   
   
    SendMessage hSci, %SCI_GETTEXT, BYVAL LEN(tx), BYVAL STRPTR(tx)
   
   '------- PUTFILE ---------------------- /
   PUTFILE fr,LEFT(tx, LEN(tx) - 1)
   '------- PUTFILE ---------------------- /
   'SETEOF nFile '-> SetEndofFile doesn't exist for oxygen?
   
   closeHandle nFile 'Close nFile

 tx = GetFilename(fr,1)
 
hsize = SendMessage hsci, SCI_GETTEXTLENGTH, 0, 0 '?
SendMessage hsci,SCI_SETTEXT,hsize+1,strptr(tx) '?

End Sub

frank

Aurel

  • Guest
Re: scintilla editor and compiling?
« Reply #7 on: October 13, 2012, 11:14:02 AM »
Ohh i see you have problem with save sciText as file visible in folder.
I see now but you don't read what i say,i do not test this yet.
Ok i will work on this right now ;)

Aurel

  • Guest
Re: scintilla editor and compiling?
« Reply #8 on: October 13, 2012, 11:59:10 AM »
Uf Frank
I do some things quickly and i'm not sure what PUTFILE() exactly need.
I do changes in FileDialog() function in include like this:
Code: [Select]
'FileDialog( $ iDir , $ filter ,$ title , % parent ,% flag )
Function FileDialog(Dir As String, filter , Title , long Hwnd, Flags, defext) As String
Dim ofn As OPENFILENAME
Dim filename[255] As zstring
INT retval

ofn.lStructSize = 76
ofn.hwndOwner = hWnd
ofn.hInstance = GetModuleHandle(0)
ofn.lpstrFilter = ?filter
ofn.lpstrCustomFilter= NULL
ofn.nMaxCustFilter = 0
ofn.nFilterIndex = 2
ofn.lpstrFile = @filename 'zstring buffer
ofn.nMaxFile = 255
ofn.lpstrFileTitle = NULL
ofn.nMaxFileTitle = 0
ofn.lpstrInitialDir = ?dir
ofn.lpstrTitle = ?title
If flags = 0 then ofn.Flags = OFN_EXPLORER Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY
If flags = 1 then ofn.Flags = OFN_EXPLORER Or OFN_OVERWRITEPROMPT Or OFN_HIDEREADONLY
ofn.nFileOffset = 0
ofn.nFileExtension = 0
ofn.lpstrDefExt = ?defext
ofn.lCustData = 0
ofn.lpfnHook = 0
ofn.lpTemplateName = NULL





' Execute the dialog box
IF flags = 0 then retval = GetOpenFileName(ofn)
IF flags = 1 then  retval = GetSaveFileName(ofn)

Return filename

End Function

Then in editor code doSave:
Code: [Select]
Sub doSave
INT hsize=0
fName=""
dir=""
sys tx
string sep=chr(0)
'filter = "All Files"+sep+"*.*"+sep"Text files"+sep+"*.txt"+ sep
filter = " All files  "+sep+" *.*"+sep+"Oxygen files "+sep+" *.o2bas"

title="Save File... "
hwnd=0
fName = FileDialog(dir,filter,title,0,1,"o2bas")

hsize = SendMessage hsci, SCI_GETTEXTLENGTH, 0, 0
tx=SendMessage edit1,SCI_GETTEXT,hsize+1,strptr(fName)
PutFile fName,tx


End sub

Also in awinh.inc i add
Code: [Select]
Declare Function GetOpenFileName  Lib "comdlg32.dll" alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Declare Function GetSaveFileName Lib "comdlg32.dll" alias "GetSaveFileNameA"  (pOpenfilename AS OPENFILENAME) As Long

BUT... >:( >:( >:(
Saved is number ::)
Ufff i think that i miss something..
maybe i tomorow see what i miss :-\

Aurel

  • Guest
Re: scintilla editor and compiling?
« Reply #9 on: October 13, 2012, 01:34:45 PM »
Yeah as usual i miss few stupid things... ::)
here is oyxgen code of doSave from scintilla c ontrol
easy ...right? ;D
Code: [Select]
Sub doSave
INT hsize=0
fName=""
dir=""
char tx[32768]
string sep=chr(0)
'filter = "All Files"+sep+"*.*"+sep"Text files"+sep+"*.txt"+ sep
filter = " All files  "+sep+" *.*"+sep+"Oxygen files "+sep+" *.o2bas"

title="Save File... "
hwnd=0
fName = FileDialog(dir,filter,title,0,1,"txt")

hsize = SendMessage hsci, SCI_GETTEXTLENGTH, 0, 0
SendMessage hsci,SCI_GETTEXT,hsize+1,tx
PutFile fName,tx

Eh i use char as buffer type but probably will work as just tx without type..
because work in doOpen to :-\

Aurel

  • Guest
Re: scintilla editor and compiling?
« Reply #10 on: October 14, 2012, 01:37:03 AM »
Oh i forget there is changes in FileDialog() function like this:
Code: [Select]
FileDialog( $ iDir , $ filter ,$ title , % parent ,% flag )
Function FileDialog(Dir As String, filter , Title , long Hwnd, Flags, defext) As String
Dim ofn As OPENFILENAME
Dim filename[255] As zstring
INT retval

ofn.lStructSize = 76
ofn.hwndOwner = hWnd
ofn.hInstance = GetModuleHandle(0)
ofn.lpstrFilter = ?filter
ofn.lpstrCustomFilter= NULL
ofn.nMaxCustFilter = 0
ofn.nFilterIndex = 2
ofn.lpstrFile = @filename 'zstring buffer
ofn.nMaxFile = 255
ofn.lpstrFileTitle = NULL
ofn.nMaxFileTitle = 0
ofn.lpstrInitialDir = ?dir
ofn.lpstrTitle = ?title
If flags = 0 then ofn.Flags = OFN_EXPLORER Or OFN_FILEMUSTEXIST Or OFN_HIDEREADONLY
If flags = 1 then ofn.Flags = OFN_EXPLORER Or OFN_OVERWRITEPROMPT Or OFN_HIDEREADONLY
ofn.nFileOffset = 0
ofn.nFileExtension = 0
ofn.lpstrDefExt = ?defext
ofn.lCustData = 0
ofn.lpfnHook = 0
ofn.lpTemplateName = NULL





' Execute the dialog box
IF flags = 0 then retval = GetOpenFileName(ofn)
IF flags = 1 then  retval = GetSaveFileName(ofn)

Return filename

End Function

Frankolinox

  • Guest
Re: scintilla editor and compiling?
« Reply #11 on: October 15, 2012, 03:42:41 AM »
thanks for your engaged help aurel. example with saving it seems to be not so easy, eh? ;) I will check your example next day, I am still at work and not private at home. best regards, frank

Aurel

  • Guest
Re: scintilla editor and compiling?
« Reply #12 on: October 15, 2012, 09:35:10 AM »
Just take your time ... ;)
No..it is easy but i miss some things as usual... ::)

Frankolinox

  • Guest
Re: execution + files are after saving empty :-)
« Reply #13 on: February 14, 2013, 09:39:33 AM »
here's my new attempt for an "oxy editor" and only the files are "empty" after saving. perhaps anybody can check this code example for correction.

I've used a simple winapi+scintilla example and oxide example plus include files.

Code: [Select]
 $ filename "t.exe"
  includepath "inc/"
  '#include "../../inc/RTL32.inc"
  '#include "../../inc/RTL64.inc"
  'include "inc/MinWin.inc"
  include "scintilla.inc"
  include  "OxideUtil.inc"
  'include "WinUtil.inc"
  
DECLARE FUNCTION GetDlgItem LIB "User32.dll" ALIAS "GetDlgItem" _
    (BYVAL hDlg AS DWORD, BYVAL nIDDlgItem AS LONG) AS DWORD

  %Buttoni      = 1001
  %Buttoni2     = 1002
  %scintilla    = 1003
  %saveFile     = 1004
  %execFile     = 1005  
  %load = 1006
  #lookahead ' for procedures
  s=error()
  '
  if s then
    print s
    goto endprog
  end if

  '==================
  'GLOBAL DEFINITIONS
  '==================

  '=========
  'MAIN CODE
  '=========
  
  dim cmdline as asciiz ptr, inst as sys
  &cmdline=GetCommandLine
  inst=GetModuleHandle 0
  '
  'WINDOWS
  '-------
  '
  WinMain inst,0,cmdline,SW_NORMAL
  
  endprog:

  'RELEASE SYSTEM RESOURCES
  '---------------------

  'FreeMinWinLibraries

  '===========
  'END OF MAIN
  '===========


  '--------------------------------------------------------------------
  Function WinMain(sys inst, prevInst, asciiz*cmdline, sys show) as sys
  '====================================================================

  WndClass wc
  MSG      wm

  sys hwnd, wwd, wht, wtx, wty, tax, myButton, hFont

  wc.style = CS_HREDRAW or CS_VREDRAW
  wc.lpfnWndProc = @WndProc
  wc.cbClsExtra =0
  wc.cbWndExtra =0    
  wc.hInstance =inst
  wc.hIcon=LoadIcon 0, IDI_APPLICATION
  wc.hCursor=LoadCursor 0,IDC_ARROW
  wc.hbrBackground = GetStockObject WHITE_BRUSH
  wc.lpszMenuName =null
  wc.lpszClassName = strptr "Demo"

  RegisterClass (@wc)
 
  Wwd = 640 : Wht = 480
  Tax = GetSystemMetrics SM_CXSCREEN
  Wtx = (Tax - Wwd) /2
  Tax = GetSystemMetrics SM_CYSCREEN
  Wty = (Tax - Wht) /2
 
  hwnd = CreateWindowEx 0,wc.lpszClassName,"OXYGEN BASIC",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0

     myButton =  CreateWindowEx(0, _                                            
                                 "Button", _                                        
                                 "push me!", _                                      
                                 %WS_CHILD OR %WS_VISIBLE OR _                        
                                 %BS_PUSHBUTTON OR %BS_FLAT, _            
                                 22, 20, _                              
                                 80, 24, _                              
                                 hWnd, %Buttoni, _                      
                                 inst, 0)                              
    
      SendMessage myButton, WM_SETFONT, hFont, TRUE '1

ShowWindow hwnd,SW_SHOW
  UpdateWindow hwnd
  '
  sys bRet
  '
  do while bRet := GetMessage (@wm, 0, 0, 0)
    if bRet = -1 then
      'show an error message
    else
      TranslateMessage @wm
      DispatchMessage @wm
    end if
  wend

  End Function



  dim as rect crect 'for WndProc and TimerProc

  '------------------------------------------------------------------
  function WndProc ( sys hWnd, wMsg, wParam, lparam ) as sys callback
  '==================================================================

    static as sys hdc,hw,ps,sx,sy
    static as String txt,cr,o2dir,f,fi,fo,dir
    static as PaintStruct Paintst
    dim as sys mySci,hlibsci,i,nLen,myButton ',hwnd,inst
    dim as string st, buffer
    static char    buf[256]

    '==========
    select wMsg
    '==========

    '----------------
      case WM_CREATE
    '================
                
      hlibsci = LoadLibrary "SciLexer.dll"
      GetClientRect  hWnd,&cRect
      'hlibsci = LoadLibrary "SciLexer.dll"
      'print str(hlibsci)
    
    '---------------------------------------// buttons ---------- //    
      mySci =  CreateWindowEx(0, _                                            
                                 "Scintilla", _                                        
                                 "", _                                      
                                 %WS_CHILD OR %WS_VISIBLE OR _                        
                                 %BS_PUSHBUTTON OR %BS_FLAT, _            
                                 10, 60, _                              
                                 360, 320, _                              
                                 hWnd, %scintilla, _                      
                                 inst, 0)                              
     'st="test me"
    
     SendMessage mySci, %SCI_SetText, 0, StrPtr(st)                  
     SendMessage mySci, %SCI_SetMarginWidthN, 0, 20    
    
    
    myButton =  CreateWindowEx(0, _                                            
                                 "Button", _                                        
                                 "gettext", _                                      
                                 %WS_CHILD OR %WS_VISIBLE OR _                        
                                 %BS_PUSHBUTTON OR %BS_FLAT, _            
                                 122, 22, _                              
                                 80, 24, _                              
                                 hWnd, %Buttoni2, _                      
                                 inst, 0)                              
          

    myButton =  CreateWindowEx(0, _                                            
                                 "Button", _                                        
                                 "saveFile", _                                      
                                 %WS_CHILD OR %WS_VISIBLE OR _                        
                                 %BS_PUSHBUTTON OR %BS_FLAT, _            
                                 242, 22, _                              
                                 80, 24, _                              
                                 hWnd, %saveFile, _                      
                                 inst, 0)                              
    
    myButton =  CreateWindowEx(0, _                                            
                                 "Button", _                                        
                                 "Execution", _                                      
                                 %WS_CHILD OR %WS_VISIBLE OR _                        
                                 %BS_PUSHBUTTON OR %BS_FLAT, _            
                                 332, 22, _                              
                                 80, 24, _                              
                                 hWnd, %execfile, _                      
                                 inst, 0)                              
    
    'myButton =  CreateWindowEx(0, _                                            
    '                             "Button", _                                        
    '                             "load", _                                      
    '                             %WS_CHILD OR %WS_VISIBLE OR _                        
    '                             %BS_PUSHBUTTON OR %BS_FLAT, _            
    '                             422, 22, _                              
    '                             80, 24, _                              
    '                             hWnd, %load, _                      
    '                             inst, 0)                              
    
    
'-------------------- //
    CASE WM_COMMAND
'-------------------- //
    
    IF wparam = %Buttoni THEN
          print "hello button"
    END IF
    
'TexTbuffer ---  
     'only a test for getting the buffer ------------ //
     IF wparam = %Buttoni2 THEN
          print "hello button2"
          mySci = GetDlgItem(hWnd, %scintilla)'
        IF mySci = 0 THEN EXIT FUNCTION
        nLen = SendMessage(mySci, %SCI_GETTEXTLENGTH, 0, 0)
        Buffer = SPACE(nLen + 1)
        SendMessage mySci, %SCI_GETTEXT, BYVAL LEN(Buffer), BYVAL STRPTR(Buffer)            
        mbox buffer 'only for test  
            a=compile buffer
            b=0
            b=call a
        print "buffer compiling by command `compile` "+b
   END IF
  
   '--------- SAVE FILE ------------------ //
   'SAVE FILE
  
   IF wparam = %saveFile THEN
          print "hello saveFile"
         f=fo
      if ShiftKey() or f=""
        f=GetFileName fo,1
      end if
      if f then
        fo=f
        fi=f
        '------------ PROBLEM ZONE ------------------  ? //
        s=GetText  mySci 'hchw[0]
        putfile fo,s
        SetWindowText hWnd, "Saved "+ClipName(f)
      end if  
      print "execution: " + f
      print f
      print str(mySci)
      Exec o2dir+"gxo2.exe","gxo2 "+f
   END IF
   'error 3: file empty or not found
  
   '--------- SAVE FILE END ------------------ //
   '
  
   '--------- EXECUTION THE FILE ------------------ //
   ' EXECUTE
  
   IF wparam = %execFile THEN
          print "hello execution File!"
          print "error 3: file is empty after saving, why?"
          
   if fi=""
        SendMessage hwnd,WM_COMMAND,%saveFile,0
      else
        'problem zone --------------------- ?
        s=GetText mySci '%scintilla ' hw
        'problem zone --------------------- ?
        if len(s) then
          putfile fi,s
          f=fi
          string m="!"
          if CtrlKey
            'CREATE INDEPENDENT BINARY
            if ShiftKey
              t="inc/RTL64.inc" 'CTRL-SHIFT-F5
            else
              t="inc/RTL32.inc" 'CTRL-F5
            end if
            s="$filename "+qu+o2dir+"_.exe"+qu+cr+
              "include "+qu+o2dir+t+qu+cr+s
            f=o2dir+"_.o2bas"
            '------------ HOW TO SAVE THE TeXT TO THIS FILE ? ------- //
            putfile f,s
            '------------ HOW TO SAVE THE TeXT TO THIS FILE ? ------- //
            m=""
          elseif ShiftKey
            'f="-c "+f 'SHIFT-F5 CREATE DEPENDENT BINARY
            s="#file "+qu+o2dir+"_.exe"+qu+cr+s
            f=o2dir+"_.o2bas"
            putfile f,s
            m=""
          end if          
          print "exec follows"
          'Exec o2dir+"co2.exe","co2 "+m+f
          '------------------------------- EXECUTE ------- //
          Exec o2dir+"gxo2.exe","gxo2 "+f
          '------------------------------- EXECUTE ------- //
          
        end if
      end if
  
   END IF
   '--------------------- EXECUTION FILE END ------------- //
  
   '---------------------- followed code only for test purpose ------ //
   IF wparam = %load THEN
          print "hello load File!"  
   case %load '1008 'F8
      f=GetFileName fi,0
      if f then
        fi=f
        fo=f
        s=GetFile fi
        le=len s
        'SendMessage hchw[0],WM_SETTEXT,le,s
        SendMessage mySci,WM_SETTEXT,le,s '%scintilla
      end if
      SetWindowText hwnd,"Loaded " ClipName(f)
    END IF
    
    
      '--------------  
      case WM_DESTROY
      '===============
          
      PostQuitMessage 0
        
      '------------
      case WM_PAINT
      '============
     '--------------  
      case WM_KEYDOWN
      '==============

      '============            
      Select wParam
      '============

Case 27 : SendMessage hwnd, WM_CLOSE, 0, 0      'ESCAPE

      End Select      

      '--------        
      case else
      '========
          
        function=DefWindowProc hWnd,wMsg,wParam,lParam
        
    end select

  end function ' WndProc

 


1) type a code in the scintilla editor: for example

Code: [Select]
mbox "Hello oxygen friends"
go to savefile and do it.

the error file shows that the file is empty after execution.
the problem zones I have marked too in code example.

best regards, frank

X
« Last Edit: February 14, 2013, 09:45:19 AM by Frankolinox »