1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 15:00:38 +00:00

Merge pull request #90 from QB64-Phoenix-Edition/wiki-dev

Latest Wiki changes and -u switch to populate internal/help during build. Once this is implemented, the respective helpfiles can be removed from the repository.
This commit is contained in:
Roland Heyder 2022-06-01 02:08:38 +02:00 committed by GitHub
commit 9a1ad7dad3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 77 additions and 44 deletions

View file

@ -2307,7 +2307,7 @@ FUNCTION ide2 (ignore)
Help_sy = Help_Back(Help_Back_Pos).sy
Help_cx = Help_Back(Help_Back_Pos).cx
Help_cy = Help_Back(Help_Back_Pos).cy
a$ = Wiki(Back$(Help_Back_Pos))
a$ = Wiki$(Back$(Help_Back_Pos))
WikiParse a$
GOTO newpageparsed
END IF
@ -2565,7 +2565,7 @@ FUNCTION ide2 (ignore)
Help_sy = Help_Back(Help_Back_Pos).sy
Help_cx = Help_Back(Help_Back_Pos).cx
Help_cy = Help_Back(Help_Back_Pos).cy
a$ = Wiki(Back$(Help_Back_Pos))
a$ = Wiki$(Back$(Help_Back_Pos))
WikiParse a$
GOTO newpageparsed
END IF
@ -2652,7 +2652,7 @@ FUNCTION ide2 (ignore)
Help_Back(Help_Back_Pos).cx = 1
Help_Back(Help_Back_Pos).cy = 1
Help_sx = 1: Help_sy = 1: Help_cx = 1: Help_cy = 1
a$ = Wiki(l$)
a$ = Wiki$(l$)
WikiParse a$
GOTO newpageparsed
END IF
@ -2758,7 +2758,7 @@ FUNCTION ide2 (ignore)
Help_Back(Help_Back_Pos).cy = 1
Help_sx = 1: Help_sy = 1: Help_cx = 1: Help_cy = 1
a$ = Wiki(lnk$)
a$ = Wiki$(lnk$)
IF idehelp = 0 THEN
IF idesubwindow THEN PCOPY 3, 0: SCREEN , , 3, 0: GOTO ideloop
@ -5414,8 +5414,16 @@ FUNCTION ide2 (ignore)
PCOPY 2, 0
q$ = ideyesnobox("Update Help", "This can take up to 15 minutes.\nRedownload all cached help content from the wiki?")
PCOPY 2, 0
IF q$ = "Y" THEN ideupdatehelpbox
PCOPY 3, 0: SCREEN , , 3, 0
IF q$ = "Y" THEN
Help_Recaching = 1: Help_IgnoreCache = 1
uerr = ideupdatehelpbox
Help_Recaching = 0: Help_IgnoreCache = 0
PCOPY 3, 0: SCREEN , , 3, 0
IF uerr THEN
lnk$ = "Update All"
GOTO OpenHelpLnk
END IF
END IF
GOTO ideloop
END IF
@ -17607,7 +17615,7 @@ SUB Help_ShowText
IF setup = 0 AND UBOUND(back$) = 1 THEN
setup = 1
IF IdeContextHelpSF = 0 THEN
a$ = Wiki(Back$(1))
a$ = Wiki$(Back$(1))
WikiParse a$
END IF
END IF
@ -18665,7 +18673,15 @@ SUB IdeAddSearched (s2$)
CLOSE #fh
END SUB
SUB ideupdatehelpbox
FUNCTION ideupdatehelpbox
ideupdatehelpbox = 0 'all good, getting 1 on error
IF Help_Recaching = 2 THEN
DIM FullMessage$(1 TO 2)
UpdateStep = 1
Help_ww = 78
GOTO startMainLoop
END IF
'-------- generic dialog box header --------
PCOPY 0, 2
PCOPY 0, 1
@ -18707,8 +18723,9 @@ SUB ideupdatehelpbox
FOR i = 1 TO 100: o(i).par = p: NEXT 'set parent info of objects
'-------- end of generic init --------
startMainLoop:
DO 'main loop
IF Help_Recaching = 2 GOTO updateRoutine
'-------- generic display dialog box & objects --------
idedrawpar p
@ -18813,6 +18830,7 @@ SUB ideupdatehelpbox
END IF
'end of custom controls
updateRoutine:
'-------- update routine -------------------------------------
SELECT CASE UpdateStep
CASE 1
@ -18830,9 +18848,8 @@ SUB ideupdatehelpbox
CASE 3
'Download and PARSE alphabetical index to build required F1 help links
FullMessage$(1) = "Regenerating keyword list..."
Help_Recaching = 1: Help_IgnoreCache = 1
a$ = Wiki$("Keyword Reference - Alphabetical")
Help_Recaching = 0: Help_IgnoreCache = 0
IF INSTR(a$, "{{PageInternalError}}") > 0 THEN ideupdatehelpbox = 1: EXIT DO
WikiParse a$
UpdateStep = UpdateStep + 1
CASE 4
@ -18889,13 +18906,14 @@ SUB ideupdatehelpbox
f2$ = LEFT$(f2$, LEN(f2$) - 4)
n = n + 1
FullMessage$(2) = "Page title: " + f2$
Help_IgnoreCache = 1: Help_Recaching = 1: ignore$ = Wiki(f2$): Help_Recaching = 0: Help_IgnoreCache = 0
ignore$ = Wiki$(f2$)
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) = ""
idetxt(o(ButtonID).txt) = "#Close"
@ -18906,7 +18924,7 @@ SUB ideupdatehelpbox
mousedown = 0
mouseup = 0
LOOP
END SUB
END FUNCTION
FUNCTION ideASCIIbox$(relaunch)
@ -19867,20 +19885,30 @@ FUNCTION findHelpTopic$(topic$, lnks, firstOnly AS _BYTE)
'check if topic$ is in help links
' - returns a list of help links separated by CHR$(0)
' - returns the total number of links found by changing 'lnks'
IF NOT _FILEEXISTS("internal\help\links.bin") THEN
lnks = 0: lnks$ = CHR$(0)
fh = FREEFILE
'----------
linksFileExist = _FILEEXISTS("internal\help\links.bin")
IF linksFileExist THEN
OPEN "internal\help\links.bin" FOR INPUT AS #fh
linksFileEmpty = (LOF(fh) = 0): CLOSE #fh
END IF
IF (NOT linksFileExist) OR linksFileEmpty THEN
q$ = ideyesnobox("Help problem", "The help system is not yet initialized,\ndo it now? (Make sure you're online.)")
PCOPY 3, 0: SCREEN , , 3, 0
IF q$ = "N" THEN lnks = 0: lnks$ = CHR$(0): GOTO noLinksFile
IF q$ = "N" GOTO noLinksFile
Help_IgnoreCache = 1
a$ = Wiki$("Keyword Reference - Alphabetical")
Help_IgnoreCache = 0
IF INSTR(a$, "{{PageInternalError}}") THEN
lnks = 1: lnks$ = lnks$ + "Initialize" + CHR$(0)
GOTO noLinksFile
END IF
Help_ww = 78: WikiParse a$ 'assume standard IDE width for parsing
END IF
'----------
a2$ = UCASE$(topic$)
fh = FREEFILE
OPEN "internal\help\links.bin" FOR INPUT AS #fh
lnks = 0: lnks$ = CHR$(0)
DO UNTIL EOF(fh)
LINE INPUT #fh, l$
c = INSTR(l$, ","): l1$ = LEFT$(l$, c - 1): l2$ = RIGHT$(l$, LEN(l$) - c)

