From 94a2b8337516eabe872836bf7e0a9ce34cef0cdb Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Fri, 9 Jul 2010 02:12:21 +0000 Subject: [PATCH] 2010-07-08 19:01 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/hbide.prg * contrib/hbide/idedocks.prg * contrib/hbide/ideedit.prg * contrib/hbide/ideeditor.prg * contrib/hbide/idefunctions.prg * contrib/hbide/ideharbourhelp.prg + Implemented: Harbour function definitions which are part of Harbour documentation files in /doc/en folders viewable in Documentation Viewer available as code completion lists. For this to happen, you must have Harbour's root path provided in Documentation Viewer dialog. So, as an example, if definitions are loaded ok, you must see a list of QWeb*() functions as soon as you type "Web" in an editing instance. Please provide your input what else is missing. --- harbour/ChangeLog | 18 ++ harbour/contrib/hbide/hbide.prg | 7 +- harbour/contrib/hbide/idedocks.prg | 2 - harbour/contrib/hbide/ideedit.prg | 8 +- harbour/contrib/hbide/ideeditor.prg | 36 +++- harbour/contrib/hbide/idefunctions.prg | 36 ++-- harbour/contrib/hbide/ideharbourhelp.prg | 248 +++++++++-------------- 7 files changed, 176 insertions(+), 179 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3bd04025e1..c2984bd6b4 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,24 @@ The license applies to all entries newer than 2009-04-28. */ +2010-07-08 19:01 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbide/hbide.prg + * contrib/hbide/idedocks.prg + * contrib/hbide/ideedit.prg + * contrib/hbide/ideeditor.prg + * contrib/hbide/idefunctions.prg + * contrib/hbide/ideharbourhelp.prg + + Implemented: Harbour function definitions which are part of + Harbour documentation files in /doc/en folders viewable in + Documentation Viewer available as code completion lists. + For this to happen, you must have Harbour's root path + provided in Documentation Viewer dialog. + So, as an example, if definitions are loaded ok, you + must see a list of QWeb*() functions as soon as you type "Web" + in an editing instance. + + Please provide your input what else is missing. + 2010-07-08 10:21 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/hbide.prg * contrib/hbide/idedocks.prg diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index 717e551290..e6251ad750 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -430,7 +430,7 @@ METHOD HbIde:create( aParams ) hbide_loadThemes( Self ) /* Harbour Help Object */ - ::oHL := ideHarbourHelp():new():create( Self ) +// ::oHL := ideHarbourHelp():new():create( Self ) /* DOCKing windows and ancilliary windows */ ::oDK := IdeDocks():new():create( Self ) @@ -461,6 +461,9 @@ METHOD HbIde:create( aParams ) /* Edits Manager */ ::oEM := IdeEditsManager():new( Self ):create() + /* Harbour Help Object */ + ::oHL := ideHarbourHelp():new():create( Self ) + /* Load Environments */ ::oEV := IdeEnvironments():new( Self ):create() @@ -535,6 +538,8 @@ METHOD HbIde:create( aParams ) ::qTabWidget:setCurrentIndex( ::qTabWidget:count() - 1 ) ::qTabWidget:setCurrentIndex( val( ::oINI:cRecentTabIndex ) ) + ::oEM:updateCompleter() + ::showApplicationCursor() qSplash:close() diff --git a/harbour/contrib/hbide/idedocks.prg b/harbour/contrib/hbide/idedocks.prg index de9b8e1954..ac0f936543 100644 --- a/harbour/contrib/hbide/idedocks.prg +++ b/harbour/contrib/hbide/idedocks.prg @@ -570,8 +570,6 @@ METHOD IdeDocks:setViewInitials( cView ) ::setView( cView ) -HB_TRACE( HB_TR_ALWAYS, cView, ::qTabWidget:count() ) - IF ::qTabWidget:count() == 1 ::oEM:setSourceVisibleByIndex( 0 ) ELSE diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index 2438e54dff..2f9e0a72ed 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -2201,10 +2201,14 @@ METHOD IdeEdit:parseCodeCompletion( cSyntax ) LOCAL cText, n IF ::oINI:lCompleteArgumented - cText := trim( cSyntax ) + IF ( n := rat( ")", cSyntax ) ) > 0 + cText := trim( substr( cSyntax, 1, n ) ) + ELSE + cText := trim( cSyntax ) + ENDIF ELSE IF ( n := at( "(", cSyntax ) ) > 0 - cText := trim( substr( cSyntax, 1, n - 1 ) ) + cText := trim( substr( cSyntax, 1, n ) ) ELSE cText := trim( cSyntax ) ENDIF diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index 4e1dc6128f..9d26d8ceaa 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -228,14 +228,46 @@ METHOD IdeEditsManager:create( oIde ) ::oIde:qProtoList := QStringList():new() ::oIde:qCompModel := QStringListModel():new() ::oIde:qCompleter := QCompleter():new() + ::connect( ::qCompleter, "activated(QString)", {|p| ::execEvent( "qcompleter_activated", p ) } ) - ::updateCompleter() RETURN Self /*----------------------------------------------------------------------*/ METHOD IdeEditsManager:updateCompleter() + LOCAL aFun := ::oFN:getFunctionPrototypes() + LOCAL aHrb := ::oHL:getFunctionPrototypes() + LOCAL n, s, a_, k_:={} + + ::disconnect( ::qCompleter, "activated(QString)", {|p| ::execEvent( "qcompleter_activated", p ) } ) + + FOR EACH a_ IN { aFun, aHrb } + FOR EACH s IN a_ + s := trim( s ) + IF ::oINI:lCompletionWithArgs + IF ascan( k_, s ) == 0 + aadd( k_, s ) + ENDIF + ELSE + IF ( n := at( "(", s ) ) == 0 + IF ( n := at( " ", s ) ) > 0 + aadd( k_, substr( s, 1, n - 1 ) ) + ELSE + aadd( k_, trim( s ) ) + ENDIF + ELSE + aadd( k_, substr( s, 1, n - 1 ) ) + ENDIF + ENDIF + NEXT + NEXT + + asort( k_, , , {|e,f| lower( e ) < lower( f ) } ) + + ::qProtoList:clear() + + aeval( k_, {|e| ::qProtoList:append( e ) } ) ::qCompModel:setStringList( ::qProtoList ) ::qCompleter:setModel( ::qCompModel ) @@ -246,6 +278,8 @@ METHOD IdeEditsManager:updateCompleter() QListView():from( ::qCompleter:popup() ):setAlternatingRowColors( .t. ) + ::connect( ::qCompleter, "activated(QString)", {|p| ::execEvent( "qcompleter_activated", p ) } ) + RETURN Self /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbide/idefunctions.prg b/harbour/contrib/hbide/idefunctions.prg index af1e56ae2b..08496df6d9 100644 --- a/harbour/contrib/hbide/idefunctions.prg +++ b/harbour/contrib/hbide/idefunctions.prg @@ -125,6 +125,7 @@ CLASS IdeFunctions INHERIT IdeObject METHOD clearProjects() METHOD getMarkedProjects() METHOD enableControls( lEnable ) + METHOD getFunctionPrototypes() ENDCLASS @@ -591,7 +592,7 @@ METHOD IdeFunctions:consolidateList() /*----------------------------------------------------------------------*/ METHOD IdeFunctions:populateTable() - LOCAL oTbl, qItm, a_, n, s, k_:={} + LOCAL oTbl, qItm, a_, n LOCAL qApp := QApplication():new() ::clear( .t. ) @@ -616,34 +617,23 @@ METHOD IdeFunctions:populateTable() ::oUI:q_labelEntries:setText( "Entries: " + hb_ntos( n ) ) NEXT - FOR EACH a_ IN ::aList - s := a_[ 2 ] - IF ::oINI:lCompletionWithArgs - aadd( k_, trim( s ) ) - ELSE - IF ( n := at( "(", s ) ) == 0 - IF ( n := at( " ", s ) ) > 0 - aadd( k_, substr( s, 1, n - 1 ) ) - ELSE - aadd( k_, trim( s ) ) - ENDIF - ELSE - aadd( k_, substr( s, 1, n - 1 ) ) - ENDIF - ENDIF - NEXT - - asort( k_, , , {|e,f| lower( e ) < lower( f ) } ) - - ::qProtoList:clear() - aeval( k_, {|e| ::qProtoList:append( e ) } ) - ::oEM:updateCompleter() RETURN Self /*----------------------------------------------------------------------*/ +METHOD IdeFunctions:getFunctionPrototypes() + LOCAL aProto := {}, a_ + + FOR EACH a_ IN ::aList + aadd( aProto, alltrim( a_[ 2 ] ) ) + NEXT + + RETURN aProto + +/*----------------------------------------------------------------------*/ + STATIC FUNCTION hbide_abbrFuncType( cFunc ) LOCAL cAbbr := "" diff --git a/harbour/contrib/hbide/ideharbourhelp.prg b/harbour/contrib/hbide/ideharbourhelp.prg index 44cd85783d..e21ea2bc4f 100644 --- a/harbour/contrib/hbide/ideharbourhelp.prg +++ b/harbour/contrib/hbide/ideharbourhelp.prg @@ -122,6 +122,8 @@ CLASS IdeDocFunction DATA oTVItem DATA cSourceTxt INIT "" + DATA lOk INIT .f. + METHOD new() INLINE Self ENDCLASS @@ -147,6 +149,10 @@ CLASS IdeHarbourHelp INHERIT IdeObject DATA hIndex INIT {=>} + DATA aProtoTypes INIT {} + DATA lLoadedProto INIT .f. + DATA aFuncDefs INIT {} + METHOD new( oIde ) METHOD create( oIde ) METHOD show() @@ -175,6 +181,8 @@ CLASS IdeHarbourHelp INHERIT IdeObject METHOD parseTextFile( cTextFile, oParent ) METHOD jumpToFunction( cFunction ) METHOD getDocFunction( acBuffer ) + METHOD getFunctionPrototypes() + METHOD pullDefinitions( acBuffer ) ENDCLASS @@ -193,6 +201,8 @@ METHOD IdeHarbourHelp:create( oIde ) DEFAULT oIde TO ::oIde ::oIde := oIde + ::cPathInstall := ::cWrkHarbour + RETURN Self /*----------------------------------------------------------------------*/ @@ -212,6 +222,8 @@ METHOD IdeHarbourHelp:show() ::populateRootInfo() ::refreshDocTree() + + ::oEM:updateCompleter() ENDIF RETURN Self @@ -487,6 +499,7 @@ METHOD IdeHarbourHelp:execEvent( nMode, p, p1 ) CASE "buttonRefresh_clicked" ::refreshDocTree() + ::oEM:updateCompleter() EXIT CASE "buttonPrint_clicked" @@ -756,155 +769,24 @@ METHOD IdeHarbourHelp:populateIndex() /*----------------------------------------------------------------------*/ -METHOD IdeHarbourHelp:getDocFunction( acBuffer ) - LOCAL a_, s, oFunc, nPart, lIsFunc +METHOD IdeHarbourHelp:pullDefinitions( acBuffer ) + LOCAL a_, s, nPart, oFunc + LOCAL lIsFunc := .f. + LOCAL aFn := {} IF hb_isArray( acBuffer ) a_:= acBuffer ELSE - a_:= hbide_memoTOarray( acBuffer ) + IF hb_fileExists( acBuffer ) + a_:= hbide_readSource( acBuffer ) + ELSE + a_:= hbide_memoTOarray( acBuffer ) + ENDIF ENDIF - oFunc := IdeDocFunction():new() - - lIsFunc := .f. - FOR EACH s IN a_ - - DO CASE - CASE "$DOC$" $ s - lIsFunc := .t. - CASE "$END$" $ s - EXIT - CASE "$TEMPLATE$" $ s - nPart := DOC_FUN_TEMPLATE - CASE "$FUNCNAME$" $ s .OR. "$NAME$" $ s - nPart := DOC_FUN_FUNCNAME - CASE "$CATEGORY$" $ s - nPart := DOC_FUN_CATEGORY - CASE "$SUBCATEGORY$" $ s - nPart := DOC_FUN_SUBCATEGORY - CASE "$ONELINER$" $ s - nPart := DOC_FUN_ONELINER - CASE "$SYNTAX$" $ s - nPart := DOC_FUN_SYNTAX - CASE "$ARGUMENTS$" $ s - nPart := DOC_FUN_ARGUMENTS - CASE "$RETURNS$" $ s - nPart := DOC_FUN_RETURNS - CASE "$DESCRIPTION$" $ s - nPart := DOC_FUN_DESCRIPTION - CASE "$EXAMPLES$" $ s - nPart := DOC_FUN_EXAMPLES - CASE "$TESTS$" $ s - nPart := DOC_FUN_TESTS - CASE "$FILES$" $ s - nPart := DOC_FUN_FILES - CASE "$STATUS$" $ s - nPart := DOC_FUN_STATUS - CASE "$PLATFORMS$" $ s .OR. "$COMPLIANCE$" $ s - nPart := DOC_FUN_PLATFORMS - CASE "$SEEALSO$" $ s - nPart := DOC_FUN_SEEALSO - CASE "$VERSION$" $ s - nPart := DOC_FUN_VERSION - CASE "$INHERITS" $ s - nPart := DOC_FUN_INHERITS - CASE "$METHODS" $ s - nPart := DOC_FUN_METHODS - CASE "$EXTERNALLINK" $ s - nPart := DOC_FUN_EXTERNALLINK - OTHERWISE - IF ! lIsFunc - LOOP // It is a fake line not within $DOC$ => $END$ block - ENDIF - s := substr( s, 9 ) - - SWITCH nPart - CASE DOC_FUN_BEGINS - EXIT - CASE DOC_FUN_TEMPLATE - oFunc:cTemplate := s - EXIT - CASE DOC_FUN_FUNCNAME - oFunc:cName := alltrim( s ) - EXIT - CASE DOC_FUN_CATEGORY - oFunc:cCategory := alltrim( s ) - EXIT - CASE DOC_FUN_SUBCATEGORY - oFunc:cSubCategory := alltrim( s ) - EXIT - CASE DOC_FUN_ONELINER - oFunc:cOneLiner := s - EXIT - CASE DOC_FUN_SYNTAX - aadd( oFunc:aSyntax , s ) - EXIT - CASE DOC_FUN_ARGUMENTS - aadd( oFunc:aArguments , s ) - EXIT - CASE DOC_FUN_RETURNS - aadd( oFunc:aReturns , s ) - EXIT - CASE DOC_FUN_DESCRIPTION - aadd( oFunc:aDescription, s ) - EXIT - CASE DOC_FUN_EXAMPLES - aadd( oFunc:aExamples , s ) - EXIT - CASE DOC_FUN_TESTS - aadd( oFunc:aTests , s ) - EXIT - CASE DOC_FUN_FILES - aadd( oFunc:aFiles , s ) - EXIT - CASE DOC_FUN_STATUS - oFunc:cStatus := alltrim( s ) - EXIT - CASE DOC_FUN_PLATFORMS - oFunc:cPlatForms := alltrim( s ) - EXIT - CASE DOC_FUN_SEEALSO - oFunc:cSeaAlso := alltrim( s ) - EXIT - CASE DOC_FUN_INHERITS - oFunc:cInherits := alltrim( s ) - EXIT - CASE DOC_FUN_METHODS - aadd( oFunc:aMethods , s ) - EXIT - CASE DOC_FUN_VERSION - oFunc:cVersion := alltrim( s ) - EXIT - CASE DOC_FUN_EXTERNALLINK - oFunc:cExternalLink := alltrim( s ) - EXIT - OTHERWISE - nPart := DOC_FUN_NONE - EXIT - ENDSWITCH - ENDCASE - NEXT - - IF ! lIsFunc - oFunc := NIL - ENDIF - RETURN oFunc - -/*----------------------------------------------------------------------*/ - -METHOD IdeHarbourHelp:parseTextFile( cTextFile, oParent ) - LOCAL a_, s, nPart, oFunc, oTWItem - LOCAL lIsFunc := .f. - LOCAL cIcon := hbide_image( "dc_function" ) - LOCAL aFn := {} - LOCAL nParsed := ascan( ::aFuncByFile, {|e_| e_[ 1 ] == cTextFile } ) - - IF nParsed == 0 + IF .t. nPart := DOC_FUN_NONE - a_:= hbide_readSource( cTextFile ) - FOR EACH s IN a_ DO CASE @@ -915,15 +797,7 @@ METHOD IdeHarbourHelp:parseTextFile( cTextFile, oParent ) CASE "$END$" $ s IF lIsFunc - lIsFunc := .f. - nPart := DOC_FUN_ENDS - oTWItem := QTreeWidgetItem():new() - oTWItem:setText( 0, oFunc:cName ) - oTWItem:setIcon( 0, cIcon ) - oTWItem:setTooltip( 0, oFunc:cName ) - oParent:addChild( oTWItem ) - aadd( ::aNodes, { oTWItem, "Function", oParent, cTextFile + "<::>" + oFunc:cName, oFunc:cName } ) - aadd( ::aFunctions, { cTextFile, oFunc:cName, oFunc, oTWItem, NIL, lower( oFunc:cName ) } ) + oFunc:lOk := .t. aadd( aFn, oFunc ) ENDIF @@ -1040,7 +914,29 @@ METHOD IdeHarbourHelp:parseTextFile( cTextFile, oParent ) ENDSWITCH ENDCASE NEXT + ENDIF + RETURN aFn + +/*----------------------------------------------------------------------*/ + +METHOD IdeHarbourHelp:parseTextFile( cTextFile, oParent ) + LOCAL aFn, oFunc, oTWItem + LOCAL cIcon := hbide_image( "dc_function" ) + LOCAL nParsed := ascan( ::aFuncByFile, {|e_| e_[ 1 ] == cTextFile } ) + + IF nParsed == 0 + IF !empty( aFn := ::pullDefinitions( cTextFile ) ) + FOR EACH oFunc IN aFn + oTWItem := QTreeWidgetItem():new() + oTWItem:setText( 0, oFunc:cName ) + oTWItem:setIcon( 0, cIcon ) + oTWItem:setTooltip( 0, oFunc:cName ) + oParent:addChild( oTWItem ) + aadd( ::aNodes, { oTWItem, "Function", oParent, cTextFile + "<::>" + oFunc:cName, oFunc:cName } ) + aadd( ::aFunctions, { cTextFile, oFunc:cName, oFunc, oTWItem, NIL, lower( oFunc:cName ) } ) + NEXT + ENDIF aadd( ::aFuncByFile, { cTextFile, aFn } ) ENDIF @@ -1048,6 +944,58 @@ METHOD IdeHarbourHelp:parseTextFile( cTextFile, oParent ) /*----------------------------------------------------------------------*/ +METHOD IdeHarbourHelp:getDocFunction( acBuffer ) + LOCAL aFn + + IF !empty( aFn := ::pullDefinitions( acBuffer ) ) + RETURN aFn[ 1 ] + ENDIF + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +METHOD IdeHarbourHelp:getFunctionPrototypes() + LOCAL a_, cFolder, aFN, oFunc, cNFolder + LOCAL aPaths := {} + LOCAL aDocs := {} + LOCAL aProto := {} + + IF !empty( ::cPathInstall ) + IF ! ::lLoadedProto + hbide_fetchSubPaths( @aPaths, ::cPathInstall, .t. ) + + FOR EACH cFolder IN aPaths + cNFolder := hbide_pathNormalized( cFolder, .t. ) + IF ( "/doc" $ cNFolder ) .OR. ( "/doc/en" $ cNFolder ) + aadd( aDocs, cFolder ) + ENDIF + NEXT + + FOR EACH cFolder IN aDocs + FOR EACH a_ IN directory( cFolder + "*.txt" ) + IF a_[ 5 ] != "D" + aFn := ::pullDefinitions( cFolder + a_[ 1 ] ) + FOR EACH oFunc IN aFn + IF hb_isObject( oFunc ) + IF !empty( oFunc:aSyntax ) + aadd( aProto, oFunc:aSyntax[ 1 ] ) //hbide_arrayToMemoEx( oFunc:aSyntax ) ) + ENDIF + ENDIF + NEXT + ENDIF + NEXT + NEXT + + ::aProtoTypes := aProto + ::lLoadedProto := .t. + ENDIF + ENDIF + + RETURN ::aProtoTypes + +/*----------------------------------------------------------------------*/ + METHOD IdeHarbourHelp:updateViewer( aHtm ) ::oUI:q_browserView:setHTML( hbide_arrayToMemo( aHtm ) )