1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-25 18:35:52 +00:00

Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes

This commit is contained in:
Samuel Gomes 2022-11-24 17:51:44 +05:30 committed by GitHub
commit 385807b024
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 117 additions and 56 deletions

View file

@ -229,7 +229,8 @@ Include_GDB_Debugging_Info = idedebuginfo
wikiBaseAddress$ = "https://qb64phoenix.com/qb64wiki"
IF ReadConfigSetting(generalSettingsSection$, "WikiBaseAddress", value$) THEN
wikiBaseAddress$ = value$
ELSE WriteConfigSetting generalSettingsSection$, "WikiBaseAddress", wikiBaseAddress$
ELSE
WriteConfigSetting generalSettingsSection$, "WikiBaseAddress", wikiBaseAddress$
END IF
UseGuiDialogs = ReadWriteBooleanSettingValue%(generalSettingsSection$, "UseGuiDialogs", -1)

View file

@ -5464,7 +5464,7 @@ FUNCTION ide2 (ignore)
IF menu$(m, s) = "Update All #Pages..." THEN
PCOPY 2, 0
q$ = ideyesnobox("Update Help", "This can take up to 20 minutes.\nRedownload all cached help content from the wiki?")
q$ = ideyesnobox("Update Help", "This can take up to 10 minutes.\nRedownload all cached help content from the wiki?")
PCOPY 2, 0
IF q$ = "Y" THEN
Help_Recaching = 1: Help_IgnoreCache = 1
@ -18820,6 +18820,7 @@ FUNCTION ideupdatehelpbox
'update steps
SELECT CASE UpdateStep
CASE 1
FullMessage$(1) = "Preparing help update..."
FullMessage$(2) = "Generating list of cached content..."
CASE 2
FullMessage$(2) = "Adding core help pages to list..."
@ -18844,7 +18845,6 @@ FUNCTION ideupdatehelpbox
maxprogresswidth = 52 'arbitrary
percentage = INT(n / c * 100)
percentagechars = INT(maxprogresswidth * n / c)
'percentageMsg$ = "[" + STRING$(percentagechars, 254) + SPACE$(maxprogresswidth - percentagechars) + "]" + STR$(percentage) + "%"
percentageMsg$ = STRING$(percentagechars, 219) + STRING$(maxprogresswidth - percentagechars, 176) + STR$(percentage) + "%"
_PRINTSTRING (p.x + (p.w \ 2 - LEN(percentageMsg$) \ 2) + 1, p.y + 4), percentageMsg$
ELSEIF UpdateStep = 6 THEN
@ -18908,29 +18908,44 @@ FUNCTION ideupdatehelpbox
SELECT CASE UpdateStep
CASE 1
'Create a list of all files to be recached
st# = TIMER(0.001)
IF Help_Recaching < 2 THEN
f$ = CHR$(0) + idezfilelist$("internal/help", 2, "*.txt") + CHR$(0)
IF LEN(f$) = 2 THEN f$ = CHR$(0)
ELSE
f$ = CHR$(0) 'no dir scan for 'qb64pe -u' (build time update)
END IF
'Prepend core pages to list
f$ = CHR$(0) + "Keyword_Reference_-_By_usage.txt" + f$
f$ = CHR$(0) + "QB64_Help_Menu.txt" + f$
f$ = CHR$(0) + "QB64_FAQ.txt" + f$
et# = TIMER(0.001) - st#: IF et# < 0 THEN et# = et# + 86400
IF 1.25 - et# > 0 THEN _DELAY 1.25 - et#
UpdateStep = UpdateStep + 1
CASE 2
'Prepend core pages to list (if not already in list)
st# = TIMER(0.001)
PageName2$ = "QB64_FAQ.txt"
IF INSTR(f$, CHR$(0) + PageName2$ + CHR$(0)) = 0 THEN f$ = CHR$(0) + PageName2$ + f$
PageName2$ = "QB64_Help_Menu.txt"
IF INSTR(f$, CHR$(0) + PageName2$ + CHR$(0)) = 0 THEN f$ = CHR$(0) + PageName2$ + f$
PageName2$ = "ERROR_Codes.txt"
IF INSTR(f$, CHR$(0) + PageName2$ + CHR$(0)) = 0 THEN f$ = CHR$(0) + PageName2$ + f$
PageName2$ = "Keywords_currently_not_supported_by_QB64.txt"
IF INSTR(f$, CHR$(0) + PageName2$ + CHR$(0)) = 0 THEN f$ = CHR$(0) + PageName2$ + f$
PageName2$ = "Keyword_Reference_-_By_usage.txt"
IF INSTR(f$, CHR$(0) + PageName2$ + CHR$(0)) = 0 THEN f$ = CHR$(0) + PageName2$ + f$
et# = TIMER(0.001) - st#: IF et# < 0 THEN et# = et# + 86400
IF 1.25 - et# > 0 THEN _DELAY 1.25 - et#
UpdateStep = UpdateStep + 1
CASE 3
'Download and PARSE alphabetical index to build required F1 help links
FullMessage$(1) = "Regenerating keyword list..."
st# = TIMER(0.001)
a$ = Wiki$("Keyword Reference - Alphabetical")
IF INSTR(a$, "{{PageInternalError}}") > 0 THEN ideupdatehelpbox = 1: EXIT DO
WikiParse a$ 'update links.bin and check for plugin templates
et# = TIMER(0.001) - st#: IF et# < 0 THEN et# = et# + 86400
IF 1.25 - et# > 0 THEN _DELAY 1.25 - et#
UpdateStep = UpdateStep + 1
CASE 4
'Add all linked pages to download list (if not already in list)
st# = TIMER(0.001)
fh = FREEFILE
OPEN "internal\help\links.bin" FOR INPUT AS #fh
DO UNTIL EOF(fh)
@ -18952,47 +18967,40 @@ FUNCTION ideupdatehelpbox
END SELECT
NEXT
PageName2$ = PageName2$ + ".txt"
IF INSTR(f$, CHR$(0) + PageName2$ + CHR$(0)) = 0 THEN
f$ = f$ + PageName2$ + CHR$(0)
END IF
IF INSTR(f$, CHR$(0) + PageName2$ + CHR$(0)) = 0 THEN f$ = f$ + PageName2$ + CHR$(0)
END IF
END IF
LOOP
CLOSE #fh
'Redownload all listed files
IF f$ <> CHR$(0) THEN
c = 0 'count files to download
FOR x = 2 TO LEN(f$)
IF ASC(f$, x) = 0 THEN c = c + 1
NEXT
c = c - 1
f$ = RIGHT$(f$, LEN(f$) - 1)
z$ = CHR$(0)
n = 0
ELSE
GOTO stoprecache
END IF
'count all listed files to download
c = 0
FOR x = 2 TO LEN(f$)
IF ASC(f$, x) = 0 THEN c = c + 1
NEXT
'set start conditions
f$ = RIGHT$(f$, LEN(f$) - 1)
n = 0
FullMessage$(2) = ""
et# = TIMER(0.001) - st#: IF et# < 0 THEN et# = et# + 86400
IF 1.25 - et# > 0 THEN _DELAY 1.25 - et#
UpdateStep = UpdateStep + 1
CASE 5
'Redownload all listed files
IF LEN(f$) > 0 THEN
x2 = INSTR(f$, z$)
f2$ = LEFT$(f$, x2 - 1): f$ = RIGHT$(f$, LEN(f$) - x2)
x2 = INSTR(f$, CHR$(0))
f2$ = LEFT$(f$, x2 - 1): f$ = MID$(f$, x2 + 1)
IF RIGHT$(f2$, 4) = ".txt" THEN
f2$ = LEFT$(f2$, LEN(f2$) - 4)
n = n + 1
FullMessage$(2) = "Page title: " + f2$
FullMessage$(2) = "Page: " + f2$
ignore$ = Wiki$(f2$)
IF INSTR(ignore$, "{{PageInternalError}}") > 0 THEN ideupdatehelpbox = 1: EXIT DO
WikiParse ignore$ 'just check for plugin templates
END IF
ELSE
UpdateStep = UpdateStep + 1
END IF
CASE 6
stoprecache:
IF Help_Recaching = 2 THEN EXIT DO
FullMessage$(1) = "All pages updated."
FullMessage$(2) = ""

