Author Topic: A little brother of OxIde  (Read 24741 times)

0 Members and 1 Guest are viewing this topic.

Arnold

  • Hero Member
  • *****
  • Posts: 977
Re: A little brother of OxIde
« Reply #30 on: March 29, 2017, 11:59:29 pm »
Hi Aurel,

thank you for this hint. This is something which I must test.

I generally let my Oxygenbasic folder untouched. And therefore I use the editor in a seperate directory like e.g. c:\AFolder\ASubFolder\O2HEdit (and the structure of the zip file). Therefore in O2Hedit.cfg the name of the Oxygenbasic directory must be recorded, so that the editor will find Oxygenbasic's tools.

But I can see that this is done with other editors for other programming languages too. They use .ini files or you are forced to add a path in your environment or they do something with the registry.

BTW I reflected on the process of compiling/running programs and now in the statusbar a notification will be shown when a program will be started or compiled. I think this should be helpful.

Roland

Arnold

  • Hero Member
  • *****
  • Posts: 977
Re: A little brother of OxIde
« Reply #31 on: March 30, 2017, 01:22:46 pm »
Hi Charles,

I found my little bug in the IDM_HELP_OXYGEN case. (st++ : en++ must be set before the if statement).
In the meantime I also managed to display the help info for the keyword, at least for 90% (I think). The Help Window will only be opened once per instance. I am quite happy with the Help functionality now.

In the meantime I have added some more options to the editor: create an oxygen.cfg in a directory, open an explorer window, add notification in the statusbar when running or compiling a program.

At the moment I try Aurel's idea to start the editor in the OxygenBasic folder and what must be done to create the O2HEdit.cfg file. To be honest: two years ago I would have thought in no way that I could come so far. And OxygenBasic is really very helpful for me.

Roland

Aurel

  • Guest
Re: A little brother of OxIde
« Reply #32 on: March 30, 2017, 02:21:39 pm »
Quote
At the moment I try Aurel's idea to start the editor in the OxygenBasic

Arnold
This is not just IDEA ..it is the only way i can compile program with O2Hedit.
so i don't know why only work if is inside Oxygen root folder.
Same problem I have with AurelEDit.
I simply cannot force gxo2 to compile something if Editor is in another folder
WHY ,i don't know.. maybe we can ask Charles?
« Last Edit: March 30, 2017, 09:19:31 pm by Aurel »

Arnold

  • Hero Member
  • *****
  • Posts: 977
Re: A little brother of OxIde
« Reply #33 on: March 30, 2017, 11:56:29 pm »
Hi Aurel,

O2hEdit 'must' work outside of OxygenBasic. Did you try to delete O2HEdit.cfg and start the editor? If the editor does not find co2.exe a dialog must start for selecting Oxygenbasic's directory to open co2.exe.
Only co2.exe can be used at the moment with the little editor project, but gxo2.exe does almost the same. And I can call these programs from outside of OxygenBasic's directory too. Although I use PSPad most of the time I know (because I tried it) that this works with other editors also e.g. with Scite, Context, Jfe (Jen's file editor). Therefore it must be possible for AurelEdit too. I assume something is missing in the Shellexecute statements. Maybe you can point me to the lines of AurelEdit where you call the routines of Compile and Run?

Roland

.

Aurel

  • Guest
Re: A little brother of OxIde
« Reply #34 on: April 01, 2017, 05:34:06 am »
Hi Arnold
It is easy to see ..
just look in subroutine doCompile()
but i doubt that problem is in filename because it contain full path to file.
problematic part is path of gxo2.exe path

Arnold

  • Hero Member
  • *****
  • Posts: 977
Re: A little brother of OxIde
« Reply #35 on: April 01, 2017, 03:11:01 pm »
Hi Aurel,

if Oxygenbasic is e.g. in c:\oxygenbasic then there are three possibilities in about line 800:

