diff --git a/harbour/utils/hbdoc/Makefile b/harbour/utils/hbdoc/Makefile index 64a154e20e..fa6c86ce9a 100644 --- a/harbour/utils/hbdoc/Makefile +++ b/harbour/utils/hbdoc/Makefile @@ -14,7 +14,6 @@ PRG_SOURCES=\ gentrf.prg \ genng.prg \ genhtm.prg \ - genchm.prg \ genrtf.prg \ genhpc.prg \ genasc.prg \ diff --git a/harbour/utils/hbdoc/genchm.prg b/harbour/utils/hbdoc/genchm.prg index 4a09975e64..5ab7264f67 100644 --- a/harbour/utils/hbdoc/genchm.prg +++ b/harbour/utils/hbdoc/genchm.prg @@ -308,38 +308,35 @@ FUNCTION ProcessChm() ENDIF cFileName := "" - // Strip off any other non-alphabetic/numeric characters FOR j := 1 TO LEN( cTemp ) cChar := SUBSTR( cTemp, j, 1 ) IF ( cChar >= "0" .AND. cChar <= "9" ) .OR. ; - ( cChar >= "A" .AND. cChar <= "Z" ) .OR. cChar = "_" + ( cChar >= "A" .AND. cChar <= "Z" ) .OR. cChar = "_" cFileName += cChar ENDIF NEXT // See if file name is present already. If so then modify - cFileName := LEFT( cFileName, 21 ) + cFileName := LEFT( cFileName, 36 ) nEnd := 1 nCount := 0 DO WHILE nEnd > 0 - nEnd := ASCAN( aDocInfo, { | a | a[ 4 ] == cFileName + ".htm" } ) + nEnd := ASCAN( aDocInfo, { | a | lower(a[ 4 ]) == lower(cFileName) + ".htm" } ) IF nEnd > 0 // This will break if there are more than 10 files with the same first // seven characters. We take our chances. - IF LEN( cFileName ) = 21 - cFileName := STUFF( cFileName, 21, 1, STR( nCount, 1, 0 ) ) + IF LEN( cFileName ) = 36 + cFileName := STUFF( cFileName, 36, 1, STR( nCount, 1, 0 ) ) ELSE cFileName += STR( nCount, 1, 0 ) ENDIF nCount ++ ENDIF ENDDO - // Add on the extension - - cFileName := LEFT( cFileName, 21 ) + ".htm" + cFileName := LEFT( cFileName, 36 ) + ".htm" IF lDoc oChm := THTML():NewChm( 'chm\' + cFileName ,,cFuncName) ENDIF diff --git a/harbour/utils/hbdoc/genhtm.prg b/harbour/utils/hbdoc/genhtm.prg index 5a943d02d6..47f021b340 100644 --- a/harbour/utils/hbdoc/genhtm.prg +++ b/harbour/utils/hbdoc/genhtm.prg @@ -311,14 +311,14 @@ FUNCTION ProcessWww() FOR j := 1 TO LEN( cTemp ) cChar := SUBSTR( cTemp, j, 1 ) IF ( cChar >= "0" .AND. cChar <= "9" ) .OR. ; - ( cChar >= "A" .AND. cChar <= "Z" ) .OR. cChar = "_" + ( cChar >= "A" .AND. cChar <= "Z" ) .OR. cChar = "_" .or. cchar ="@" cFileName += cChar ENDIF NEXT // See if file name is present already. If so then modify - cFileName := LEFT( cFileName, 21 ) + cFileName := LEFT( cFileName, 36 ) nEnd := 1 nCount := 0 DO WHILE nEnd > 0 @@ -328,8 +328,8 @@ FUNCTION ProcessWww() // This will break if there are more than 10 files with the same first // seven characters. We take our chances. - IF LEN( cFileName ) = 21 - cFileName := STUFF( cFileName, 21, 1, STR( nCount, 1, 0 ) ) + IF LEN( cFileName ) = 36 + cFileName := STUFF( cFileName, 36, 1, STR( nCount, 1, 0 ) ) ELSE cFileName += STR( nCount, 1, 0 ) ENDIF @@ -338,7 +338,7 @@ FUNCTION ProcessWww() ENDDO // Add on the extension - cFileName := LEFT( cFileName, 21 ) + ".htm" + cFileName := LEFT( cFileName, 36 ) + ".htm" IF lDoc oHtm := THTML():New( 'htm\' + cFileName ) ENDIF @@ -405,13 +405,13 @@ FUNCTION ProcessWww() // Now start writing out what we know IF lData - oHtm:WriteText( "