View file

@ -1,6 +1,7 @@
FUNCTION Back2BackName$ (a$)
IF a$ = "Keyword Reference - Alphabetical" THEN Back2BackName$ = "Alphabetical": EXIT FUNCTION
IF a$ = "Keyword Reference - By usage" THEN Back2BackName$ = "By Usage": EXIT FUNCTION
IF a$ = "Keywords currently not supported by QB64" THEN Back2BackName$ = "Unsupported": EXIT FUNCTION
IF a$ = "QB64 Help Menu" THEN Back2BackName$ = "Help": EXIT FUNCTION
IF a$ = "QB64 FAQ" THEN Back2BackName$ = "FAQ": EXIT FUNCTION
Back2BackName$ = a$
@ -38,22 +39,22 @@ FUNCTION Wiki$ (PageName$) 'Read cached wiki page (download, if not yet cached)
END IF
'Check for curl
IF _SHELLHIDE("curl --version >NUL") <> 0 THEN
a$ = CHR$(10) + "{{PageInternalError}}" + CHR$(10)
IF PageName$ = "Initialize" THEN
a$ = a$ + "To be able to initialize the help system, "
ELSEIF PageName$ = "Update All" THEN
a$ = a$ + "To be able to update the help pages from the online Wiki, "
ELSE
a$ = a$ + "The requested help page is not yet cached locally. To download the help page from the online Wiki, "
END IF
a$ = a$ + "a tool called ''curl'' is required, but it wasn't found on your system." + CHR$(10) + CHR$(10)
a$ = a$ + "* To get ''curl'', visit the official [https://curl.se/download.html download page]." + CHR$(10)
a$ = a$ + "** Grab the latest ''binary'' archive available for your system." + CHR$(10)
a$ = a$ + "** Unpack and drop the ''curl'' executable into the '''qb64pe''' folder." + CHR$(10)
a$ = a$ + "** If there's a file named ''curl-ca-bundle.crt'' or similar, drop it into the '''qb64pe''' folder too." + CHR$(10)
Wiki$ = a$: EXIT FUNCTION
END IF
'IF _SHELLHIDE("curl --version >NUL") <> 0 THEN
' a$ = CHR$(10) + "{{PageInternalError}}" + CHR$(10)
' IF PageName$ = "Initialize" THEN
' a$ = a$ + "To be able to initialize the help system, "
' ELSEIF PageName$ = "Update All" THEN
' a$ = a$ + "To be able to update the help pages from the online Wiki, "
' ELSE
' a$ = a$ + "The requested help page is not yet cached locally. To download the help page from the online Wiki, "
' END IF
' a$ = a$ + "a tool called ''curl'' is required, but it wasn't found on your system." + CHR$(10) + CHR$(10)
' a$ = a$ + "* To get ''curl'', visit the official [https://curl.se/download.html download page]." + CHR$(10)
' a$ = a$ + "** Grab the latest ''binary'' archive available for your system." + CHR$(10)
' a$ = a$ + "** Unpack and drop the ''curl'' executable into the '''qb64pe''' folder." + CHR$(10)
' a$ = a$ + "** If there's a file named ''curl-ca-bundle.crt'' or similar, drop it into the '''qb64pe''' folder too." + CHR$(10)
' Wiki$ = a$: EXIT FUNCTION
'END IF
'Download message (Status Bar)
IF Help_Recaching = 0 THEN
@ -68,19 +69,25 @@ FUNCTION Wiki$ (PageName$) 'Read cached wiki page (download, if not yet cached)
END IF
'Url query and output arguments for curl
url$ = CHR$(34) + wikiBaseAddress$ + "/index.php?title=" + PageName2$ + "&action=edit" + CHR$(34)
'url$ = CHR$(34) + wikiBaseAddress$ + "/index.php?title=" + PageName2$ + "&action=edit" + CHR$(34)
url$ = wikiBaseAddress$ + "/index.php?title=" + PageName2$ + "&action=edit"
outputFile$ = Cache_Folder$ + "/" + PageName3$ + ".txt"
'Wikitext delimiters
s1$ = "name=" + CHR$(34) + "wpTextbox1" + CHR$(34) + ">"
s2$ = "</textarea>"
'Download page using curl
SHELL _HIDE "curl --silent -o " + CHR$(34) + outputFile$ + CHR$(34) + " " + url$
'SHELL _HIDE "curl --silent -o " + CHR$(34) + outputFile$ + CHR$(34) + " " + url$
fh = FREEFILE
OPEN outputFile$ FOR BINARY AS #fh 'get new content
a$ = SPACE$(LOF(fh))
GET #fh, 1, a$
CLOSE #fh
'OPEN outputFile$ FOR BINARY AS #fh 'get new content
'a$ = SPACE$(LOF(fh))
'GET #fh, 1, a$
'CLOSE #fh
IF PageName$ = "Initialize" OR PageName$ = "Update All" THEN
a$ = "" 'dummy pages (for error display)
ELSE
a$ = wikiDLPage$(url$, 15)
END IF
'Find wikitext in the downloaded page
s1 = INSTR(a$, s1$)
@ -121,7 +128,7 @@ FUNCTION Wiki$ (PageName$) 'Read cached wiki page (download, if not yet cached)
CLOSE #fh
ELSE
'Delete page, if empty or corrupted (force re-download on next access)
KILL outputFile$
'KILL outputFile$
a$ = CHR$(10) + "{{PageInternalError}}" + CHR$(10) +_
"* Either the requested page is not yet available in the Wiki," + CHR$(10) +_
"* or the download from Wiki failed and corrupted the page data." + CHR$(10) +_
@ -1068,6 +1075,51 @@ FUNCTION wikiSafeName$ (page$) 'create a unique name for both case sensitive & i
wikiSafeName$ = page$ + "_" + ext$
END FUNCTION
$UNSTABLE:HTTP
FUNCTION wikiDLPage$ (url$, timeout!)
'--- set default result & avoid side effects ---
wikiDLPage$ = ""
wik$ = url$: tio! = timeout!
'--- open client ---
retry:
ch& = _OPENCLIENT(wik$)
IF Help_Recaching < 2 THEN 'avoid messages for 'qb64pe -u' (build time update)
IF ch& = 0 AND LCASE$(LEFT$(wik$, 8)) = "https://" THEN
IF _MESSAGEBOX("QB64-PE Help", "Can't make secure connection (https:) to Wiki, shall the IDE use unsecure (http:) instead?", "yesno", "warning" ) = 1 THEN
IF _MESSAGEBOX("QB64-PE Help", "Do you wanna save your choice permanently for the future?", "yesno", "question" ) = 1 THEN
wikiBaseAddress$ = "http://" + MID$(wikiBaseAddress$, 9)
WriteConfigSetting generalSettingsSection$, "WikiBaseAddress", wikiBaseAddress$
END IF
wik$ = "http://" + MID$(wik$, 9): GOTO retry
END IF
END IF
END IF
IF ch& = 0 THEN EXIT FUNCTION
'--- wait for response ---
res$ = "": st! = TIMER
DO
_DELAY 0.05
GET ch&, , rec$
IF LEN(rec$) > 0 THEN st! = TIMER
res$ = res$ + rec$
IF _STATUSCODE(ch&) = 200 THEN
le& = LOF(ch&)
IF le& > -1 THEN
IF LEN(res$) = le& THEN
wikiDLPage$ = res$: EXIT DO
END IF
ELSE
IF EOF(ch&) THEN
wikiDLPage$ = res$: EXIT DO
END IF
END IF
ELSE
tio! = 0
END IF
LOOP UNTIL TIMER > st! + tio!
CLOSE ch&
END FUNCTION
FUNCTION wikiLookAhead$ (a$, i, token$) 'Prefetch further wiki text
wikiLookAhead$ = "": IF i >= LEN(a$) THEN EXIT FUNCTION
j = INSTR(i, a$, token$)

View file

@ -13177,7 +13177,7 @@ FUNCTION ParseCMDLineArgs$ ()
Help_Recaching = 2: Help_IgnoreCache = 1
IF ideupdatehelpbox THEN
_DEST _CONSOLE
PRINT "Update failed: curl not found"
PRINT "Update failed: Can't make connection to Wiki."
SYSTEM 1
END IF
SYSTEM