1) using fullpath:
sRet = ShellExecute 0,"open","c:\oxygenbasic\gxo2.exe","-c "+ fn,"",5
2) if a path is added in the environment e.g. via User account control:
sRet = ShellExecute 0,"open","gxo2.exe","-c "+ fn,"",5
3) I copied Aureledit.o2bas and the necessary files into folder projectsB\Scintilla and then I could also use:
sRet = ShellExecute 0,"open","..\..\gxo2.exe","-c "+ fn,"",5

But this is also documented in Win32 Help with the function ShellExecute. You will need either a fullpath or a file which is in the environment path or is in the current directory. The third example uses a relative path to the current (working) directory.

See also the remarks in this link:

https://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx

Roland

Arnold

  • Hero Member
  • *****
  • Posts: 977
Re: A little brother of OxIde
« Reply #36 on: April 03, 2017, 05:59:55 am »
Hello,

this is an updated version of O2HEdit. F1 should work like in most other editors. The Find/Replace dialog should now work better. I limited the Replace All functionality to 5000 items, the dialog can be continued with pressing Replace All again. I tried this with a file of 78000 lines, it worked quite nice.

Also added is the option to drag/drop a file into the editor. There is the possibility to open an explorer window of the file directory by selecting Tools, Open Explorer. I also added a menuitem for credits.

The editor should start anywhere. If copying into the OxygenBasic folder, it should even start out of the box. When the editor does not find co2.exe it will open a dialog to select the directory of Oxygenbasic and open co2.exe.

The code of O2HEdit.o2bas as is will create an exe file. To link the resources to the executable the batch file MakeExe.bat in folder source/MakeExe must be run.

To run O2HEdit with a resource dll these lines of O2HEdit.o2bas must be changed to:

#define use_dll
'#define make_exe

Before I start to work out MenuItem Options/Settings I have to tighten up the code. There is a lot of redundant code now, but I had to test several cases. There is still more to test.

Roland


.
« Last Edit: May 13, 2017, 02:52:45 am by Arnold »

Arnold

  • Hero Member
  • *****
  • Posts: 977
Re: A little brother of OxIde
« Reply #37 on: April 04, 2017, 01:01:47 am »
Hi Charles,

will it be possible to create the little editor project with Oxygen in progress too or are there some issues to respect? There are two options: creating an exe with the linked resources or creating a resource dll which can be used with the .o2bas file. I would be interested to know if Help would work (you mentioned that you will upgrade Oxygen_help a little bit) and if drag/drop a file would be successful. Somehow a gremlin is there with the .cfg file. Again I discovered a problem if I start O2Hedit with a file in Dos. I thought I already had solved this. The problem arises because I try to start the editor both in JIT mode and also as an independant executable. But hopefully I shall overcome some day.

Would it make sense to add a backup option for a code file? If I want to run a code, it will be first saved and the Undo capabilities are limited. Some editors create a temporary file with a random number and work with this file but I think this is also not completely fool-proof. I would like to use a simple solution.

Roland
« Last Edit: April 04, 2017, 01:55:34 am by Arnold »

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4486
    • Oxygen Basic
Re: A little brother of OxIde
« Reply #38 on: April 04, 2017, 11:25:37 pm »
Hi Roland,

Yes your o2hEdit works well on my developing OxygenBasic - A43

The only adjustment needed is to add the child window handle array hchw[...]  in your globals.

I have made quite a few alterations to Winutil (more generic), and sysutil ( includes stringutil and parseutil ).

Re Backup files:

They can get quite messy when working on multiple (include) files. A project could be zipped explicitly by the user, then selected files could be rolled back, if required. I do this regularly with the O2basic source, and find it very useful when making major alterations, and avoiding unforseen disasters.

To execute a program, you can save to a temporary file, and run that file, before commiting the original file to disk.

Re Keyword-specific Help

Passing keywords to Oxygen_Help.chm

