Page 1 of 1

PB Editor - change tab

Posted: Fri Jan 07, 2011 1:17 am
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

Re: PB Editor - change tab

Posted: Fri Jan 07, 2011 2:20 am
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!

Re: PB Editor - change tab

Posted: Fri Jan 07, 2011 2:23 am
by epidemicz
Guys, may have to explain what this is supposed to do, I just get a blank window :O

Re: PB Editor - change tab

Posted: Fri Jan 07, 2011 2:39 am
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

Re: PB Editor - change tab

Posted: Fri Jan 07, 2011 2:50 am
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?

Re: PB Editor - change tab

Posted: Fri Jan 07, 2011 5:21 am
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?

Re: PB Editor - change tab

Posted: Fri Jan 07, 2011 4:05 pm
by epidemicz
Ok, I gotcha. I appreciate it :D.

Haven't messed with any of this stuff yet.

Re: PB Editor - change tab

Posted: Fri Jan 07, 2011 4:33 pm
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.

Re: PB Editor - change tab

Posted: Fri Jan 07, 2011 5:20 pm
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?

Re: PB Editor - change tab

Posted: Fri Jan 07, 2011 6:12 pm
by freak
There are no plans for that at the moment, sorry.

Re: PB Editor - change tab

Posted: Fri Jan 07, 2011 6:35 pm
by skywalk
:cry: My palm reader said to expect lots of [Ctrl+Tab], [Ctrl+Shift+Tab], [Ctrl+F], [Enter], [Enter], [F3]..........zzzzzz.

Re: PB Editor - change tab

Posted: Sat Jan 08, 2011 9:31 am
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:

Re: PB Editor - change tab

Posted: Mon Jan 10, 2011 2:15 am
by freak