FreeBasic IDE-poseidonFB(Update 2024.03.03)

User projects written in or related to FreeBASIC.
Post Reply
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2018.04.01)

Post by Kuan Hsu »

kcvinu wrote:Hi,
Custom Tools window is not appearing conrrectly. See this image.
Image
.......
OK, I saw a warning picture........^^
I've modified some code about CallTip, please check at rev.383
Image
The color settings of CallTip are in editorSettings.ini:

Code: Select all

[color]
...
...
calltipFore=112 112 112
calltipBack=255 255 210
calltipHLT=230 0 0
sancho3
Posts: 358
Joined: Sep 30, 2017 3:22

Re: FreeBasic IDE-poseidonFB(Update 2018.03.29)

Post by sancho3 »

kcvinu wrote:@Kuan Hsu,
Its ok. As far as i know, Scintilla will allow us to use its COM object. I have practiced it years ago. It's quiet easy. We can send text to Scintilla editor component via WM_COPYDATA msg. If my experiments succeeded, i can make an add-on to poseidon for creating GUI. Anyway, i am on it.
I am interested in getting access to the editor in poseiden.
Would you be willing to start a post in Projects or General so I can ask you some questions about this without derailing this thread?

Or maybe Kuan, can you tell me if it is possible to access the editor widget/window? Can you give me a starting point if it is?
kcvinu
Posts: 232
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: FreeBasic IDE-poseidonFB(Update 2018.04.02)

Post by kcvinu »

@sancho3,

Hi i am glad that you are interested on scintilla. These are the steps.
1. Get the scintilla edit controls's handle
2. SendMessage(hwndScintilla,sci_command,wparam,lparam)

For getting scintilla handle, You need to use one of these strings.
a.) "DirectorExtension"
b.) "CLASS:Scintilla; INSTANCE:1"
For details, you can browse their site.
Link is here --> http://www.scintilla.org/Steps.html
sancho3
Posts: 358
Joined: Sep 30, 2017 3:22

Re: FreeBasic IDE-poseidonFB(Update 2018.04.02)

Post by sancho3 »

I am using Ubuntu not Windows.
These 3 tries return 0, the last attempt is the window name.

Code: Select all

#Include Once "IUP/iup.bi"
#Include Once "IUP/iup_scintilla.bi"
'dim As ihandle ptr hsci = IupGetHandle( Strptr("DirectorExtension"))
'dim As ihandle ptr hsci = IupGetHandle( Strptr( "CLASS:Scintilla; INSTANCE:0"))

dim As ihandle ptr hsci = IupGetHandle( Strptr( "poseidonFB - FreeBasic IDE"))
? hsci
Sleep 
kcvinu
Posts: 232
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: FreeBasic IDE-poseidonFB(Update 2018.04.02)

Post by kcvinu »

@sancho3,
This is my try in Windows. And it is working.

Code: Select all

#define unicode
#Include "windows.bi"
#Include Once "Afx/CWSTR.inc" 	' This is a nust have item for me in FreeBasic. I Love it. Thanks to Josep Roca !
'============================================ Finding Scintilla=====================================

' A little macro for adding arrays. I hate to redim in each step. Thanks for dodicat. He is the author of this macro.
#Macro ArrayAdd(p,i)
    if Ubound(p) = -1 Then 
        Redim p(0)
		p(0) = i
    Else
		Redim Preserve p(Lbound(p) To Ubound(p)+1)
		p(Ubound(p)) = i
    End If
#Endmacro

' This type is sufficient to fit our child window handle and class name.
Type ChildWins
	CntHwnd As HWND
	CntClsName As CWSTR
	Declare Constructor(cHwnd As HWND, sClsName As String )
	 
	Declare Constructor
End Type
Constructor ChildWins( cHwnd As HWND,  sClsName As String )
	This.CntHwnd = cHwnd
	This.CntClsName = sClsName
End Constructor
Constructor ChildWins( )
	This.CntHwnd = 0
	This.CntClsName = ""
End Constructor

' I want reuse this code in my future hobby projects
Dim Shared WinHwndList(Any) As HWND				' A list for all opened window's handle
Dim Shared ChildrenList(Any) As ChildWins		' This will contain all child control handle and class names



'Call back for enumWindow function
Function ENUMWIN_CallBack( WinHwnd As HWND, lParam As LPARAM) As BOOL
		
	If IsWindowVisible(WinHwnd) Then
		ArrayAdd(WinHwndList, WinHwnd)
	End If
	Return TRUE
End Function