DATA " + ALLTRIM( PAD( cFuncName, 21 ) ) + "

" ) + oHtm:WriteText( "

DATA " + ALLTRIM( cFuncName ) + "

" ) oHtm:WriteText( "

" + cOneline + "

" + hb_osnewline() ) ELSEIF lMethod - oHtm:WriteText( "

METHOD " + ALLTRIM( PAD( cFuncName, 21 ) ) + "

" ) + oHtm:WriteText( "

METHOD " + ALLTRIM( cFuncName ) + "

" ) oHtm:WriteText( "

" + cOneline + "

" + hb_osnewline() ) ELSE - oHtm:WriteText( "

" + ALLTRIM( PAD( cFuncName, 21 ) ) + "

" ) + oHtm:WriteText( "

" + ALLTRIM( cFuncName ) + "

" ) AADD( aWWW, { cFuncName, LEFT( cFileName, AT( ".", cFileName ) - 1 ) } ) oHtm:WriteText( "

" + cOneline + "

" + hb_osnewline() ) ENDIF diff --git a/harbour/utils/hbdoc/genos2.prg b/harbour/utils/hbdoc/genos2.prg index ad2d64c908..7ffd441b5e 100644 --- a/harbour/utils/hbdoc/genos2.prg +++ b/harbour/utils/hbdoc/genos2.prg @@ -240,7 +240,7 @@ FUNCTION ProcessOs2() ENDIF IF .NOT. EMPTY( cSeeAlso ) oOs2:WriteText( ".br") - oOs2:WriteParBold( "See Also&colon." ) + oOs2:WriteParBold( "See Also:" ) FOR nAlso := 1 TO LEN( aAlso ) IF nAlso == 1 @@ -374,14 +374,14 @@ FUNCTION ProcessOs2() IF AT( cSyn, cBuffer ) > 0 IF GetItem( cBuffer, nCurdoc ) - oOs2:WriteParBold( " Syntax" ) + oOs2:WriteParBold( "Syntax" ) nMode := D_SYNTAX lAddBlank := .T. end ELSEIF AT( cConstruct, cBuffer ) > 0 IF GetItem( cBuffer, nCurdoc ) - oOs2:WriteParBold( " Constructor syntax" ) + oOs2:WriteParBold( "Constructor syntax" ) nMode := D_SYNTAX lAddBlank := .T. @@ -389,8 +389,8 @@ end ELSEIF AT( cArg, cBuffer ) > 0 IF GetItem( cBuffer, nCurdoc ) IF !lBlankLine - - oOs2:WriteParBold( " Arguments" ) + oOs2:WriteText( ".br" ) + oOs2:WriteParBold( "Arguments" ) ENDIF @@ -404,7 +404,7 @@ end oOs2:WriteText( ".br" ) ENDIF - oOs2:WriteParBold( " Returns" ) + oOs2:WriteParBold( "Returns" ) nMode := D_RETURN lAddBlank := .T. @@ -416,7 +416,7 @@ end IF !lBlankLine oOs2:WriteText( ".br" ) ENDIF - oOs2:WriteParBold( " Description" ) + oOs2:WriteParBold( "Description" ) nMode := D_DESCRIPTION lAddBlank := .T. @@ -427,7 +427,7 @@ end oOs2:WriteText( ".br" ) //:endpar() ENDIF - oOs2:WriteParBold( " Data" ) + oOs2:WriteParBold( "Data" ) nMode := D_DATALINK lAddBlank := .T. @@ -436,7 +436,7 @@ end ELSEIF AT( cDatanolink, cBuffer ) > 0 IF GetItem( cBuffer, nCurdoc ) IF !lIsDataLink - oOs2:WriteParBold( " Data" ) + oOs2:WriteParBold( "Data" ) ENDIF nMode := D_NORMAL @@ -446,7 +446,7 @@ end ELSEIF AT( cMethodslink, cBuffer ) > 0 IF GetItem( cBuffer, nCurdoc ) - oOs2:WriteParBold( " Method" ) + oOs2:WriteParBold( "Method" ) nMode := D_METHODLINK lAddBlank := .T. @@ -455,7 +455,7 @@ end ELSEIF AT( cMethodsnolink, cBuffer ) > 0 IF GetItem( cBuffer, nCurdoc ) IF !lIsMethodLink - oOs2:WriteParBold( " Methods" ) + oOs2:WriteParBold( "Methods" ) ENDIF nMode := D_NORMAL @@ -466,7 +466,7 @@ end IF !lBlankLine oOs2:WriteText( ".br" ) ENDIF - oOs2:WriteParBold( " Examples" ) + oOs2:WriteParBold( "Examples" ) nMode := D_EXAMPLE lAddBlank := .T. end @@ -476,7 +476,7 @@ end oOs2:WriteText( ".br" ) ENDIF - oOs2:WriteParBold( " Tests" ) + oOs2:WriteParBold( "Tests" ) nMode := D_EXAMPLE lAddBlank := .T. end @@ -489,7 +489,7 @@ end IF !lBlankLine oOs2:WriteText( ".br" ) ENDIF - oOs2:WriteParBold( " Compliance" ) + oOs2:WriteParBold( "Compliance" ) nMode := D_COMPLIANCE lAddBlank := .T. end @@ -498,7 +498,7 @@ end IF !lBlankLine oOs2:WriteText( ".br" ) ENDIF - oOs2:WriteParBold( " Platforms" ) + oOs2:WriteParBold( "Platforms" ) nMode := D_NORMAL lAddBlank := .T. end @@ -507,7 +507,7 @@ end IF !lBlankLine oOs2:WriteText( ".br" ) ENDIF - oOs2:WriteParBold( " Files" ) + oOs2:WriteParBold( "Files" ) nMode := D_NORMAL lAddBlank := .T. @@ -517,7 +517,7 @@ end IF !lBlankLine oOs2:WriteText( ".br" ) ENDIF - oOs2:WriteParBold( " Function" ) + oOs2:WriteParBold( "Function" ) nMode := D_NORMAL lAddBlank := .T. @@ -766,11 +766,12 @@ FUNCTION Formatos2Buff( cBuffer, cStyle, ongi ) cReturn := '' + creturn + ' ' ELSEIF cStyle == 'Syntax' - cReturn := ' ' + cReturn + ' ' + cReturn := '' + Alltrim(cReturn) + '' + ELSEIF cStyle == 'Arguments' nPos := 0 - ? 'Estou em formatos2buff' - ? AT( "", cReturn ) + + IF AT( "", cReturn ) > 0 cReturn := STRTRAN( cReturn, "", "" ) cReturn := STRTRAN( cReturn, "", "" ) @@ -1033,7 +1034,7 @@ FUNCTION Procos2Desc( cBuffer, oOs2, cStyle ) DEFAULT cStyle TO "Default" lendfixed := .F. - IF AT( '', cBuffer ) == 0 .AND. !EMPTY( cBuffer ) .AND. cstyle <> "Example" + IF AT( '', cBuffer ) == 0 .AND. !EMPTY( cBuffer ) .AND. cstyle <> "Example" cBuffer := '' + cBuffer ENDIF IF EMPTY( cBuffer ) @@ -1043,10 +1044,10 @@ FUNCTION Procos2Desc( cBuffer, oOs2, cStyle ) IF cStyle <> "Example" .AND. AT( "", cBuffer ) == 0 .AND. AT( "", cBuffer ) = 0 IF AT( "", cBuffer ) >= 0 .OR. AT( "", cBuffer ) = 0 .AND. !EMPTY( cbuffer ) IF AT( "", cBuffer ) > 0 .AND. AT( "", cBuffer ) > 0 -? " Estou Aqui" + IF cStyle == "Arguments" creturn := cBuffer - ? " Estou Aqui 2" + cReturn := STRTRAN( cReturn, "", "" ) cReturn := STRTRAN( cReturn, "", "" ) cReturn := ALLTRIM( cReturn ) @@ -1061,9 +1062,9 @@ FUNCTION Procos2Desc( cBuffer, oOs2, cStyle ) // cBuffer:= strtran(cBuffer,"","") IF lArgBold - cReturn := '' + cOLine + ' ' + cReturn + ' ' + cReturn := '' + cOLine + ' ' + cReturn + ' ' ELSE - cReturn := '' + cOLine + ' ' + cReturn + ' ' + cReturn := '' + cOLine + ' ' + cReturn + ' ' ENDIF cbuffer := cReturn @@ -1091,6 +1092,7 @@ FUNCTION Procos2Desc( cBuffer, oOs2, cStyle ) ENDIF IF cStyle == "Description" .OR. cStyle == "Compliance" + /* nIdentLevel := 5 nPos := 0 @@ -1124,61 +1126,76 @@ FUNCTION Procos2Desc( cBuffer, oOs2, cStyle ) ENDIF IF !EMPTY( cLine ) - if AT("",cLine)>0 .or. AT("",cLine)>0 - cLine := STRTRAN( cLine, '', '' ) - cLine := STRTRAN( cLine, '', '' ) - oOs2:WriteParBold(cLine,.f.) - Else - IF LEFT(CLINE,LEN(SPACE(nidentLevel ))) ==SPACE(nidentLevel ) - oos2:WriteText( cLine ) - Else - oos2:WriteText(SPACE(nidentLevel )+ cLine ) - endif - Endif + if AT("",cLine)>0 .or. AT("",cLine)>0 + cLine := STRTRAN( cLine, '', '' ) + cLine := STRTRAN( cLine, '', '' ) + oOs2:WriteParBold(cLine,.f.) + Else + oos2:WriteText(SPACE(nidentLevel )+ cLine ) + Endif oOs2:WriteTExt(".br") ENDIF curPos += nPos ENDDO - +*/ + nIdentLevel := 6 + nPos := 0 +/* IF AT( '', cBuffer ) > 0 + cBuffer := STRTRAN( cBuffer, "", "" ) + ENDIF*/ + IF !EMPTY( cBuffer ) + // cBuffer:=SUBSTR(cBuffer,2) +/* cBuffer := STRTRAN( cBuffer, "<", "<" ) + cBuffer := STRTRAN( cBuffer, ">", ">" ) +*/ + cBuffeR := ALLTRIM( cBuffer ) + oos2:WritePar2( cBuffer,":p." ) + ENDIF ELSEIF cStyle == "Arguments" - cBuffer := STRTRAN( cBuffer, ':', "&colon." ) +/* cBuffer := STRTRAN( cBuffer, ':', "&colon." ) cBuffer := STRTRAN( cBuffer, '', 'hp2.' ) cBuffer := STRTRAN( cBuffer, '', 'ehp2.' ) IF AT( '', cBuffer ) > 0 cBuffer := STRTRAN( cBuffer, "", "" ) ENDIF - cBuffer := STRTRAN( cBuffer, "<", "<." ) - cBuffer := STRTRAN( cBuffer, ">", ">." ) IF !EMPTY( cBuffer ) cBuffer := SUBSTR( cBuffer, 2 ) - cBuffer := STRTRAN( cBuffer, 'hp2.', ':hp2.' ) - cBuffer := STRTRAN( cBuffer, 'ehp2.', ':ehp2.' ) oos2:writetext(cbuffer+CRLF+'.br') -/*a oOs2:writeText( cBuffer+CRLF+".br") */ + oOs2:writeText( cBuffer+CRLF+".br") + ENDIF + */ + IF !EMPTY( cBuffer ) + // cBuffer:=SUBSTR(cBuffer,2) + cBuffeR := ALLTRIM( cBuffer ) + oos2:WritePar2( cBuffer,":p." ) ENDIF + ELSEIF cStyle == "Syntax" - IF AT( '', cBuffer ) > 0 +/* IF AT( '', cBuffer ) > 0 cBuffer := STRTRAN( cBuffer, "", "" ) - ENDIF + ENDIF*/ IF !EMPTY( cBuffer ) - cBuffer := SUBSTR( cBuffer, 2 ) +/* cBuffer := SUBSTR( cBuffer, 2 ) oOs2:WriteParBold( cBuffer,.f.) oOs2:writeText('.br') - oOs2:writeText('.br') + oOs2:writeText('.br')*/ +// ? cBuffer + cBuffer:=Alltrim(cBuffer) + oos2:WritePar2( cBuffer,":p.","Syntax" ) ENDIF ELSEIF cStyle == "Default" - IF AT( '', cBuffer ) > 0 +/* IF AT( '', cBuffer ) > 0 cBuffer := STRTRAN( cBuffer, "", "" ) - ENDIF + ENDIF*/ IF !EMPTY( cBuffer ) - cBuffer := SUBSTR( cBuffer, 2 ) - oOs2:WritePar( cBuffer ) + cBuffer := alltrim( cBuffer ) + oOs2:WritePar2( cBuffer ,":p.") ENDIF ENDIF diff --git a/harbour/utils/hbdoc/genrtf.prg b/harbour/utils/hbdoc/genrtf.prg index 813cff5446..145a53e1f8 100644 --- a/harbour/utils/hbdoc/genrtf.prg +++ b/harbour/utils/hbdoc/genrtf.prg @@ -357,7 +357,7 @@ FUNCTION ProcessRtf() ELSEIF lMethod oRtf:WriteJumpTitle( LEFT( cFilename, AT( '.', cFilename ) - 1 ) + cFuncName, "Method " + cFuncName ) ELSE - oRtf:WriteTitle( PAD( cFuncName, 40 ), cFuncName, cOneLine ) + oRtf:WriteTitle( cFuncName, cFuncName, cOneLine ) // oRtf:WriteParBold( cOneLine ) // oRtf:WriteParBox( cBar ) ENDIF diff --git a/harbour/utils/hbdoc/hbdoc.prg b/harbour/utils/hbdoc/hbdoc.prg index fd7d320e95..0f4baeea78 100644 --- a/harbour/utils/hbdoc/hbdoc.prg +++ b/harbour/utils/hbdoc/hbdoc.prg @@ -455,14 +455,14 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) aadd(aMetaContents,{'Keywords',"Harbour project, Clipper, xBase, database, Free Software, GNU, compiler, cross platform, 32-bit, FiveWin,"+cItem}) ohtm:=THTML():new('htm\hb'+strtran(citem," ","")+'.htm',aMetaContents) ohtm:WriteText('