View file

@ -32,20 +32,6 @@ FUNCTION Wiki$ (PageName$) 'Read cached wiki page (download, if not yet cached)
a$ = SPACE$(LOF(fh))
GET #fh, , a$
CLOSE #fh
chr13 = INSTR(a$, CHR$(13))
removedchr13 = 0
DO WHILE chr13 > 0
removedchr13 = -1
a$ = LEFT$(a$, chr13 - 1) + MID$(a$, chr13 + 1)
chr13 = INSTR(a$, CHR$(13))
LOOP
IF removedchr13 THEN
fh = FREEFILE
OPEN Cache_Folder$ + "/" + PageName3$ + ".txt" FOR OUTPUT AS #fh: CLOSE #fh
OPEN Cache_Folder$ + "/" + PageName3$ + ".txt" FOR BINARY AS #fh
PUT #fh, 1, a$
CLOSE #fh
END IF
Wiki$ = a$
EXIT FUNCTION
END IF
@ -53,10 +39,20 @@ FUNCTION Wiki$ (PageName$) 'Read cached wiki page (download, if not yet cached)
'Check for curl
IF _SHELLHIDE("curl --version") <> 0 THEN
PCOPY 2, 0
result = idemessagebox("QB64", "Cannot find 'curl'.", "#Abort")
PCOPY 3, 0: SCREEN , , 3, 0
EXIT FUNCTION
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 QB64 folder." + CHR$(10)
a$ = a$ + "** If there's a file named ''curl-ca-bundle.crt'' or similar, drop it into the QB64 folder too." + CHR$(10)
Wiki$ = a$: EXIT FUNCTION
END IF
'Download message (Status Bar)
@ -112,9 +108,10 @@ FUNCTION Wiki$ (PageName$) 'Read cached wiki page (download, if not yet cached)
a$ = StrReplace$(a$, "Start}}" + CHR$(10) + "'' ''", "Start}}")
a$ = StrReplace$(a$, "'' ''" + CHR$(10) + "{{", CHR$(10) + "{{")
a$ = StrReplace$(a$, "'' '' " + CHR$(10) + "{{", CHR$(10) + "{{")
a$ = StrReplace$(a$, "'' ''" + MKI$(&H0A0A) + "{{", CHR$(10) + "{{")
'--- wiki redirects
a$ = StrReplace$(a$, "'' ''" + CHR$(10) + CHR$(10) + "{{", CHR$(10) + "{{")
'--- wiki redirects & crlf
a$ = StrReplace$(a$, "#REDIRECT", "See page")
a$ = StrReplace$(a$, CHR$(13) + CHR$(10), CHR$(10))
'--- put a download date/time entry
a$ = "{{QBDLDATE:" + DATE$ + "}}" + CHR$(10) + "{{QBDLTIME:" + TIME$ + "}}" + CHR$(10) + a$
'--- now save it
@ -775,8 +772,8 @@ SUB WikiParse (a$) 'Wiki page interpret
IF c$ = ";" AND nl = 1 THEN 'definition (new line only)
IF c$(2) = "; " THEN i = i + 1
Help_Bold = 1: col = Help_Col: Help_DList = 1
IF c$(3) = ";* " THEN i = i + 2: Help_DList = 3 'list dot belongs to description
IF c$(2) = ";*" THEN i = i + 1: Help_DList = 2 'list dot belongs to description
IF c$(3) = ";* " OR c$(3) = ";# " THEN i = i + 2: Help_DList = 3 'list dot belongs to description
IF c$(2) = ";*" OR c$(2) = ";#" THEN i = i + 1: Help_DList = 2 'list dot belongs to description
GOTO charDone
END IF
IF c$ = ":" AND Help_DList > 0 THEN 'description (same or new line)
@ -803,16 +800,16 @@ SUB WikiParse (a$) 'Wiki page interpret
'Wiki lists (*, **) are not handled in blocks (soft- and hard lock), as it would
'disrupt the block, also in code blocks it could be part of the code example itself
IF Help_LockParse = 0 THEN
'Unordered lists
'Unordered/Ordered lists
IF nl = 1 THEN
IF c$(2) = "**" THEN
IF c$(3) = "** " THEN i = i + 2: ELSE i = i + 1
IF c$(2) = "**" OR c$(2) = "##" THEN
IF c$(3) = "** " OR c$(3) = "## " THEN i = i + 2: ELSE i = i + 1
Help_AddTxt " " + CHR$(4) + " ", 14, 0
Help_NewLineIndent = Help_NewLineIndent + 5
GOTO charDone
END IF
IF c$ = "*" THEN
IF c$(2) = "* " THEN i = i + 1
IF c$ = "*" OR c$ = "#" THEN
IF c$(2) = "* " OR c$(2) = "# " THEN i = i + 1
Help_AddTxt CHR$(4) + " ", 14, 0
Help_NewLineIndent = Help_NewLineIndent + 2
GOTO charDone

View file

@ -13118,6 +13118,14 @@ FUNCTION ParseCMDLineArgs$ ()
PRINT " -z Generate C code without compiling to executable"
PRINT
SYSTEM
CASE "-u" 'Invoke "Update all pages" to populate internal/help files (hidden build option)
Help_Recaching = 2: Help_IgnoreCache = 1
IF ideupdatehelpbox THEN
_DEST _CONSOLE
PRINT "Update failed: curl not found"
SYSTEM 1
END IF
SYSTEM
CASE "-c" 'Compile instead of edit
NoIDEMode = 1
cmdlineswitch = -1