'Callback for EnumChildWindow function
Function EnumChildWinProc( ctHwnd As HWND, lParam As LPARAM) As BOOL
	Dim clsName As CWSTR =  127
	GetClassName(ctHwnd, clsName, 128)
	If Len(clsName) > 0 Then 
		Dim ThisChild As ChildWins = ChildWins(ctHwnd, clsName)
		ArrayAdd(ChildrenList, ThisChild)
		'? clsName
	End If
	Function = TRUE
End Function

' Give a partial title to this function, it will give the handle of the window which contains that title.
Function GetWindowHandle(Byval sTitle As CWSTR) As HWND
	EnumWindows(@ENUMWIN_CallBack,0)
	  
	Dim hResultVal As HWND = NULL
	Dim i As Integer
	For i = 0 To Ubound(WinHwndList)
		Dim txtLen As Integer = SendMessage(WinHwndList(i), WM_GETTEXTLENGTH, 0, 0 )
		Dim TitleFromWin As CWSTR = txtLen + 1
		GetWindowText(WinHwndList(i), TitleFromWin, txtLen + 1 )
				
		If Instr(TitleFromWin, sTitle) Then
			hResultVal = WinHwndList(i)		 
		End If		 
	Next
	Return hResultVal
End Function

' Give a partial title to this function, it will give the full title of the window.
Function GetWindowTitle Overload(Byval sPartialTitle As CWSTR) As CWSTR
	EnumWindows(@ENUMWIN_CallBack,0)
	
	 
	Dim sResultVal As CWSTR
	 
	Dim i As Integer
	For i = 0 To Ubound(WinHwndList)
		
		Dim txtLen As Integer = SendMessage(WinHwndList(i), WM_GETTEXTLENGTH, 0, 0 )
		
		If txtLen > 0 Then
			Dim TitleFromWin As CWSTR = txtLen + 1
			GetWindowText(WinHwndList(i), TitleFromWin,  txtLen + 1  )
			
			 If Instr(TitleFromWin, sPartialTitle) > 0 Then				
				sResultVal = *TitleFromWin				 
				Exit For
			 End If
		End If
		
	Next
	Return sResultVal
End Function

' Give a window handle to this function, it will give the window title of that window.
Function GetWindowTitle (Byval hWinHandle As HWND) As CWSTR
	 
	Dim sResultVal As CWSTR
			
	Dim txtLen As Integer = SendMessage(hWinHandle, WM_GETTEXTLENGTH, 0, 0 )
		
		If txtLen > 0 Then
			Dim TitleFromWin As CWSTR = txtLen + 1
			GetWindowText(hWinHandle, TitleFromWin,  txtLen + 1  )
			
			sResultVal = *TitleFromWin				 
		End If		
	Return sResultVal
End Function


' Give parent window handle and class name of the control. It will give the control's handle.
Function GetControlHandle(Byval hParent As HWND, Byval sClassName As CWSTR) As HWND
	EnumChildWindows(hParent, @EnumChildWinProc, 0)
	Dim hControlHandle As HWND
	For i As Integer = 0 To Ubound(ChildrenList)
		 
		If  ChildrenList(i).CntClsName.wstr = sClassName  Then
						
			hControlHandle = ChildrenList(i).CntHwnd
			Exit for
						
		End If
	Next
	Function = hControlHandle
End Function


Dim PartofTitle As CWSTR = "poseidonFB"
Dim poseidon_HWND As HWND = GetWindowHandle(PartofTitle )
? GetWindowTitle(poseidon_HWND )
? GetControlHandle(poseidon_HWND , "Scintilla")
 
Sleep
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2018.04.02)

Post by Kuan Hsu »

sancho3 wrote:I am using Ubuntu not Windows.
These 3 tries return 0, the last attempt is the window name.

Code: Select all

#Include Once "IUP/iup.bi"
#Include Once "IUP/iup_scintilla.bi"
'dim As ihandle ptr hsci = IupGetHandle( Strptr("DirectorExtension"))
'dim As ihandle ptr hsci = IupGetHandle( Strptr( "CLASS:Scintilla; INSTANCE:0"))

dim As ihandle ptr hsci = IupGetHandle( Strptr( "poseidonFB - FreeBasic IDE"))
? hsci
Sleep 
We couldn't use IupGetHandle in different program, they have Independent memory block, so the getting handle is null.....
I am not a expert about get the window message/handle, what I think is dynamic library( like plugin......I think ):
(1) poseidonFB send the main handle to DLL
(2) In DLL code blocks, Use main handle to do something
(3) ......
I wrote below code and worked in Windows 7 / Linux mint, it convert the document text to upper case and show the poseidonFB main dialog raster size, but it need poseidonFB init/send the handle first.....

Code: Select all

#include once "IUP/iup.bi"
#include once "IUP/iup_scintilla.bi"

