Author Topic: Aurel Edit  (Read 5356 times)

0 Members and 1 Guest are viewing this topic.

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Aurel Edit
« on: April 02, 2017, 05:43:12 AM »
I open new topic because of many internal changes i have in plan to add
in Aurel Edit - alternative Oxygen Basic editor.
And also this editor is proof that can be done in Oxygen Basic.
This version have some bug fixing and you can add compiler path if you
want to run editor out of oxygen Basic root folder.
 

.

Arnold

  • Hero Member
  • *****
  • Posts: 677
Re: Aurel Edit
« Reply #1 on: April 05, 2017, 07:11:22 AM »
Hi Aurel,

although I will concentrate on my little project, maybe I can make some proposals for your project? Of course this is only my point of view.
I created two folders for my project: project_dev and project. Folder project_dev is my sandbox, the folder project will contain the files which I will deliver.

As long as I do modifications with my code I do not use the #include "$\inc\RTL32.inc" statement. With my editor (PSPad, but Scite or Oxide will work too) it is really easy to run the code and see the bugs at once. And when I then create an executable I will see what is still missing.

E.g. when running AurelEdit.o2bas without the runtime library then SciLexer.dll is not necessary in the working folder as Oxygenbasic will find it. I also make sure that there is no other SciLexer.dll is opened. This can be checked in a Dos Box (cmd.exe) with this command:

where scilexer.dll

Running AurelEdit as an executable is another problem. But for developing the code you will not need an extra scilexer.dll.
I copied AurelEdit.o2bas and awinh.inc into a folder AurelEdit and tried to restore the missing images (not sure if I got the right ones). I would like to suggest to add a routine like this for missing images:

Code: OxygenBasic
  1. sub missing(sys id, string name)
  2.    if not id then mbox name " not found"
  3. end sub
  4.  
  5. '--------------------------------------
  6. 'loadbmp
  7. '##################################################
  8. INT bmpB0,bmpB1,bmpB2,bmpB3,bmpB4,bmpB5,bmpB6,bmpB7,bmpB8
  9. bmpB0 = LoadImage(0,"bPanel.bmp",0,80,24,16) : missing(bmpB0, "bPanel.bmp")
  10. bmpB1 = LoadImage(0,"data/rcImg.bmp",0,400,300,16) : missing(bmpB1, "data/rcImg.bmp")
  11. '......................................................
  12. bmpB2 = LoadImage(0,"data/guiApp.bmp",0,24,24,16) : missing(bmpB2, "data/guiApp.bmp")
  13. bmpB3 = LoadImage(0,"data/consoleApp.bmp",0,24,24,16) : missing(bmpB3, "data/consoleApp.bmp")
  14. bmpB4 = LoadImage(0,"data/btCut.bmp",0,30,30,16) : missing(bmpB4, "data/btCut.bmp")
  15. bmpB5 = LoadImage(0,"data/btCopy.bmp",0,30,30,16) : missing(bmpB5, "data/btCopy.bmp")
  16. bmpB6 = LoadImage(0,"data/btPaste.bmp",0,30,30,16) : missing(bmpB6, "data/btPaste.bmp")
  17. bmpB7 = LoadImage(0,"data/btCompile.bmp",0,30,30,16) : missing(bmpB7, "data/btCompile.bmp")
  18. bmpB8 = LoadImage(0,"data/btRun.bmp",0,30,30,16) : missing(bmpB8, "data/btRun.bmp")
  19. '##################################################
  20.  
  21. and in about line 234:
  22.  
  23.   hImage = LoadImage(0, "rCodetb.bmp", 0, 280, 20, 24) : missing(hImage, "rCodetb.bmp")
  24.  

Do you need some images at all like btCut.bmp, btCopy.bmp etc. They could be integrated with your rcImg.bmp.

You definitively should add a menu to the application. It is not so comfortably easy as with a resource file (which you do not like) but it is possible. A menu will give you much more flexibility than only using a toolbar.

I would also leave the edit fields of the find/replace dialog blank and add labels in front of them e.g. something like this:
Code: OxygenBasic
  1. 'create single-line edit control
  2. % SS_LEFT=0
  3. % WS_GROUP=0x00020000
  4. label_1= SetStatic(fWindow, 80,32,60,25,"Enter word:",WS_VISIBLE | WS_CHILD | WS_GROUP | SS_LEFT,0,-1)
  5. fwed1 = SetEditBox(fWindow,  150,30,200,23,"",0x50004000,0x200,fwed1ID)
  6.  

This is all for now. There are already good starting points in your project and hopefully you will continue with it. This would also extend your awinh.inc.