The invocation I use is:

        wd=ExtractWord s,st,en,lw
        cm="hh.exe "+o2dir+"\inf\oxygen_help.chm::/wordlink.htm#"+wd
        Exec cm

« Last Edit: April 04, 2017, 11:51:53 pm by Charles Pegge »

Arnold

  • Hero Member
  • *****
  • Posts: 977
Re: A little brother of OxIde
« Reply #39 on: April 05, 2017, 12:41:29 am »
Hi Charles,

thank you for testing the compatibility. There is a small bug in O2HEdit.inc and ResourceIds.inc with IDC_FINDREGEX. The lines should read:
#define IDC_FINDMATCHWORD 1155
#define IDC_FINDREGEX 1156

As the project is intended to be a single file editor I removed the connection to hchw at the moment and use only hSci as handle for the Scintilla control. I also used Oxygen's macro capability and replaced all 'SendMessage hSci,' with 'hSciMsg'. I would like to use some more macros. At the moment I try to integrate some repetitive code. Then I will work out the Settings item.

When I started the project I also used hh.exe. The problem with hh.exe is that each F1 will open a new instance of Oxygen_help. Then I noticed that I can use the HtmlHelp Api directly:

! HtmlHelp lib "hhctrl.ocx" alias "HtmlHelpA" (dword hwndCaller, char* pszFile, dword uCommand, dword dwData) as sys

This way I can treat the HH_ commands and HH_ structures more flexible. I have not yet found out all possibilities, in particular wordlink.htm would be interesting to add. Repetitive F1 key would still open a second help file but only if a new instance of the editor is created. Maybe this can be prevented also, but I have not yet found out how this should be handled.
 
Thank you for the hint to create a temporary file for running/compiling the code. I think this is a good and also simple solution and I will try this.

Roland

Arnold

  • Hero Member
  • *****
  • Posts: 977
Re: A little brother of OxIde
« Reply #40 on: April 05, 2017, 01:39:37 am »
While I spied at Windows Dev Center I found this:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms670084(v=vs.85).aspx

I tried this with O2HEdit and modified the IDM_HELP_OXYGEN case:
Code: OxygenBasic
  1.         case IDM_HELP_OXYGEN
  2.         zstring wd
  3.         sys st,en,le,lw
  4.  
  5.         s=GetText hSci
  6.         le=len s
  7.         SendMessage hSci,EM_GETSEL,@st,@en
  8.         st++ : en++
  9.         if asc(s,st) > 32 then
  10.           if en != st then
  11.             lw=en-st
  12.             wd=mid(s, st,lw)
  13.           else        
  14.             wd=ExtractWord s,st,en,lw
  15.           end if                        
  16.           HtmlHelp null ,o2dir+"\inf\oxygen_help.chm", HH_DISPLAY_INDEX, @wd
  17.           HH_AKLINK link
  18.           link.cbStruct = sizeof(HH_AKLINK)
  19.           link.pszKeywords = wd
  20.           link.fIndexOnFail = true
  21.           HtmlHelp null ,o2dir+"\inf\oxygen_help.chm", HH_KEYWORD_LOOKUP, @link                  
  22.         else
  23.           HtmlHelp null ,o2dir+"\inf\oxygen_help.chm::/wordlink.htm>!", HH_DISPLAY_TOPIC, null        
  24. ''          HtmlHelp null, o2dir+"\inf\oxygen_help.chm", HH_DISPLAY_TOC, 0
  25.        end if
  26.  

I think this would look nice too? This would open an additional Help Window, maybe this can be prevented or it must be called as a seperate item.



.
« Last Edit: April 05, 2017, 01:58:11 am by Arnold »

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4486
    • Oxygen Basic
Re: A little brother of OxIde
« Reply #41 on: April 05, 2017, 01:51:21 am »
One further idea for keyword help: going directly to the topic page, instead of wordlink.htm.

You will need this customised HTM filename encoder which embeds ascii symbols like #  % $ in alphanumeric form: (used in recent versions of oxygen_help)