'Compile with -dll option
extern "C"
	
	declare sub Send_PoseidonFB_HANDLE alias "Send_PoseidonFB_HANDLE" ( _ih as Ihandle ptr ) ' Send poseidonFB's main dialog handle to DLL, the using "IupGetDialogChild" get child handle
	declare sub Send_SCINTILLA alias "Send_SCINTILLA" ( _ih as Ihandle ptr )
	declare sub Dll_Go alias "Dll_Go" () 

	dim shared as Ihandle ptr POSEIDONFB_HANDLE
	dim shared as Ihandle ptr SCINTILLA_HANDLE

	sub Send_PoseidonFB_HANDLE alias "Send_PoseidonFB_HANDLE"( _ih as Ihandle ptr ) export
		
		POSEIDONFB_HANDLE = _ih
		
	end sub

	sub Send_SCINTILLA alias "Send_SCINTILLA"( _ih as Ihandle ptr ) export
		
		SCINTILLA_HANDLE = _ih
		
	end sub

	sub Dll_Go alias "Dll_Go"() export 
		
		' open a dialog 
		IupOpen( 0, 0 )
		var dlg = IupDialog( 0 )
		IupSetAttributes( dlg, "TITLE=Dll Dialog,RASTERSIZE=640x480" )
		IupShow( dlg )
		
		' Upper case All Document Text
		if( SCINTILLA_HANDLE <> 0 ) then
			dim as zstring ptr	fileString = IupGetAttribute( SCINTILLA_HANDLE, "VALUE" )
			dim as string document = ucase( fileString[0] )
			IupSetAttribute( SCINTILLA_HANDLE, "VALUE", document )
		end if

		' Show the poseidonFB main dialog size
		if( POSEIDONFB_HANDLE <> 0 ) then
			IupMessage( "PoseidonFB Size", IupGetAttribute( POSEIDONFB_HANDLE, "RASTERSIZE" ) )
		end if
		
		IupMainLoop()
		IupClose()		
		
	end sub
	
end extern
Image
sancho3
Posts: 358
Joined: Sep 30, 2017 3:22

Re: FreeBasic IDE-poseidonFB(Update 2018.04.06)

Post by sancho3 »

Thank you both. I have a starting point now.
sancho3
Posts: 358
Joined: Sep 30, 2017 3:22

Re: FreeBasic IDE-poseidonFB(Update 2018.04.02)

Post by sancho3 »

Kuan Hsu wrote: I wrote below code and worked in Windows 7 / Linux mint, it convert the document text to upper case and show the poseidonFB main dialog raster size, but it need poseidonFB init/send the handle first.....

So by this you mean that from within your own dev. environment it worked because you somehow fed it an iup window handle?
Does that means I can't use that method?

Linux doesn't have an over-arching API so it doesn't have any method of obtaining window handles that you don't create. On windows you can use SPY++ and find out all kinds of handle info. Ubuntu has xwininfo, but it can't help me here. It only gives basic info.

From what I have read SCINTILLA uses GTK to create windows. This adds a layer of obfuscation.
On Windows systems you can still use windows messages to interface with it but they recommend against it as that may change.
I am abandoning this task as it has be a lot of work to get nowhere and I don't really know where to go from here.
Thanks for your help anyway.
kcvinu
Posts: 232
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: FreeBasic IDE-poseidonFB(Update 2018.04.07)

Post by kcvinu »

@sancho3,
In Windows, these are the steps.
1. Use EnumWindows function and get the window titles.
2. Loop through them and find the one which have "poseidonFB" . And thus you can get Window handle of poseidon from EnumnWindows.

3. Now, Use EnumChildWindows and loop through all controls in poseidonFB. While iterating, check for that class name. If you find one with "Scintilla" that's your control. Get the control handle from EnumChildWindows.
And once you have got the control handle, you can easily sent messages to scintilla. Their website have listed all possible messages.
Out of curiosity, i am asking you that, how on earth, Linux do these kind of tasks ?
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2018.03.29)

Post by Kuan Hsu »

sancho3 wrote:
kcvinu wrote:@Kuan Hsu,
Its ok. As far as i know, Scintilla will allow us to use its COM object. I have practiced it years ago. It's quiet easy. We can send text to Scintilla editor component via WM_COPYDATA msg. If my experiments succeeded, i can make an add-on to poseidon for creating GUI. Anyway, i am on it.
I am interested in getting access to the editor in poseiden.
Would you be willing to start a post in Projects or General so I can ask you some questions about this without derailing this thread?

Or maybe Kuan, can you tell me if it is possible to access the editor widget/window? Can you give me a starting point if it is?
Please see viewtopic.php?f=3&t=26601
Dinosaur
Posts: 1481
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: FreeBasic IDE-poseidonFB(Update 2018.04.15)