Roland

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Re: Aurel Edit
« Reply #2 on: April 05, 2017, 10:50:52 AM »
Hi Arnold
first Thanks for reply  :)
I keep AurelEdit and related files in folder OxygenEditor
and do all changes there .
Yes you have right about images i must clear this block of code as some other things.
Images which are used are toolbar bitmap and AELogo in AboutWindow.
About menu..
well i decide to avoid menu because i really dont need menu for such a
simple editor..
BUT adding MENU would be piece of cake and there is no need to add menu to
resources, also i try to avoid resources .
Menu in most cases duplicate actions from toolbar or versa.
BUT again i will build version with menu because so many people are used to menus.
In my older editor OxyEdit i have menus.  :D
When you say that FindReplace window must be clear...yes
you have right i shoud add two statics and then would be Ok.
About Scilexer...
First AurelEdit currently require Scilexer version 1.6.8.0 ,,and yes i know that is old
also Charles used 2.2.0.0 which is larger just because support more languages.
Functionality shoud be same..right?
So I need to test this newer version with AurelEdit.
And awinh still wait for cleaning and removing binded api-s.
« Last Edit: April 05, 2017, 11:45:02 AM by Aurel »

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Re: Aurel Edit
« Reply #3 on: April 06, 2017, 02:29:26 AM »
Tested Find-Replace work
just add this two function:
Code: [Select]
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub FindNext
INT loc,temp : 'msgBox "FindNext-OK","Find"
if loc=0
loc=SENDMESSAGE hsci,SCI_GETSELECTIONEND,0,0
else
loc=SENDMESSAGE hsci,SCI_GETSELECTIONSTART,0,0
end if

SENDMESSAGE hsci,SCI_SETANCHOR,loc,0,
SENDMESSAGE hsci,SCI_SETCURRENTPOS,loc,0
SENDMESSAGE hsci,SCI_SEARCHANCHOR,0,0
'temp=SCFIND_REGEXP
temp=SCFIND_WHOLEWORD
 loc=SENDMESSAGE hsci,SCI_SEARCHNEXT,temp,GetText(fwed1)
IF loc > -1
      SENDMESSAGE hsci,SCI_SCROLLCARET,0,0
end if
End Sub
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub ReplaceSelected
SENDMESSAGE hsci,SCI_REPLACESEL,0,GetText(fwed2)

End Sub

or download complete code from attachement:
« Last Edit: April 06, 2017, 05:29:01 AM by Aurel »

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Re: Aurel Edit
« Reply #4 on: April 06, 2017, 05:32:04 AM »
Here is version with Find/ReplaceOnce/ReplaceAll function.
I just do quick test and it looks that work...
Arnold if you have time do you can check how work for you?
/ it looks to me that only first match is skipped /  ::)
i must test on bigger file..

.

Arnold

  • Hero Member
  • *****
  • Posts: 677
Re: Aurel Edit
« Reply #5 on: April 07, 2017, 05:26:19 AM »
Hi Aurel,

I was fighting with Scintilla's regex yesterday and lost the first round of the match miserably. But the battle is not yet over.

Maybe I can suggest two small modifications of your code:
I would at least add the extended style WS_TOOLWINDOW | WS_EX_TOPMOST for the fWindow control, I always had to search the find window when I pointed to the text of Scintilla.
For debugging the code I use a very simple but very effective tool:
#include "$/inc/console.inc"

I use printl statements for the console window. If I later comment out the include statement I will easily find the printl statements.
For messages of the application I use mbox (or with awinh.inc I can use MSGBOX)
This way I can follow all kinds of values, variables, controls, messages etc very easily. And when the app crashes I can simply close it by closing the console window. BTW if I close the app and the console window does not close, then something is wrong with my app as gxo2.exe / co2.exe do not release memory and I have to kill them with the task manager. So the console acts as a simple debugging tool for me and has many advantages.

I did this approach for the (print) messages which you added for the find replace dialog. Then I loaded a little test file, entered 'if' and 'uf' in the edit fields and pressed the Replace Button until I got the 'OK' message. Then I set the cursor to the top of the text again and tried to find 'if' again. There are finds, so something is missing. If I try other combinations of using the buttons, something is also missing.

This is not the solution of the problem (I did not explore the code), but I am convinced that the console would help you to find many such critical places very fast. Try it yourself.

Roland


.
« Last Edit: April 07, 2017, 06:09:47 AM by Arnold »

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Re: Aurel Edit
« Reply #6 on: April 07, 2017, 10:08:08 AM »
Yes  Arnold WS_TOPMOST should be better and i can add it without problem.
The code i used for this 3 functions is derived from garryBene Powerbasic scintilla example
so type in google GarryBene Powerbasic scintilla example  and you will find
this functions ,mine is different in some things and work for me but not
exactlly as it should.
Main trick is that you must call ReplaceOnce in loop to get ReplaceAll.
You probably figured that ...right?
I dont do this like Garry and probably that is why not 100% proper.  ::)
 
