IDE / Scintilla - active tab

Just starting out? Need help? Post your questions and find answers here.
dige
Addict
Addict
Posts: 1404
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

IDE / Scintilla - active tab

Post 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?
"Daddy, I'll run faster, then it is not so far..."
fryquez
Enthusiast
Enthusiast
Posts: 391
Joined: Mon Dec 21, 2015 8:12 pm

Re: IDE / Scintilla - active tab

Post 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
dige
Addict
Addict
Posts: 1404
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: IDE / Scintilla - active tab

Post 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.
"Daddy, I'll run faster, then it is not so far..."
dige
Addict
Addict
Posts: 1404
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: IDE / Scintilla - active tab

Post by dige »

The Includebrowser 'IDE_GetIncludeNames_x86.exe' can download here: https://u.pcloud.link/publink/show?code ... VItYmmPMry
"Daddy, I'll run faster, then it is not so far..."
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: IDE / Scintilla - active tab

Post 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.
quidquid Latine dictum sit altum videtur
AZJIO
Addict
Addict
Posts: 2176
Joined: Sun May 14, 2017 1:48 am

Re: IDE / Scintilla - active tab

Post 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()
dige
Addict
Addict
Posts: 1404
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: IDE / Scintilla - active tab

Post 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
"Daddy, I'll run faster, then it is not so far..."
dige
Addict
Addict
Posts: 1404
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: IDE / Scintilla - active tab

Post 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?
"Daddy, I'll run faster, then it is not so far..."
fryquez
Enthusiast
Enthusiast
Posts: 391
Joined: Mon Dec 21, 2015 8:12 pm

Re: IDE / Scintilla - active tab

Post by fryquez »

You should call the IDE not a .pb file.

RunProgram("PureBasic.exe", "/L 1234", "")
dige
Addict
Addict
Posts: 1404
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: IDE / Scintilla - active tab

Post 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), "")
"Daddy, I'll run faster, then it is not so far..."
Post Reply