Post by Dinosaur »

Hi All

A problem with parser.
The following line will cause Poseidon to shut down on the typing of the letter "t" when the Autocomplete jumps to the "continue" suggestion.

Code: Select all

If (Control.Liquid > 0) And (Con
If I press Esc on the Autocomplete suggestions and continue typing

Code: Select all

If (Control.Liquid > 0) And (Contr 
a smaller Autocomplete window appears which will allow me to complete the word Control or select
it from the Autocomplete suggestions.

Code: Select all

If (Control.Liquid > 0) And (Control.Cream < 1) Then
Regards

Edit: Using the Parser setting " ..... at Back Thread" with delay of 100 mSec
If I deselect this then there is no problem, (other then the slow response)
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2018.04.15)

Post by Kuan Hsu »

Dinosaur wrote:Hi All

A problem with parser.
The following line will cause Poseidon to shut down on the typing of the letter "t" when the Autocomplete jumps to the "continue" suggestion.

Code: Select all

If (Control.Liquid > 0) And (Con
If I press Esc on the Autocomplete suggestions and continue typing

Code: Select all

If (Control.Liquid > 0) And (Contr 
a smaller Autocomplete window appears which will allow me to complete the word Control or select
it from the Autocomplete suggestions.

Code: Select all

If (Control.Liquid > 0) And (Control.Cream < 1) Then
Regards

Edit: Using the Parser setting " ..... at Back Thread" with delay of 100 mSec
If I deselect this then there is no problem, (other then the slow response)
The issue is about multiple thread for autocomplete and calltip, I've tried to fix at rev.389, please check....
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2018.01.28)

Post by Kuan Hsu »

Imortis wrote:I am guessing that the Linux version does not have the problem I keep having. Randomly (or seems to be random), the editor will crash when opening a file. It has nothing to do with the file, as I can re-open the editor then open the same file and it causes no problems.

I find that while working on a project, either opening a file already in the project, or adding a new file to the project will cause the editor to crash. I am going to guess it is a memory leak as it does not happen immediately after opening the editor. It always happens after I have had the editor open for an extended period of time.

Because of that, I have begun to save the project after every file added. If I don't I will have to re add all the files since the last time I saved or closed the editor properly to the project again.

If there is any extra info I can give you to help trouble shoot this, please let me know.
I found a memory leak bug in the check the file coding if is UTF-8 without Bom, I rewrite the code and commit to rev.390

Another memory issue found that never happened at my desktop but notebook, lt's about reset the parser, I'll fix at next release(392)
kcvinu
Posts: 232
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: FreeBasic IDE-poseidonFB(Update 2018.04.19)

Post by kcvinu »

@Kuan Hsu,
This time, agin i am coming with a feature request. Please consider this if it is possible.
Many times, i (and probably everybody like me) need to run code snippets from forum or somewhere else. On such situations, we need to copy the code to Poseidon and save it to somewhere in hdd in order to run that file. Can you make an option to run snippets without saving ?
I mean poseidon should save it as a temp file without notifying us. An automatic file name setup will be better, like "NoName_1", NoName_2" etc.. An option to specify a folder path for saving temp file is a better idea. Because, all antivirus softwares will check the NoName_1.exe when it starts. So if we set a folder for such operations, we can turn off av checking in that folder. And you can separate auto file saving and manual file saving with a checkbox in toolbar.
Kuan Hsu
Posts: 586
Joined: Sep 16, 2007 15:12
Location: Taiwan

Re: FreeBasic IDE-poseidonFB(Update 2018.04.19)

Post by Kuan Hsu »

kcvinu wrote:@Kuan Hsu,
This time, agin i am coming with a feature request. Please consider this if it is possible.
Many times, i (and probably everybody like me) need to run code snippets from forum or somewhere else. On such situations, we need to copy the code to Poseidon and save it to somewhere in hdd in order to run that file. Can you make an option to run snippets without saving ?
I mean poseidon should save it as a temp file without notifying us. An automatic file name setup will be better, like "NoName_1", NoName_2" etc.. An option to specify a folder path for saving temp file is a better idea. Because, all antivirus softwares will check the NoName_1.exe when it starts. So if we set a folder for such operations, we can turn off av checking in that folder. And you can separate auto file saving and manual file saving with a checkbox in toolbar.
Does "Quick Run" not fit your need? see: viewtopic.php?f=8&t=23935&start=15
Use "Quick Run", poseidonFB will create a auto-named tempfile to compile and run without saving( actually, it saves in auto-named tempfile ), after executing, poseidonFB will delete the tempfile automatically
Post Reply