Code: [Select]
        '
        function filenameHTM(string nn) as string
        '=======
        sys a,i
        string s,n
        n=lcase nn
        for i=1 to len(n)
         a=asc(n,i)
         if a<97 or a>122 then
           s+="a"+str(a-31) 'supports ascii symbol encoding (space=a1)
          else
            s+=chr(a)
          end if
        next
        return s+".htm"
        end function

then you can get to the relevant page directly.
        '
        wd=ExtractWord s,st,en,lw
        'cm="hh.exe "+o2dir+"\inf\oxygen_help.chm::/wordlink.htm#"+wd
        '
        wd=filenameHTM(wd)
        cm="hh.exe "+o2dir+"\inf\oxygen_help.chm::/"+wd
        Exec cm

It should also work with the CHM API


.
« Last Edit: April 05, 2017, 02:02:06 am by Charles Pegge »

Arnold

  • Hero Member
  • *****
  • Posts: 977
Re: A little brother of OxIde - Scintilla.inc
« Reply #42 on: April 09, 2017, 11:58:36 pm »
Hi Charles,

I think something is missing with the SCNotification structure in Scintilla.inc? If I use it as is then the WM_NOTIFY messages in my little editor project will not fire. There must be a conflict with the nmhdr structure of minwin.inc. You can test this in OxHEdit.o2bas:
Code: OxygenBasic
  1.    case WM_NOTIFY
  2.       showToolTips(lParam)
  3.  
  4. '      NMHDR pnmh at lParam
  5. '      select pnmh.code
  6.  
  7.       SCNotification pnmh at lParam
  8. 'will need some work
  9.      select pnmh.NotifyHeader.code
  10.  

For now I have redefined the structure in O2HEditApi.inc:
Code: OxygenBasic
  1. 'redefine SCNotification
  2. typedef nmhdr Sci_NotifyHeader
  3.  
  4. type SCNotification
  5.     Sci_NotifyHeader NotifyHeader
  6.     int position;
  7.     /* SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, */
  8.     /* SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, */
  9.     /* SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, */
  10.     /* SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */
  11.     /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */
  12.  
  13.     int ch        /* SCN_CHARADDED, SCN_KEY */
  14.     int modifiers;
  15.     /* SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, */
  16.     /* SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */
  17.  
  18.     int modificationType    /* SCN_MODIFIED */
  19.     const char *text
  20.     /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED */
  21.  
  22.     int length        /* SCN_MODIFIED */
  23.     int linesAdded    /* SCN_MODIFIED */
  24.     int message    /* SCN_MACRORECORD */
  25.     sys wParam     /* SCN_MACRORECORD */
  26.     sys lParam     /* SCN_MACRORECORD */
  27.     int line        /* SCN_MODIFIED */
  28.     int foldLevelNow    /* SCN_MODIFIED */
  29.     int foldLevelPrev    /* SCN_MODIFIED */
  30.     int margin        /* SCN_MARGINCLICK */
  31.     int listType    /* SCN_USERLISTSELECTION */
  32.     int x            /* SCN_DWELLSTART, SCN_DWELLEND */
  33.     int y        /* SCN_DWELLSTART, SCN_DWELLEND */
  34.     int token        /* SCN_MODIFIED with SC_MOD_CONTAINER */
  35.     int annotationLinesAdded    /* SCN_MODIFIED with SC_MOD_CHANGEANNOTATION */
  36.     int updated    /* SCN_UPDATEUI */
  37. end type
  38.  

Applying this modification the WM_NOTIFY messages will work. But maybe I missed something with the structure in Scintilla.inc?

Roland

Arnold

  • Hero Member
  • *****
  • Posts: 977
Re: A little brother of OxIde - Update
« Reply #43 on: April 20, 2017, 12:52:10 am »
Hello,

