PB Editor - change tab

Share your advanced PureBasic knowledge/code with the community.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

PB Editor - change tab

Post by eddy »

Code: Select all

Structure FindWindowData
   *handle  ; variable to store a handle
   name.s   ; variable to store a Window name
   class.s  ; variable to store a window class name
EndStructure
Global FindEditor.FindWindowData

Procedure.i FindEditorWindow(WindowHandle, lParam)
   Protected WindowName.s=Space(255)
   Protected WindowClass.s=Space(255)
   If GetWindowText_(WindowHandle, WindowName, 255)
      Protected Result=GetClassName_(WindowHandle, WindowClass, 255)
      If FindString(WindowName, "PureBasic 4.51", 0)
         FindEditor\handle=WindowHandle
         FindEditor\name=WindowName
         FindEditor\class=WindowClass
         ;end of searching
         ProcedureReturn 0
      EndIf
   EndIf
   ;continue searching
   ProcedureReturn 1
EndProcedure
Procedure.i FindEditorTabberToChangeTab(EditorChild, SelectedTab)
   Protected ChildName.s=Space(255)
   Protected ChildClass.s=Space(255)
   If Not GetWindowText_(EditorChild, @ChildName, 255)
      SendMessage_(EditorChild, #WM_GETTEXT, 255, ChildName)
   EndIf
   If GetClassName_(EditorChild, @ChildClass, 255)
      If FindString(ChildClass, "SysTab", 0)
         Static EditorTabber
         Static EditorTabberIndex
         EditorTabberIndex+1
         If EditorTabberIndex=2
            EditorTabberIndex=0
            ;found the second editor tabber
            EditorTabber=EditorChild
            ;select a tab
            SendMessage_(EditorTabber, #TCM_SETCURFOCUS, SelectedTab, 0)
            SendMessage_(EditorTabber, #TCM_SETCURSEL, SelectedTab, 0)
            SendMessage_(EditorTabber, #WM_LBUTTONUP, SelectedTab, 0)
            ;end of searching
            ProcedureReturn 0
         EndIf
      EndIf
   EndIf
   ;continue searching
   ProcedureReturn 1
EndProcedure

Procedure ChangeEditorTab(SelectedTab)
   ;find editor
   EnumWindows_(@FindEditorWindow(), 0)
   
   ;find tabber and change tab
   Protected Editor=FindEditor\handle
   EnumChildWindows_(Editor, @FindEditorTabberToChangeTab(), SelectedTab)
EndProcedure


; ********************
; EXAMPLE
; ********************

#w=200
#h=100
OpenWindow(0, 0, 0, #w, #h, "IDE change tab", #PB_Window_SizeGadget | #PB_Window_ScreenCentered | #PB_Window_SystemMenu)

ChangeEditorTab(0)

Repeat
   Define e=WaitWindowEvent()
Until e=#PB_Event_CloseWindow
End
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
skywalk
Addict
Addict
Posts: 4220
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PB Editor - change tab

Post by skywalk »

Thanks eddy :!:
This works in standalone exe and in a Tool.

Now if I could just get the darn refreshed Scintilla handle. :cry:
My hSCI messages still return text from the original Tab?
hSCI = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))

I will try cascading Tool calls with a shortcut assigned to ChangeEditorTab(x).
Or try to understand your enumeration code better.

Thanks again!
epidemicz
User
User
Posts: 86
Joined: Thu Jan 22, 2009 8:05 am
Location: USA
Contact:

Re: PB Editor - change tab

Post by epidemicz »

Guys, may have to explain what this is supposed to do, I just get a blank window :O
Image
User avatar
skywalk
Addict
Addict
Posts: 4220
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PB Editor - change tab

Post by skywalk »

epidemicz wrote:Guys, may have to explain what this is supposed to do, I just get a blank window :O
eddy's code allows you to navigate the IDE Tabs.
Given there are currently no Tool messages to do that...
http://www.purebasic.fr/english/viewtop ... 66#p342466
epidemicz
User
User
Posts: 86
Joined: Thu Jan 22, 2009 8:05 am
Location: USA
Contact:

Re: PB Editor - change tab

Post by epidemicz »

I still dont get it, explain it to me slowly, like I'm a baby. A stupid baby. But seriously I don't get it. How? Control+Tab works for me?
Image
User avatar
skywalk
Addict
Addict
Posts: 4220
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PB Editor - change tab

Post by skywalk »

epidemicz wrote:I still dont get it, explain it to me slowly, like I'm a baby. A stupid baby. But seriously I don't get it. How? Control+Tab works for me?
LOL...[Ctrl+Tab] works for me too. Just not in a Tool. See my earlier post.

There are many camps in this forum regarding IDEs.
I see PB IDE, jaPBe, NotePad++ and so on.
Simple me, I prefer to use the native PB IDE. It is very good but lacking extended search mechanisms and history logging and whatever.
It is not open source and freak is the only developer I assume.
So to add features while we wait for new stuff to come along if ever, freak enabled Tool communication with the IDE to automate tasks.
Unfortunately, changing the current Tab was not in the Tool "lingo".
Theoretically, with eddy's code, you can now make a Tool that searches the current word in any file in your project, and then set the cursor position to the appropriate Tab and line x column.

Hope this make sense?
epidemicz
User
User
Posts: 86
Joined: Thu Jan 22, 2009 8:05 am
Location: USA
Contact:

Re: PB Editor - change tab

Post by epidemicz »

Ok, I gotcha. I appreciate it :D.

Haven't messed with any of this stuff yet.
Image
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: PB Editor - change tab

Post by freak »

Just a heads up: This isn't going to work in the next PB version because the File selection will be a custom control, not a PanelGadget() then.
quidquid Latine dictum sit altum videtur
User avatar
skywalk
Addict
Addict
Posts: 4220
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PB Editor - change tab

Post by skywalk »

freak wrote:Just a heads up: This isn't going to work in the next PB version because the File selection will be a custom control, not a PanelGadget() then.
DOH!
Without giving away too much, will there be any way to navigate loaded Files via automation?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: PB Editor - change tab

Post by freak »

There are no plans for that at the moment, sorry.
quidquid Latine dictum sit altum videtur
User avatar
skywalk
Addict
Addict
Posts: 4220
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PB Editor - change tab

Post by skywalk »

:cry: My palm reader said to expect lots of [Ctrl+Tab], [Ctrl+Shift+Tab], [Ctrl+F], [Enter], [Enter], [F3]..........zzzzzz.
C64
Enthusiast
Enthusiast
Posts: 151
Joined: Sat Dec 18, 2010 4:40 am

Re: PB Editor - change tab

Post by C64 »

freak wrote:Just a heads up: This isn't going to work in the next PB version because the File selection will be a custom control, not a PanelGadget() then.
ROTFLMAO! :lol:
freak
PureBasic Team
PureBasic Team
Posts: 5941
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: PB Editor - change tab

Post by freak »

quidquid Latine dictum sit altum videtur
Post Reply