
NEVER FORGET you can also search https://www.purebasic.com/documentation/PureBasic.pdf (and often quickly get even better help/infos, if you have a good PDF reader like Skim)
Notes:
Dear Fred…
IDE tools seem to have "focus problems" when they use a parameter (I tried some AS "activation" tricks)… in this case it's not a big deal, but see when you search for 'file'… (you get an "unfocused AS list dialog")
Did you also guillotine the google bot? It seems bad, especially @finding Forum [code] stuff…
Code: Select all
; IDE tool, Parameter: %WORD (help on current PB word, but a bit different from standard PB help…)
#helppath$="/Applications/PureBasic.app/Contents/Resources/help/purebasic/"
#ind=#helppath$+"reference/reference.html" ; default
fi$="https://www.purebasic.fr/english/index.php" ; default
#forum="https://www.purebasic.fr/english/search.php?keywords="
fig$="https://www.google.com/" ; default
; adding '/documentation ' excludes non-english help docs:
#forumg="https://www.google.com/search?q=site:purebasic.fr OR site:purebasic.com/documentation "
; Bookmark (JS snippet) to search selection (MULTIPLE words) with a browser (e.g., FireFox):
; javascript:window.open('https://www.google.com/search?q=site:purebasic.fr OR site:purebasic.com/documentation '+document.getSelection());
Procedure.s sh(search$)
Protected Output$, shell
shell = RunProgram("/bin/sh","","",
#PB_Program_Open|#PB_Program_Write|#PB_Program_Read)
If shell
WriteProgramStringN(shell,search$)
WriteProgramData(shell,#PB_Program_Eof,0)
While ProgramRunning(shell)
If AvailableProgramOutput(shell)
Output$ + ReadProgramString(shell) + ~"\n"
EndIf
Wend
CloseProgram(shell)
EndIf
ProcedureReturn RTrim(Output$,~"\n")
EndProcedure
Procedure ResizeWebWindow()
ResizeGadget(10, #PB_Ignore, #PB_Ignore, WindowWidth(0), WindowHeight(0)-52)
ResizeGadget(4, #PB_Ignore, #PB_Ignore, WindowWidth(0)-410, #PB_Ignore)
ResizeGadget(5, WindowWidth(0)-220, #PB_Ignore, #PB_Ignore, #PB_Ignore)
ResizeGadget(6, WindowWidth(0)-70, #PB_Ignore, #PB_Ignore, #PB_Ignore)
ResizeGadget(7, WindowWidth(0)-140, #PB_Ignore, #PB_Ignore, #PB_Ignore)
EndProcedure
wl2$= ProgramParameter()
; wl2$= "file" ; "" ; "runtime" ; "" ; tests
If OpenWindow(0, 0, 0, 1024, 868, "Help for: "+wl2$, #PB_Window_Invisible| #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
CreateStatusBar(0, WindowID(0))
AddStatusBarField(#PB_Ignore)
StatusBarText(0, 0, "Welcome to the Help MiniBrowser!", 0)
ButtonGadget(1, 0, 3, 60, 25, "Back")
ButtonGadget(2, 60, 3, 60, 25, "Next")
ButtonGadget(3, 120, 3, 60, 25, "Stop")
StringGadget(4, 185, 5, 0, 20, wl$) ; wl$ ?!? this is definitely a RAW hack !!!
ButtonGadget(5, 0, 3, 80, 25, "Browser")
ButtonGadget(6, 0, 3, 70, 25, "Forum")
ButtonGadget(7, 0, 3, 70, 25, "Google")
If WebGadget(10, 0, 31, 0, 0, "") = 0
MessageRequester("Error", "Webkit library not found", 0)
End ; Quit
EndIf
BindEvent(#PB_Event_SizeWindow, @ResizeWebWindow())
ResizeWebWindow() ; Adjust the gadget to the current window size
wl$=wl2$
if wl$
s.s=sh("grep -i '"+wl$+"' "+#helppath$+~"index.xml | awk -F'\"' '{ print $(NF-1) }' | sort -u")
if CountString(s,~"\n")
s=sh(~"osascript\n choose from list (paragraphs of \"" + s + ~"\")")
EndIf
s=#helppath$+ s
EndIf
if s = #helppath$+"false" or s = #helppath$ or wl$ = ""
wl$=#ind
If wl2$
fi$= URLEncoder(#forum+wl2$)
fig$= URLEncoder(#forumg+wl2$)
EndIf
else
wl$= URLEncoder(s)
fi$= URLEncoder(#forum+wl2$)
fig$= URLEncoder(#forumg+wl2$)
EndIf
SetGadgetText(10, wl$)
HideWindow (0,#False)
Repeat
Event = WaitWindowEvent(10)
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 1
SetGadgetState(10, #PB_Web_Back)
Case 2
SetGadgetState(10, #PB_Web_Forward)
Case 3
SetGadgetState(10, #PB_Web_Stop)
Case 5
RunProgram("open",GetGadgetText(10),"")
Case 6
SetGadgetText(10, fi$)
Case 7
SetGadgetText(10, fig$)
EndSelect
SetGadgetText(4, GetGadgetText(10))
Case #PB_Event_Menu
Select EventMenu()
Case #PB_Menu_Quit
End
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
EndIf