Page 1 of 1

IDE / Scintilla - active tab

Posted: Thu Jan 25, 2024 2:28 pm
by dige
Hi guys,

I have written myself an Include Browser which, when started as an IDE tool, determines all includes in the complete project (also within the includes).

I can now search through all files using a search function.

Now I want to display the found location in the IDE and I can't get any further.

I use RunProgram() to load the file into the IDE. How can I now

determine which ID Scintilla has in the currently open tab? So that I can jump to the code line with #SCI_GOTOLINE?

GetEnvironmentVariable("PB_TOOL_Scintilla") is not updated.


Any ideas?

Re: IDE / Scintilla - active tab

Posted: Thu Jan 25, 2024 6:44 pm
by fryquez
Only the active tab's Scintilla window will be visible:

Code: Select all

Procedure EnumWinProc(hwnd, *lparam.Integer)
  
  Protected sClass.s{260}
  
  GetClassName_(hwnd, @sClass, 255)
  If sClass = "Scintilla"
    If IsWindowVisible_(hwnd)
      *lparam\i = hwnd
    EndIf
  EndIf
  
  ProcedureReturn 1
  
EndProcedure

EnumChildWindows_(hwnd_IDE, @EnumWinProc(), @hwnd)
Debug hwnd

Re: IDE / Scintilla - active tab

Posted: Thu Jan 25, 2024 7:45 pm
by dige
Thx fryquez! It works :D

If someone else need this: you can get hwnd_IDE from environment:

Code: Select all

Global hwnd_IDE = Val(GetEnvironmentVariable("PB_TOOL_MainWindow"))
The PB EnvironmentVariables are only available if its executed as exe via the IDE tools.

Re: IDE / Scintilla - active tab

Posted: Thu Jan 25, 2024 8:36 pm
by dige
The Includebrowser 'IDE_GetIncludeNames_x86.exe' can download here: https://u.pcloud.link/publink/show?code ... VItYmmPMry

Re: IDE / Scintilla - active tab

Posted: Thu Jan 25, 2024 11:00 pm
by freak
You can also specify the "-l" (or "/L" on Windows) commandline option to specify a line to jump to in the loaded file.

Re: IDE / Scintilla - active tab

Posted: Fri Jan 26, 2024 12:38 am
by AZJIO
FindAllReferences[Win]

Code: Select all

Global PbIdeHandle, ScintillaHandle
Global g_ClassTextIDE.s, g_TitleTextIDE.s

Global classText.s = Space(256)
; PureBasic, Notepad++, SciTE
Procedure.l enumChildren0(hwnd.l)
	If hwnd
		GetClassName_(hwnd, @classText, 256)
		If classText = g_ClassTextIDE
			GetWindowText_(hwnd, @classText, 256)
			; если заголовок не указан, или в нём есть имя редактора, то применить
			If Not Asc(g_TitleTextIDE) Or FindString(classText, g_TitleTextIDE)
				PbIdeHandle = hwnd
				ProcedureReturn 0
			EndIf
		EndIf
		ProcedureReturn 1
	EndIf
	ProcedureReturn 0
EndProcedure

; Scintilla
Procedure.l enumChildren1(hwnd.l)
	If hwnd
		GetClassName_(hwnd, @classText, 256)
		If classText = "Scintilla"
			ScintillaHandle = hwnd
			ProcedureReturn 0
		EndIf
		ProcedureReturn 1
	EndIf
	ProcedureReturn 0
EndProcedure

g_TitleTextIDE = "PureBasic"
g_ClassTextIDE = "WindowClass_2"
EnumChildWindows_(0, @enumChildren0(), 0)
EnumChildWindows_(PbIdeHandle, @enumChildren1(), 0)

Debug PbIdeHandle
Debug ScintillaHandle
WinGetHandle()

Re: IDE / Scintilla - active tab

Posted: Fri Jan 26, 2024 8:43 am
by dige
freak wrote: Thu Jan 25, 2024 11:00 pm You can also specify the "-l" (or "/L" on Windows) commandline option to specify a line to jump to in the loaded file.
This seems simply the best option - thx freak! :D

Re: IDE / Scintilla - active tab

Posted: Fri Jan 26, 2024 2:21 pm
by dige
@Freak: I've tried to load the code and goto line 1234, but it does not jump.

Code: Select all

RunProgram("PB_SourceCode.pb", "/L 1234", "")
What am I doing wrong?

Re: IDE / Scintilla - active tab

Posted: Fri Jan 26, 2024 2:47 pm
by fryquez
You should call the IDE not a .pb file.

RunProgram("PureBasic.exe", "/L 1234", "")

Re: IDE / Scintilla - active tab

Posted: Fri Jan 26, 2024 3:04 pm
by dige
fryquez wrote: Fri Jan 26, 2024 2:47 pm You should call the IDE not a .pb file.

RunProgram("PureBasic.exe", "/L 1234", "")
Thx fryquez!

Now it works this way:

Code: Select all

RunProgram(GetEnvironmentVariable("PB_TOOL_IDE"), Chr(34) + srcfile.s + Chr(34) + " " + Chr(34) + "/L 1234" + Chr(34), "")