Code: [Select]
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub FindNext () as long
INT loc,temp : 'msgBox "FindNext-OK","Find"
if loc=0
loc=SENDMESSAGE hsci,SCI_GETSELECTIONEND,0,0
else
loc=SENDMESSAGE hsci,SCI_GETSELECTIONSTART,0,0
end if

SENDMESSAGE hsci,SCI_SETANCHOR,loc,0,
SENDMESSAGE hsci,SCI_SETCURRENTPOS,loc,0
SENDMESSAGE hsci,SCI_SEARCHANCHOR,0,0
'temp=SCFIND_REGEXP
temp=SCFIND_WHOLEWORD
 loc=SENDMESSAGE hsci,SCI_SEARCHNEXT,temp,GetText(fwed1)
IF loc > -1
      SENDMESSAGE hsci,SCI_SCROLLCARET,0,0
ELSE
 Msgbox "No matches found","Search"
printl "Find LOC:" + str(loc) ' -1
return loc
END IF
printl "Find " str(loc)
return loc
End Sub
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function ReplaceOnce(RepeatS As Long) As Long
If FindNext() = -1
Exit Function
End if
Function = 1
SENDMESSAGE hsci,SCI_REPLACESEL,0,GetText(fwed2)
printl "Replaced"
FindNext() 'try to find next
End Function
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Sub ReplaceAll
   dim iResult As Long
   iResult = ReplaceOnce(1)
   While iResult
      iResult = ReplaceOnce(1)
   Wend
   MsgBox " All words Replaced!","Info"
End Sub
'////////////////////////////////////////////////////////////////

John

  • Hero Member
  • *****
  • Posts: 3280
Re: Aurel Edit
« Reply #7 on: April 07, 2017, 01:10:46 PM »
Roland,

It might be worth prototyping your IDE using IUP first and if you still want to dabble with the Windows API and styles, use a Spy like utility to see how IUP did it.

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Re: Aurel Edit
« Reply #8 on: April 09, 2017, 12:55:10 AM »
Hi Charles..
You use in OxIde version 2.2.0.0 of scilexer.
so i look into your scintilla.inc and found that u use SCI_SETLEXER 4001
For which language is this lexer?
thanks

PS. I ask because i want to switch to this newer version even is bigger that old 1.6.8.0
i use in AurelEdit

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Re: Aurel Edit
« Reply #9 on: April 09, 2017, 05:14:24 AM »
Hi Arnold
here is link to Garry Bene site in Power Basic with scintilla example Find/Replace
http://www.garybeene.com/power/code/gbsnippets_gbs_00637.htm

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Re: Aurel Edit
« Reply #10 on: April 09, 2017, 07:06:03 AM »
Hi Arnold , Charles  :D
it looks that i finally fixed problems with Find/Replace/ReplaceAll functions
clicking Find word is selected , then clicking Replace selected word is Replaced
and if i click ReplaceAll if word is selected then each selected word in code is Replaced.
I hope that all that should work for you !

.

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Re: Aurel Edit
« Reply #11 on: April 09, 2017, 09:48:47 AM »
Hi Charles
I am really confused version of scilexer 2.2.0.0 used in OxygenBasic work with your
OxIde but not with mine Aurel Edit
I used lexer SCLEX_LOUT 40 which has same value in version 2.2.0.0
as in 1.6.8.0 so what a heck i must do?
which one you use ?

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3751
    • Oxygen Basic
Re: Aurel Edit
« Reply #12 on: April 10, 2017, 08:27:28 AM »

Hi Aurel, I'm using VBasic lexing:

Code: [Select]
     '3  cpp
     '8  vb ***
     '40 lout
     '51 powerbasic
     '75 freebasic
      sm SCI_SETLEXER, 8, 0
      include "oxykeywords.inc"
      sm SCI_SETKEYWORDS, 0, strptr OxyKeywords
      sm SCI_COLOURISE, 0, -1

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Re: Aurel Edit
« Reply #13 on: April 10, 2017, 11:41:12 AM »
sm SCI_SETKEYWORDS, 0, strptr OxyKeywords
      sm SCI_COLOURISE, 0, -1

ahh i see you use  SCI_COLOURISE,
i dont us it in my version but u will try  :)

Aurel

  • Sr. Member
  • ****
  • Posts: 277
Re: Aurel Edit
« Reply #14 on: April 11, 2017, 08:57:09 AM »
Hi Charles
I have tried your way but nothing .
I only get string and comment colored ..what a heck is with this version >:(

Ok .Charles
Do you can show me where is this all code for scintilla placed ?
In OxIde or somewhere else?
thnx