attached is an updated state of my little editor project. It will hopefully not be the last update. I do not expect that anybody will use the editor for real work at the moment. It should work well though for running the examples of OxygenBasic. As I am now able to create O2Hedit.exe by itself and modify the code I will use the editor for extending it a little bit more.

Some things I added (but still must be tested):
Apply SCI_EmptyUndoBuffer instead of SCI_SetSavePoint for stopping Undo. This will hopefully prevent to reload a previous loaded file.

Regular expressions with find (Ctrl-F) and replace (Ctrl-H) using posix mode. The option Replace all with regex seems not to work correctly, I do not yet know if this is an issue of using an older scilexer.dll or a problem of the code.

Sensitive WinApi Help (Ctrl-F1). I used the Win32.chm created by Marc and Mike which can be found at www.oxygenbasic.org, Reference.

When running or compiling a file, a temporary file will be created when the original file is modified and is not yet saved.

There is also a MenuItem Options/Environment Settings, where some directories for used tools can be changed.

Tabs in a file can be replaced by spaces. (I do not like the escaped tabs). The size for tabspaces can be set from 2 to 8.

I also added a basic autoindent and brace matching. Brace matching and editing strings look a little bit weird at the moment.

O2HEdit should run everywhere on disc or usb-stick. If there exists already an o2hedit.cfg file it should be deleted. I also changed the structure of the include files therefore an unused folder would be the best way to extract the files.

The code as it is will create an executable in folder \source. To compile and link to an exe file, the file MakeExe.bat in folder \source\MakeExe must be run (the line: set o2_dir=c:\OxygenBasic must perhaps be changed to the correct path).

To create a O2HEdit.dll, in O2HEdit.o2bas the line 12 must be changed to:
'#define make_exe
MakeDll.bat in folder \source\MakeDll is then used to create the dll in folder \source.

Before I can continue further with the project (fonts), I suppose some issues with Scilexer.dll must be examined.
 
Roland


.
« Last Edit: June 27, 2017, 07:50:07 am by Arnold »

Arnold

  • Hero Member
  • *****
  • Posts: 977
Re: A little brother of OxIde - Next step
« Reply #44 on: May 13, 2017, 02:57:09 am »
Hello,

this is the latest state of my little editor project. There was a small bug in my code and it took three days to find out what went wrong. Maybe this works better now.

It should be possible now to change the font and font size, I limited to fixed-pitched fonts. Changing to bold or italic in the font dialog will only affect the font in the margin. I also added the possibility to change the styles for highlighting - I used schemes as this is simpler than modifiying the styles individually. This is done in O2HEditcolors.inc. If there is a demand for special styles I could add them.

I added additional syntax coloring for WinApi keywords and asm keywords. If there is a recommended link for assembler help than a asm help option could be added to the project.

O2HEdit should work everywhere on harddisk or usb-stick and it can also be started in the OxygenBasic folder. An existing older O2HEdit.cfg must be deleted as otherwise O2HEdit.exe will crash at the moment. It is possible to create a link for O2HEdit on the desktop and open files by dragging and dropping. It is also possible to associate files with O2HEdit.exe so they will be opened directly.

I use a special Scilexer.dll for the project which is included. This dll can be copied to the Oxygenbasic folder. Another way is to set the path for Scilexer.dll with the MenuItem: Opitons / Enironment Settings.

This project aims to be simple but also to be practical for creating small Oxygenbasic applications. What additional features might make sense? At the moment I am reflecting about folding.

Roland

Edit:

Due to some changes added to Oxygenbasic version A43 some small modifications are necessary to compile the source of O2HEdit.o2bas with version A43:

O2HEdit.o2bas:

line 99,100

   static bool h_check=true 'highlighting
   static bool a_check=true 'autoindent

O2HEdit.inc:

line 561

       zstring buffer[10]

line 688

             down=1

line 803
             down=1


.
« Last Edit: June 27, 2017, 07:51:33 am by Arnold »