'+adocinfo[1,1]+'


') - ohtm:WriteText("
    ") + ohtm:WriteText("
") for ppp:=1 to len(adocinfo) - if citem ==adocinfo[ppp,1] - oHtm:Writelink(adocinfo[ppp,4],pad(adocinfo[ppp,2],21)+adocinfo[ppp,3]) + if citem ==adocinfo[ppp,1] + oHtm:WritelinkTable(adocinfo[ppp,4],adocinfo[ppp,2],adocinfo[ppp,3]) else - ohtm:WriteText("") + ohtm:WriteText("
") ohtm:close() citem:=adocinfo[ppp,1] aMetaContents:={} @@ -473,14 +473,15 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) // oHtm:WriteMetaTag('Keywords',"Harbour project, Clipper, xBase, database, Free Software, GNU, compiler, cross platform, 32-bit, FiveWin,"+cItem) ohtm:WriteText('

'+adocinfo[ppp,1]+'


') - ohtm:WriteText("
    ") - oHtm:Writelink(adocinfo[ppp,4],pad(adocinfo[ppp,2],21)+adocinfo[ppp,3]) + ohtm:WriteText("") + oHtm:WritelinkTable(adocinfo[ppp,4],adocinfo[ppp,2],adocinfo[ppp,3]) endif next if ppp>len(adocinfo) exit endif enddo + ohtm:WriteText("
    ") ohtm:close() aMetaContents:={} AADD(aMetaContents,{"GENERATOR","HBDOC Harbour document Extractor"}) @@ -528,6 +529,7 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) FWRITE( nHpj, '[OPTIONS]' + CRLF ) FWRITE( nHpj, 'Compatibility=1.1 or later'+CRLF) FWRITE( nHpj, 'Auto Index=Yes'+CRLF) + FWRITE( nHpj,'Full-text search=Yes'+CRLF) FWRITE( nHpj, 'Language=0x416 Português (brasileiro)' + CRLF ) FWRITE( nHpj, 'Contents file=.\'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hhc"+ CRLF ) FWRITE( nHpj, 'Compiled file=.\'+ lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".chm"+ CRLF ) @@ -549,6 +551,7 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) ohtm:=THTML():NewContent('chm\'+lower(substr(cLinkName,1,AT(".",cLinkName)-1)) +".hhc") ohtm:WriteText('') ohtm:Addobject("text/site properties") + oHtm:AddParam("FrameName","Ajuda") ohtm:EndObject() ohtm:WriteText("
      ") oHtm:ListItem() @@ -568,6 +571,7 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) oHtm:AddParam("Local","license.htm") oHtm:EndObject() OHTM:WriteChmLink('license.htm',"Harbour License") + if Alltrim(cLinkName)=='harbour.lnk' oHtm:ListItem() oHtm:AddObject("text/sitemap") oHtm:AddParam("Name","GNU License") @@ -586,7 +590,13 @@ FUNCTION MAIN( cFlags, cLinkName, cAtFile ) oHtm:AddParam("Local","harbourextensions.htm") oHtm:EndObject() OHTM:WriteChmLink('harbourextensions.htm',"Harbour Extensions") + endif oHtm:WriteText( "
    " ) + ohtm:ListItem() + oHtm:AddObject("text/sitemap") + ohtm:addParam("Name","Harbour Functions by Categorie") + oHtm:Endobject() + asort(adocinfo,,,{|x,y| x[1]+x[2]" + CRLF ) + FWRITE( Self:nHandle, "" + CRLF ) if Valtype(aMetaContents) <> NIL .and. Valtype(aMetaContents)=="A" For nCount:=1 to len(aMetaContents) Self:WriteMetaTag(aMetaContents[nCount,1],aMetaContents[nCount,2]) NEXT Endif - FWRITE( Self:nHandle, "" + CRLF ) + RETURN Self METHOD WriteTitle( cTitle ) CLASS THTML FWRITE( Self:nHandle, "" + CRLF + cTitle + CRLF + "" + CRLF + '' + CRLF ) - + FWRITE( Self:nHandle, "" + CRLF ) RETURN Self METHOD WritePar( cPar ) CLASS THTML @@ -137,6 +139,34 @@ METHOD WriteLink( cLink, cName ) CLASS THTML LOCAL nPos LOCAL cTemp := '' + nPos := AT( "()", cLink ) + IF nPos > 0 + if AT(".htm",cLink)=0 + cTemp := SUBSTR( cLink, 1, nPos - 1 ) + '.htm' + else + cTemp := SUBSTR( cLink, 1, nPos - 1 ) + endif + ELSE + if AT(".htm",cLink)=0 + cTemp := ALLTRIM( cLink ) + '.htm' + else + cTemp := ALLTRIM( cLink ) + endif + ENDIF + IF cName != Nil + cLink := cName + ENDIF + cTemp := STRTRAN( cTemp, " ", "" ) + + FWRITE( Self:nHandle, "
  • " + cLink + "
  • " + CRLF ) + +RETURN Self + +METHOD WriteLinkTable( cLink, cName,cInfo ) CLASS THTML + + LOCAL nPos + LOCAL cTemp := '' + nPos := AT( "()", cLink ) IF nPos > 0 if AT(".htm",cLink)=0 @@ -155,7 +185,7 @@ METHOD WriteLink( cLink, cName ) CLASS THTML cLink := cName ENDIF cTemp := STRTRAN( cTemp, " ", "" ) - FWRITE( Self:nHandle, "
  • " + cLink + "
  • " + CRLF ) + FWRITE( Self:nHandle, "" + cLink + "" +cinfo +''+ CRLF ) RETURN Self diff --git a/harbour/utils/hbdoc/os2.prg b/harbour/utils/hbdoc/os2.prg index dac4039091..fe1b8a4dd2 100644 --- a/harbour/utils/hbdoc/os2.prg +++ b/harbour/utils/hbdoc/os2.prg @@ -88,12 +88,15 @@ CLASS TOs2 DATA nHandle DATA aLinkRef DATA nRef - DATA aHeadRef + DATA aHeadRef + DATA aIndRef METHOD New( cFile ) METHOD WritePar( cPar ) + METHOD WritePar2( cPar,ctag ) METHOD WriteLink( cLink ) METHOD ScanLink( cLink ) - METHOD ScanRef( cRef ) + METHOD ScanRef( cRef ) + METHOD ScanInd( cRef ) METHOD WriteJumpLink( cLink, cName, cText ) METHOD CLOSE() METHOD WriteText( cPar ) @@ -108,6 +111,7 @@ METHOD New( cFile ) CLASS TOs2 IF Self:aLinkRef == NIL Self:aLinkRef := {} Self:aHeadRef := {} + Self:aIndRef := {} Self:nRef := 1 ENDIF @@ -133,12 +137,103 @@ METHOD WritePar( cPar ) CLASS TOs2 RETURN Self -METHOD WriteText( cPar ) CLASS TOs2 +METHOD WritePar2( cBuffer,cTag,cStyle ) CLASS TOs2 + Local aLines:={} + LOCAL nPos,cLine:='' + Default cStyle to "Default" +if at("-",cBuffer)>0 +?cBuffer +Endif + cBuffer := STRTRAN( cBuffer, '', ':hp2.' ) + cBuffer := STRTRAN( cBuffer, '', ':ehp2.' ) + cBuffer := STRTRAN( cBuffer, '', '' ) + cBuffer := STRTRAN( cBuffer, '', '' ) + cBuffer := self:DostoOs2Text(cBuffer) +if at("&minus.",cBuffer)>0 + ?cBuffer +Endif + + aLines:=FormatStringBuffer(cBuffer) +if at("&minus.",cBuffer)>0 + ?cBuffer +Endif + + For nPos:=1 to LEN(aLines) + cLine:=aLines[nPos] + If nPos==1 + If !empty(cLine) .and. cStyle <>"Syntax" + FWRITE( Self:nHandle,cTag+ cLine + CRLF) + elseIf !empty(cLine) .and. cStyle =="Syntax" + FWRITE( Self:nHandle,cTag+ ":hp2."+ cLine +":ehp2." +CRLF) + Endif + Else + + If !empty(cLine) .and. cStyle <>"Syntax" + FWRITE( Self:nHandle, cLine + CRLF) + elseIf !empty(cLine) .and. cStyle =="Syntax" + FWRITE( Self:nHandle, ":hp2."+ cLine +":ehp2." +CRLF) + Endif + Endif + NEXT +/* +if cStyle=="Syntax" + ? cBuffer +endif + DO WHILE !lendPar + IF nPos == 0 + cLine := SUBSTR( cBuffer, 1, 231 ) + nPos := RAT( " ", cLine ) + IF nPos > 0 + cLine := SUBSTR( cBuffer, 1, nPos ) + ENDIF + If !empty(cLine) .and. cStyle <>"Syntax" + FWRITE( Self:nHandle,cTag+ cLine + CRLF) + elseIf !empty(cLine) .and. cStyle =="Syntax" + FWRITE( Self:nHandle,cTag+ ":hp2."+ cLine +":ehp2." +CRLF) + Endif + if nLen<255 + lEndpar:=.T. + exit + endif + ELSE + cLine := SUBSTR( cBuffer, curPos, 231 ) + + IF AT( '', cLine ) > 0 + lEndPar := .T. + cLine := STRTRAN( cLine, " ", "" ) + ENDIF + nPos := RAT( " ", cLine ) + IF nPos > 0 + cLine := SUBSTR( cBuffer, curpos, nPos ) + nPos -= 1 + ELSE + IF cLine == "" + cLine := '' + ENDIF + + ENDIF + If !empty(cLine) .and. cStyle <>"Syntax" + FWRITE( Self:nHandle,cTag+ cLine + CRLF) + elseIf !empty(cLine) .and. cStyle =="Syntax" + FWRITE( Self:nHandle,cTag+ ":hp2."+ cLine +":ehp2." +CRLF) + Endif + + ENDIF + + curPos += nPos +? Curpos + ENDDO +*/ + - FWRITE( Self:nHandle, cPar + CRLF ) RETURN Self +METHOD WriteText( cPar ) CLASS TOs2 + FWRITE( Self:nHandle, cPar + CRLF ) +RETURN Self + + METHOD WriteParBold( cPar ,lMarg) CLASS TOs2 DEFAULT lMarg to .t. IF lMarg @@ -155,25 +250,38 @@ METHOD WriteTitle( cTopic, cTitle ,cCategory) CLASS TOs2 LOCAL nPos LOCAL cWrite LOCAL nItem - LOCAL nrItem + LOCAL nrItem,nIItem LOCAL cRefCateg - + LOCAL cIndCateg cTopic := ALLTRIM( cTopic ) - cRefCateg:=ALLTRIM(left(cCategory,5 )) + cRefCateg:=SetCateg(cCategory ) + cIndCateg:=SetInd(cCategory) + IF Self:Scanlink( cTopic ) == 0 nItem := ASCAN( Self:aLinkRef, { | a | upper(a[ 1 ]) == upper(cTopic )} ) ELSE // Just in case that nItem>0 so the Link is already referenced nItem := ASCAN( Self:aLinkRef, { | a | upper(a[ 1 ]) == upper(cTopic) } ) ENDIF - FWRITE( Self:nHandle, ':h1 res=' + ALLTRIM( STR( nItem ) ) + '.' + cTopic + CRLF ) +// FWRITE( Self:nHandle, ':h1 res=' + ALLTRIM( STR( nItem ) ) + '.' + cTopic + CRLF ) + If Self:ScanInd(cIndCateg)==0 + niItem := ASCAN( Self:aIndRef, { | a | upper(a) == upper(cIndCateg )} ) + FWRITE( Self:nHandle, ':h1 ' + ::aIndRef[niItem] + "."+ UPPER( cCategory ) + CRLF) + ELSE // Just in case that nItem>0 so the Link is already referenced + niItem := ASCAN( Self:aIndRef, { | a | upper(a) == upper(cIndCateg) } ) + ENDIF + IF niItem>0 + FWRITE( Self:nHandle, ':h2 '+ 'id=' + ::aIndRef[niItem] +' res=' + ALLTRIM( STR( nItem ) ) + '.' + cTopic + CRLF ) + Endif If Self:ScanRef(cRefCateg)==0 nrItem := ASCAN( Self:aHeadRef, { | a | upper(a) == upper(cRefCateg )} ) - FWRITE( Self:nHandle, ':i1 id=' + ::aHeadRef[nrItem] + " global." + UPPER( cCategory ) + CRLF ) + FWRITE( Self:nHandle, ':i1 id=' + ::aHeadRef[nrItem] + "."+ UPPER( cCategory ) + CRLF) ELSE // Just in case that nItem>0 so the Link is already referenced nrItem := ASCAN( Self:aHeadRef, { | a | upper(a) == upper(cRefCateg) } ) ENDIF + if nritem>0 - FWRITE( Self:nHandle, ':i2 refid=' + ::aHeadRef[nrItem] + " global." + UPPER( cTopic ) + CRLF ) + + FWRITE( Self:nHandle, ':i2 refid=' + ::aHeadRef[nrItem] + "." + UPPER( cTopic ) + CRLF ) Endif cTopic := ::DosToOs2Text(cTopic) cTitle := ::DosToOs2Text(cTitle) @@ -237,18 +345,37 @@ METHOD ScanRef( cLink ) CLASS TOs2 RETURN nItem +METHOD ScanInd( cLink ) CLASS TOs2 + + LOCAL nItem + LOCAL nReturn + + nItem := ASCAN( Self:aIndRef, { | a | Upper(a)== upper(cLink) } ) + + IF nItem == 0 + AADD( Self:aIndRef, upper(cLink)) + ENDIF + +RETURN nItem + METHOD DosToOs2Text( cText ) CLASS TOs2 LOCAL cReturn cReturn := STRTRAN( cText, '&', "&." ) + cReturn := STRTRAN( cReturn, '"', "&cdq." ) - cReturn := STRTRAN( cReturn, ':', "&colon." ) + if at(":hp2.",cReturn)==0 .or. at(":ehp2.",cReturn)==0 + cReturn := STRTRAN( cReturn, ':', "&colon." ) + endif cReturn := STRTRAN( cReturn, ',', "&comma." ) + cReturn := STRTRAN( cReturn, '_', "&us." ) cReturn := STRTRAN( cReturn, '~', "&tilde." ) cReturn := STRTRAN( cReturn, '|', "&splitvbar." ) + cReturn := STRTRAN( cReturn, '/', "&slash." ) + cReturn := STRTRAN( cReturn,"<&slash.par>","") cReturn := STRTRAN( cReturn, ';', "&semi." ) cReturn := STRTRAN( cReturn, ')', "&rpar." ) cReturn := STRTRAN( cReturn, ']', "&rbrk.." ) @@ -258,8 +385,6 @@ METHOD DosToOs2Text( cText ) CLASS TOs2 cReturn := STRTRAN( cReturn, '{', "&lbrc." ) cReturn := STRTRAN( cReturn, '=', "&eq." ) cReturn := STRTRAN( cReturn, '$', "&dollar." ) - cReturn := STRTRAN( cReturn, "<", "<." ) - cReturn := STRTRAN( cReturn, ">", ">." ) cReturn := STRTRAN( cReturn, "-", "&minus." ) RETURN cReturn @@ -286,4 +411,47 @@ METHOD WriteJumpLink( cLink, cText ) CLASS TOs2 RETURN Self +Static function SetCateg(cRef) +Local cReturn +cReturn:=Alltrim(left(cRef,5)) +cReturn+="X" +Return cReturn +Static function SetInd(cRef) +Local cReturn +cReturn:=Alltrim(left(cRef,4)) +cReturn+="Y" +Return cReturn + +Static FUNCTION FormatStringBuffer(cBuffer) +Local nLen,nPos,aLine:={} +Local cLine:='' +nLen:=Len(cBuffer) +? nLen +WHILE nLen>230 + If nLen>230 + cLine:=Substr(cBuffer,1,230) + nPos:=RAT(" ",cLine) + IF nPos>0 + cLine:=Substr(cBuffer,1,nPos) + cBuffer:=Strtran(cBuffer,cLine,"") + AADD(aLine,alltrim(cLine)) + nLen:=Len(cBuffer) + Endif + if at('&minus.',cLine)>0 + nPos:=RAT(".",cLine) + IF nPos>0 + cLine:=Substr(cBuffer,1,nPos) + cBuffer:=Strtran(cBuffer,cLine,"") + AADD(aLine,alltrim(cLine)) + nLen:=Len(cBuffer) + Endif + Endif + Endif +ENDDO +IF nLen<=230 + aadd(aLine,ALLTRIM(cBuffer)) +ENDIF +RETURN aLine *+ EOF: OS2.PRG + +