From b659d0135d47d29fca4fdd927651d94419f23994 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Wed, 7 Jul 2010 01:36:09 +0000 Subject: [PATCH] 2010-07-06 18:29 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + contrib/hbide/editor.ui + Added: to be used a little while. * contrib/hbide/setup.ui + Added: 1. Completion List with Arguments ? 2. Complete Code including Arguments ? * contrib/hbide/hbide.hbp * contrib/hbide/idebrowse.prg * contrib/hbide/ideedit.prg * contrib/hbide/ideeditor.prg * contrib/hbide/idefunctions.prg * contrib/hbide/idesaveload.prg + Implemented: a better control over code completion feature. Now completion list can be presented with argument list intact, i.e., hbide_isValidSource( cSourceFile ) can be presented either as (default) hbide_isValidSource OR hbide_isValidSource( cSourceFile ) Similarily, code can also be completed including arguments list or without it. Please experiment. --- harbour/ChangeLog | 23 ++ harbour/contrib/hbide/editor.ui | 82 ++++++ harbour/contrib/hbide/hbide.hbp | 1 + harbour/contrib/hbide/idebrowse.prg | 13 + harbour/contrib/hbide/ideedit.prg | 20 +- harbour/contrib/hbide/ideeditor.prg | 12 +- harbour/contrib/hbide/idefunctions.prg | 34 +-- harbour/contrib/hbide/idesaveload.prg | 19 +- harbour/contrib/hbide/setup.ui | 393 +++++++++++++++++++++++++ 9 files changed, 573 insertions(+), 24 deletions(-) create mode 100644 harbour/contrib/hbide/editor.ui diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5b58209b70..ec32df9293 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,29 @@ The license applies to all entries newer than 2009-04-28. */ +2010-07-06 18:29 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + + contrib/hbide/editor.ui + + Added: to be used a little while. + + * contrib/hbide/setup.ui + + Added: + 1. Completion List with Arguments ? + 2. Complete Code including Arguments ? + + * contrib/hbide/hbide.hbp + * contrib/hbide/idebrowse.prg + * contrib/hbide/ideedit.prg + * contrib/hbide/ideeditor.prg + * contrib/hbide/idefunctions.prg + * contrib/hbide/idesaveload.prg + + Implemented: a better control over code completion feature. + Now completion list can be presented with argument list intact, + i.e., hbide_isValidSource( cSourceFile ) can be presented + either as (default) hbide_isValidSource OR + hbide_isValidSource( cSourceFile ) + Similarily, code can also be completed including arguments + list or without it. Please experiment. + 2010-07-07 01:46 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg + -autohbc now has natural defaults, header part will diff --git a/harbour/contrib/hbide/editor.ui b/harbour/contrib/hbide/editor.ui new file mode 100644 index 0000000000..45f20c78a3 --- /dev/null +++ b/harbour/contrib/hbide/editor.ui @@ -0,0 +1,82 @@ + + + Form + + + + 0 + 0 + 454 + 544 + + + + Editor + + + + + + + + + + + + Cancel + + + + + + + ... + + + + + + + ... + + + + + + + ... + + + + + + + ... + + + + + + + OK + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + diff --git a/harbour/contrib/hbide/hbide.hbp b/harbour/contrib/hbide/hbide.hbp index 4a1b8fbbd5..739ffd4c39 100644 --- a/harbour/contrib/hbide/hbide.hbp +++ b/harbour/contrib/hbide/hbide.hbp @@ -43,6 +43,7 @@ idebrowse.prg docviewgenerator.ui docwriter.ui +editor.ui environ.ui environments.ui finddialog.ui diff --git a/harbour/contrib/hbide/idebrowse.prg b/harbour/contrib/hbide/idebrowse.prg index e0f9a74733..6203d4bc8d 100644 --- a/harbour/contrib/hbide/idebrowse.prg +++ b/harbour/contrib/hbide/idebrowse.prg @@ -510,6 +510,19 @@ METHOD IdeBrowseManager:loadTables() FOR EACH cInfo IN ::oINI:aDbuPanelsInfo aPanel := hb_aTokens( cInfo, "," ) + + aSize( aPanel, TBL_VRBLS ) + + DEFAULT aPanel[ TBL_PANEL ] TO "" + DEFAULT aPanel[ TBL_NAME ] TO "" + DEFAULT aPanel[ TBL_ALIAS ] TO "" + DEFAULT aPanel[ TBL_DRIVER ] TO "" + DEFAULT aPanel[ TBL_INDEX ] TO 0 + DEFAULT aPanel[ TBL_RECORD ] TO 0 + DEFAULT aPanel[ TBL_CURSOR ] TO 0 + DEFAULT aPanel[ TBL_GEOMETRY ] TO "" + DEFAULT aPanel[ TBL_NEXT ] TO "" + IF ::isPanel( aPanel[ 1 ] ) IF hb_fileExists( cTable := hbide_pathToOSPath( aPanel[ 2 ] ) ) ::setPanel( aPanel[ 1 ] ) diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index 1d2f8ed724..2438e54dff 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -234,6 +234,7 @@ CLASS IdeEdit INHERIT IdeObject METHOD findEx( cText, nFlags, nStart ) METHOD highlightAll( cText ) METHOD unHighlight() + METHOD parseCodeCompletion( cSyntax ) ENDCLASS @@ -2196,6 +2197,23 @@ METHOD IdeEdit:hidePrototype() /*----------------------------------------------------------------------*/ +METHOD IdeEdit:parseCodeCompletion( cSyntax ) + LOCAL cText, n + + IF ::oINI:lCompleteArgumented + cText := trim( cSyntax ) + ELSE + IF ( n := at( "(", cSyntax ) ) > 0 + cText := trim( substr( cSyntax, 1, n - 1 ) ) + ELSE + cText := trim( cSyntax ) + ENDIF + ENDIF + + RETURN cText + +/*----------------------------------------------------------------------*/ + METHOD IdeEdit:completeCode( p ) LOCAL qCursor := QTextCursor():from( ::qEdit:textCursor() ) @@ -2203,7 +2221,7 @@ METHOD IdeEdit:completeCode( p ) qCursor:movePosition( QTextCursor_StartOfWord ) qCursor:movePosition( QTextCursor_EndOfWord, QTextCursor_KeepAnchor ) - qCursor:insertText( p ) + qCursor:insertText( ::parseCodeCompletion( p ) ) qCursor:movePosition( QTextCursor_Left ) qCursor:movePosition( QTextCursor_Right ) diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index d59705172e..afa5ba19e6 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -175,6 +175,7 @@ CLASS IdeEditsManager INHERIT IdeObject METHOD spaces2tabs() METHOD qscintilla() METHOD setStyleSheet( nMode ) + METHOD updateCompleter() ENDCLASS @@ -230,9 +231,18 @@ METHOD IdeEditsManager:create( oIde ) aadd( ::aActions, { "" , ::qContextSub:addSeparator() } ) aadd( ::aActions, { "Close Split" , ::qContextSub:addAction( "Close Split Window" ) } ) + /* Define code completer */ ::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() ::qCompModel:setStringList( ::qProtoList ) ::qCompleter:setModel( ::qCompModel ) @@ -241,7 +251,7 @@ METHOD IdeEditsManager:create( oIde ) ::qCompleter:setCompletionMode( QCompleter_PopupCompletion ) ::qCompleter:setWrapAround( .f. ) - ::connect( ::qCompleter, "activated(QString)", {|p| ::execEvent( qcompleter_activated, p ) } ) + QListView():from( ::qCompleter:popup() ):setAlternatingRowColors( .t. ) RETURN Self diff --git a/harbour/contrib/hbide/idefunctions.prg b/harbour/contrib/hbide/idefunctions.prg index 942bf3493c..d7649317f0 100644 --- a/harbour/contrib/hbide/idefunctions.prg +++ b/harbour/contrib/hbide/idefunctions.prg @@ -592,6 +592,7 @@ METHOD IdeFunctions:consolidateList() METHOD IdeFunctions:populateTable() LOCAL oTbl, qItm, a_, n, s, k_:={} + LOCAL qApp := QApplication():new() ::clear( .t. ) ::buildHeader() @@ -608,39 +609,36 @@ METHOD IdeFunctions:populateTable() oTbl:setItem( n, 0, qItm ) oTbl:setRowHeight( n, 16 ) - QApplication():new():processEvents() + qApp:processEvents() aadd( ::aItems, qItm ) n++ ::oUI:q_labelEntries:setText( "Entries: " + hb_ntos( n ) ) NEXT - ::qProtoList:clear() - FOR EACH a_ IN ::aList s := a_[ 2 ] - IF ( n := at( "(", s ) ) == 0 - IF ( n := at( " ", s ) ) > 0 - aadd( k_, substr( s, 1, n - 1 ) ) - ELSE - aadd( k_, trim( s ) ) - ENDIF + IF ::oINI:lCompletionWithArgs + aadd( k_, trim( s ) ) ELSE - aadd( k_, substr( s, 1, n - 1 ) ) + 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 ) } ) - ::qCompModel:setStringList( ::qProtoList ) - ::qCompleter:setModel( ::qCompModel ) - ::qCompleter:setModelSorting( QCompleter_CaseInsensitivelySortedModel ) - ::qCompleter:setCaseSensitivity( Qt_CaseInsensitive ) - ::qCompleter:setCompletionMode( QCompleter_PopupCompletion ) - ::qCompleter:setWrapAround( .f. ) - - QListView():from( ::qCompleter:popup() ):setAlternatingRowColors( .t. ) + ::oEM:updateCompleter() RETURN Self diff --git a/harbour/contrib/hbide/idesaveload.prg b/harbour/contrib/hbide/idesaveload.prg index e848086b9f..7e9d2b1ef9 100644 --- a/harbour/contrib/hbide/idesaveload.prg +++ b/harbour/contrib/hbide/idesaveload.prg @@ -162,6 +162,9 @@ CLASS IdeINI INHERIT IdeObject DATA cBkpPath INIT "" DATA cBkpSuffix INIT ".bkp" + DATA lCompletionWithArgs INIT .f. + DATA lCompleteArgumented INIT .f. + METHOD new( oIde ) METHOD create( oIde ) METHOD load( cHbideIni ) @@ -248,6 +251,8 @@ METHOD IdeINI:save( cHbideIni ) aadd( txt_, "TmpBkpPrd" + "=" + hb_ntos( ::nTmpBkpPrd ) ) aadd( txt_, "BkpPath" + "=" + ::cBkpPath ) aadd( txt_, "BkpSuffix" + "=" + ::cBkpSuffix ) + aadd( txt_, "CodeListWithArgs" + "=" + iif( ::lCompletionWithArgs , "YES", "NO" ) ) + aadd( txt_, "CompletionWithArgs" + "=" + iif( ::lCompleteArgumented , "YES", "NO" ) ) aadd( txt_, "[PROJECTS]" ) aadd( txt_, " " ) @@ -504,6 +509,8 @@ METHOD IdeINI:load( cHbideIni ) CASE "TmpBkpPrd" ; ::oINI:nTmpBkpPrd := val( cVal ) ; EXIT CASE "BkpPath" ; ::oINI:cBkpPath := cVal ; EXIT CASE "BkpSuffix" ; ::oINI:cBkpSuffix := cVal ; EXIT + CASE "CodeListWithArgs" ; ::oINI:lCompletionWithArgs := cVal != "NO" ; EXIT + CASE "CompletionWithArgs" ; ::oINI:lCompleteArgumented := cVal != "NO" ; EXIT ENDSWITCH ENDIF @@ -795,7 +802,7 @@ CLASS IdeSetup INHERIT IdeObject DATA oINI DATA qOrgPalette DATA aItems INIT {} - DATA aTree INIT { "General", "Selections", "Font", "Paths", "Variables", "Dictionaries" } + DATA aTree INIT { "General", "Selections", "Font", "Paths", "Variables", "Dictionaries", "Themes" } DATA aStyles INIT { "cleanlooks", "windows", "windowsxp", ; "windowsvista", "cde", "motif", "plastique", "macintosh" } DATA aKeyItems INIT {} @@ -968,6 +975,8 @@ METHOD IdeSetup:retrieve() ::oINI:nTmpBkpPrd := val( ::oUI:q_editTmpBkpPrd : text() ) ::oINI:cBkpPath := ::oUI:q_editBkpPath : text() ::oINI:cBkpSuffix := ::oUI:q_editBkpSuffix : text() + ::oINI:lCompletionWithArgs := ::oUI:q_checkListlWithArgs : isChecked() + ::oINI:lCompleteArgumented := ::oUI:q_checkCmplInclArgs : isChecked() RETURN Self @@ -1017,9 +1026,11 @@ METHOD IdeSetup:populate() ::oUI:q_listTextExt:setSortingEnabled( .t. ) ::oUI:q_listTextExt:sortItems() - ::oUI:q_editTmpBkpPrd : setText( hb_ntos( ::oINI:nTmpBkpPrd ) ) - ::oUI:q_editBkpPath : setText( ::oINI:cBkpPath ) - ::oUI:q_editBkpSuffix : setText( ::oINI:cBkpSuffix ) + ::oUI:q_editTmpBkpPrd : setText( hb_ntos( ::oINI:nTmpBkpPrd ) ) + ::oUI:q_editBkpPath : setText( ::oINI:cBkpPath ) + ::oUI:q_editBkpSuffix : setText( ::oINI:cBkpSuffix ) + ::oUI:q_checkListlWithArgs : setChecked( ::oINI:lCompletionWithArgs ) + ::oUI:q_checkCmplInclArgs : setChecked( ::oINI:lCompleteArgumented ) ::connectSlots() RETURN Self diff --git a/harbour/contrib/hbide/setup.ui b/harbour/contrib/hbide/setup.ui index 3a9fa1900b..efff41225c 100644 --- a/harbour/contrib/hbide/setup.ui +++ b/harbour/contrib/hbide/setup.ui @@ -576,6 +576,45 @@ + + + + 10 + 158 + 331 + 71 + + + + Code Completion + + + + + 12 + 20 + 307 + 19 + + + + Show code completion list with arguments ? + + + + + + 12 + 42 + 307 + 19 + + + + Complete the code including arguments body ? + + + @@ -1578,6 +1617,360 @@ + + + + + 0 + 0 + 351 + 365 + + + + + + + + + 10 + 8 + 99 + 135 + + + + + + + 118 + 8 + 65 + 135 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 193 + 9 + 149 + 133 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + 12 + 174 + 49 + 20 + + + + + + + 12 + 152 + 53 + 16 + + + + Sections + + + + + + 12 + 202 + 49 + 20 + + + + + + + 12 + 230 + 49 + 20 + + + + + + + 12 + 258 + 49 + 20 + + + + + + + 12 + 286 + 49 + 20 + + + + + + + 118 + 176 + 65 + 16 + + + + Qt::Horizontal + + + + + + 196 + 176 + 65 + 16 + + + + Qt::Horizontal + + + + + + 274 + 176 + 65 + 16 + + + + Qt::Horizontal + + + + + + 118 + 204 + 65 + 16 + + + + Qt::Horizontal + + + + + + 196 + 204 + 65 + 16 + + + + Qt::Horizontal + + + + + + 274 + 204 + 65 + 16 + + + + Qt::Horizontal + + + + + + 118 + 232 + 65 + 16 + + + + Qt::Horizontal + + + + + + 196 + 232 + 65 + 16 + + + + Qt::Horizontal + + + + + + 274 + 232 + 65 + 16 + + + + Qt::Horizontal + + + + + + 118 + 260 + 65 + 16 + + + + Qt::Horizontal + + + + + + 196 + 260 + 65 + 16 + + + + Qt::Horizontal + + + + + + 274 + 260 + 65 + 16 + + + + Qt::Horizontal + + + + + + 118 + 288 + 65 + 16 + + + + Qt::Horizontal + + + + + + 196 + 288 + 65 + 16 + + + + Qt::Horizontal + + + + + + 274 + 288 + 65 + 16 + + + + Qt::Horizontal + + + + + + 144 + 156 + 27 + 16 + + + + Red + + + + + + 216 + 156 + 37 + 16 + + + + Green + + + + + + 298 + 156 + 31 + 16 + + + + Blue + + + +