From ff53c0f49bcdc94c5c1e47852d76e85f77472e41 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Fri, 30 Jul 2010 01:50:14 +0000 Subject: [PATCH] 2010-07-29 18:47 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/doc/en/class_hbqplaintextedit.txt * contrib/hbqt/hbqt_hbqplaintextedit.cpp * contrib/hbqt/hbqt_hbqplaintextedit.h * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp * contrib/hbqt/qtgui/THBQPlainTextEdit.prg * contrib/hbqt/qth/HBQPlainTextEdit.qth + Added: methods to control code completions and completion tips. + contrib/hbide/resources/help1.png + contrib/hbide/resources/infotips.png * contrib/hbide/hbide.qrc + Added: two more images foe code completions and completion tips. * contrib/hbide/idedocks.prg * contrib/hbide/ideedit.prg * contrib/hbide/ideeditor.prg + Added: controls to toggle code completions and completion tips. The settings are not saved for the next run and are applicable per editing instance. --- harbour/ChangeLog | 22 ++++++++ harbour/contrib/hbide/hbide.qrc | 2 + harbour/contrib/hbide/idedocks.prg | 7 ++- harbour/contrib/hbide/ideedit.prg | 27 +++++++--- harbour/contrib/hbide/ideeditor.prg | 22 ++++++++ harbour/contrib/hbide/resources/help1.png | Bin 0 -> 910 bytes harbour/contrib/hbide/resources/infotips.png | Bin 0 -> 899 bytes .../hbqt/doc/en/class_hbqplaintextedit.txt | 2 + .../contrib/hbqt/hbqt_hbqplaintextedit.cpp | 50 ++++++++++++------ harbour/contrib/hbqt/hbqt_hbqplaintextedit.h | 4 ++ .../contrib/hbqt/qtgui/HBQPlainTextEdit.cpp | 28 ++++++++++ .../contrib/hbqt/qtgui/THBQPlainTextEdit.prg | 10 ++++ harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth | 2 + 13 files changed, 149 insertions(+), 27 deletions(-) create mode 100644 harbour/contrib/hbide/resources/help1.png create mode 100644 harbour/contrib/hbide/resources/infotips.png diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3b521bc94e..4fc0248591 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,28 @@ The license applies to all entries newer than 2009-04-28. */ +2010-07-29 18:47 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/doc/en/class_hbqplaintextedit.txt + * contrib/hbqt/hbqt_hbqplaintextedit.cpp + * contrib/hbqt/hbqt_hbqplaintextedit.h + * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp + * contrib/hbqt/qtgui/THBQPlainTextEdit.prg + * contrib/hbqt/qth/HBQPlainTextEdit.qth + + Added: methods to control code completions and completion tips. + + + contrib/hbide/resources/help1.png + + contrib/hbide/resources/infotips.png + + * contrib/hbide/hbide.qrc + + Added: two more images foe code completions and completion tips. + + * contrib/hbide/idedocks.prg + * contrib/hbide/ideedit.prg + * contrib/hbide/ideeditor.prg + + Added: controls to toggle code completions and completion tips. + The settings are not saved for the next run and are applicable + per editing instance. + 2010-07-29 15:49 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/hbide.prg ! Minor. diff --git a/harbour/contrib/hbide/hbide.qrc b/harbour/contrib/hbide/hbide.qrc index 9115d74c80..dc739c37da 100644 --- a/harbour/contrib/hbide/hbide.qrc +++ b/harbour/contrib/hbide/hbide.qrc @@ -102,12 +102,14 @@ resources/hbidesplash.png resources/hbidesplashwatermark.png resources/help.png +resources/help1.png resources/helpdoc.png resources/hilight-all.png resources/horzruler.png resources/idepreferences.png resources/increaseindent.png resources/info.png +resources/infotips.png resources/insert-datetime.png resources/insert-external-file.png resources/insert-procname.png diff --git a/harbour/contrib/hbide/idedocks.prg b/harbour/contrib/hbide/idedocks.prg index 8366012e89..5e9cb53d4b 100644 --- a/harbour/contrib/hbide/idedocks.prg +++ b/harbour/contrib/hbide/idedocks.prg @@ -743,13 +743,12 @@ METHOD IdeDocks:buildToolBarPanels() aadd( aBtns, { "deleteline" , "Delete Current Line" , {|| ::oEM:deleteLine() } } ) aadd( aBtns, { "duplicateline" , "Duplicate Current Line" , {|| ::oEM:duplicateLine() } } ) aadd( aBtns, {} ) - #if 0 - aadd( aBtns, { "togglelinenumber", "Toggle Line Numbers" , {|| ::oEM:toggleLineNumbers() } } ) - aadd( aBtns, { "curlinehilight" , "Toggle Current Line Hilight", {|| ::oEM:toggleCurrentLineHighlightMode() } } ) - #endif aadd( aBtns, { "togglelinenumber", "Toggle Line Numbers" , {|| ::oEM:toggleLineNumbers() } } ) aadd( aBtns, { "horzruler" , "Toggle Horizontal Ruler" , {|| ::oEM:toggleHorzRuler() } } ) aadd( aBtns, { "curlinehilight" , "Toggle Current Line Hilight", {|| ::oEM:toggleCurrentLineHighlightMode() } } ) + aadd( aBtns, {} ) + aadd( aBtns, { "help1" , "Toggle Code Completion" , {|| ::oEM:toggleCodeCompetion() } } ) + aadd( aBtns, { "infotips" , "Toggle Completion Tips" , {|| ::oEM:toggleCompetionTips() } } ) FOR EACH a_ IN aBtns IF empty( a_ ) ::qTBarLines:addSeparator() diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index a95ea74030..c9d9bafd05 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -184,6 +184,8 @@ CLASS IdeEdit INHERIT IdeObject METHOD toggleLineSelectionMode() METHOD clearSelection() METHOD togglePersistentSelection() + METHOD toggleCodeCompetion() + METHOD toggleCompetionTips() METHOD getWord( lSelect ) METHOD getLine( nLine, lSelect ) @@ -1387,6 +1389,18 @@ METHOD IdeEdit:togglePersistentSelection() /*----------------------------------------------------------------------*/ +METHOD IdeEdit:toggleCodeCompetion() + ::qEdit:hbToggleCodeCompetion() + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:toggleCompetionTips() + ::qEdit:hbToggleCompetionTips() + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeEdit:redo() ::qEdit:redo() RETURN Self @@ -1529,7 +1543,7 @@ METHOD IdeEdit:find( cText, nPosFrom ) /* nFlags will decide the position, case sensitivity and direction */ METHOD IdeEdit:findEx( cText, nFlags, nStart ) - LOCAL qCursor, lFound, cT, nPos + LOCAL qCursor, lFound, nPos DEFAULT nStart TO 0 @@ -1546,12 +1560,11 @@ METHOD IdeEdit:findEx( cText, nFlags, nStart ) IF ( lFound := ::qEdit:find( cText, nFlags ) ) ::qEdit:centerCursor() - qCursor := ::getCursor() - cT := qCursor:selectedText() - //qCursor:clearSelection() - ::qEdit:hbSetSelectionInfo( { qCursor:blockNumber(), qCursor:columnNumber() - len( cT ), ; - qCursor:blockNumber(), qCursor:columnNumber(), 1 } ) - //::qEdit:setTextCursor( qCursor ) + qCursor := QTextCursor():from( ::qEdit:textCursor() ) //::getCursor() + + ::qEdit:hbSetSelectionInfo( { qCursor:blockNumber(), qCursor:columnNumber() - len( cText ), ; + qCursor:blockNumber(), qCursor:columnNumber(), 1, .t., .f. } ) + qCursor:clearSelection() ELSE qCursor:setPosition( nPos ) ::qEdit:setTextCursor( qCursor ) diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index f67bd70375..1fdc0a5d2e 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -145,6 +145,8 @@ CLASS IdeEditsManager INHERIT IdeObject METHOD toggleLineNumbers() METHOD toggleHorzRuler() METHOD toggleCurrentLineHighlightMode() + METHOD toggleCodeCompetion() + METHOD toggleCompetionTips() METHOD getText() METHOD getWord( lSelect ) @@ -747,6 +749,26 @@ METHOD IdeEditsManager:toggleHorzRuler() /*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:toggleCodeCompetion() + LOCAL oEdit + ::oIde:lHorzRulerVisible := ! ::lHorzRulerVisible + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:toggleCodeCompetion() + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEditsManager:toggleCompetionTips() + LOCAL oEdit + ::oIde:lHorzRulerVisible := ! ::lHorzRulerVisible + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:toggleCompetionTips() + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeEditsManager:duplicateLine() LOCAL oEdit IF !empty( oEdit := ::getEditObjectCurrent() ) diff --git a/harbour/contrib/hbide/resources/help1.png b/harbour/contrib/hbide/resources/help1.png new file mode 100644 index 0000000000000000000000000000000000000000..0b334e64b4e1e21d75c1cf6ef54f15cd309c8a99 GIT binary patch literal 910 zcmV;919AL`P)DZyIWIIXFf@5y zqtyTa0^dnQK~#90rITG~TV)u>fA2XbIZ2wOO=2ryT~=ouwN}}{i&~4yL^|kPK@hep z!5hWFE~a#d=yYyO5N`wp5jOBf=wv8Uk#<-nbz`WbYxmV*m!{d$+9bAVl9QZ|_q<*V z0?z4;&*j6PAOGj$FO*XJpEB;%6hesOk1^QR&NGDAvMQNhl6?EtxSIZl_HGAX4~lK+ z$2Ytif2e;X66-)z^AxjlWES%E#R}h4lzwpZdvEccfbm`8#jV4;PNe&XTf9GhBX{Kj zREnhHt;o8~%(X>kOY(Zb(TCn1zXNFkPVNvr+lL1(cJF*Cygczf=P%x(rRxcNGl5)~ zqBm5=G-F)ORk^h4Pw1My`@j!g!vIJKAx^&%JCy1h3_Cx*!Q9O{-FrUf(aj2~Wfp_` zshu9hTDU|<$RHk2&t>ZVZeUCU811Gn+4b;9Aa{nwa)sW35kjeLl)gJe_QX5fKKCV? zcD{}+@9aHp>KH=33ZMaWKERNH7j_C6q=IPW23t1YPboRXncD&4Jx}A5vPeLLB18f~ z3>a*lQ4jHmRxM&{9#VooKg;?@+xexG=7pnQVXkMH8~Xqij1i2)(5ez&5oiJ&uxe{- zL_!|Y6}Up-H7uUmdk`%%#q}>f#EzOo+EbXif#rhjGv6E`S7y>Rf&|PqT+vG12~u`7 zX3kGA|I;bFs7a(_6Rm9tr00{jY?NZG>ELFWv$<90Mlu-LYPKc7wJ~ZndIz3IUrJM- zIYl&?La#Nrwo;~0cb9a@XH5skr&ZziqV>t_auo;=OKzmStB3nazp_CVNwjZ7vmCBu z^GvV&iRa2=N2XNvZ;!OMPiXxQhCc6%MPKeobr6ro5x$G#NmeTjuI5+B6xXm__tV3Z zYTv(R;n+~{&6bGyS|S|oG!27w+oe>kVKwZ_p64Gva#o%E&oBYJ_iP~TYhnjVJt>rL kA^l0$;pe00RN-#zUkmq4?ZH6p5dZ)H07*qoM6N<$g0-Zey8r+H literal 0 HcmV?d00001 diff --git a/harbour/contrib/hbide/resources/infotips.png b/harbour/contrib/hbide/resources/infotips.png new file mode 100644 index 0000000000000000000000000000000000000000..d80abf6138c800beb41cf0aca22cc3134d23ff94 GIT binary patch literal 899 zcmV-}1AP36P)DZyIWIIXFf@5y zqtyTa0@O)FK~#90rITHVRAm^)fA4$FnKNh4&NLHFe(WM@8LN#ND7Mi`YqG3ZXdp$f z&_xhLT}w%3qN#{i_8|yGH$jwF(&h(7tAsZ}s|$k5w#)90w4?3r%+8#d^Ev0dT?8vG z+D*^p!~gm5zj%H^DaHR8{ZY$zg%Fp!Kj=}N9laUTSeN&j69vC9c;V;Mx0Ytb(gt09 z2cBQo^TLr$Pj~KH`DBK_Lyd`2new0Go-sFj!AO!1FaL0;^hm(gfs=3Sdad`{ZQG0X z?|zy)_v?gClNE-B?lzeo9!8X=NA)1+zjFR?=^?=8S3mCBv48jQi@STQPwse3%{kaX z1KoGAnl;wwisib7Gd7C&Yvw8`ZSODN9rPu@9wEf)%^N-~ZrNxZ7_Kl?X_C=mbOHVG zJRcSFH2i?M`8l*~2CQ^n((v{INPwGNZxz=+yLR8j1*lZ(*NLUCh%AX8RpzD};?V@3f-N?Z_m- ztX4Vv`UXaPjn6OMq!0)H-q->JIXBSFp1y62hzxS&Dx@Y+ zGiBnsQ`Sh%EdnlGJu@q-)vwH{Nm5CISk=MVy9wWv6Hbi>RLyo$Nr)I9r!`qZgsqdm z4j!L=$c6Cs*q6GdZ!zMLcl5Pu7@bdm+s};N=lzIt;i%N#17v31Ua$ NIL :hbSelectAll() -> NIL :hbSetFieldsListActive( lActive ) -> NIL + :hbToggleCodeCompetion() -> NIL + :hbToggleCompetionTips() -> NIL $DESCRIPTION$ diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index 3668e60ee3..dce4a8a26e 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -122,6 +122,8 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent isSelectionPersistent = false; isShiftPressed = false; isAliasCompleter = false; + isCodeCompletionActive = true; + isCompletionTipsActive = true; #if 0 QTextFrameFormat format( this->document()->rootFrame()->frameFormat() ); @@ -178,6 +180,12 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent void HBQPlainTextEdit::hbShowPrototype( const QString & tip, int rows, int cols ) { + if( ! isCompletionTipsActive ){ + ttTextEdit->hide(); + ttLabel->hide(); + return; + } + if( rows <= 1 ) { ttLabel->setText( tip ); @@ -464,9 +472,23 @@ void HBQPlainTextEdit::hbSetSelectionInfo( PHB_ITEM selectionInfo ) columnEnds = hb_arrayGetNI( selectionInfo, 4 ); selectionMode = hb_arrayGetNI( selectionInfo, 5 ); - emit selectionChanged(); - - update(); + PHB_ITEM pSome = hb_arrayGetItemPtr( selectionInfo, 6 ); + if( hb_itemType( pSome ) & HB_IT_LOGICAL ){ + if( hb_itemGetL( pSome ) ){ + QTextCursor c( textCursor() ); + c.clearSelection(); + } + } + pSome = hb_arrayGetItemPtr( selectionInfo, 7 ); + if( hb_itemType( pSome ) & HB_IT_LOGICAL ){ + if( hb_itemGetL( pSome ) ){ + emit selectionChanged(); + } + } + else { + emit selectionChanged(); + } + repaint(); } /*----------------------------------------------------------------------*/ @@ -771,6 +793,8 @@ void HBQPlainTextEdit::mouseDoubleClickEvent( QMouseEvent *event ) columnEnds = c.columnNumber(); columnBegins = columnEnds - ( c.selectionEnd() - c.selectionStart() ); selectionMode = selectionMode_stream; + c.clearSelection(); + setTextCursor( c ); emit selectionChanged(); repaint(); } @@ -1371,6 +1395,13 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) } QPlainTextEdit::keyPressEvent( event ); + if( ! isCodeCompletionActive ){ + if( c ){ + c->popup()->hide(); + } + return; + } + if( ! c ){ return; } @@ -1402,10 +1433,6 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) eow.contains( event->text().right( 1 ) ) ) { c->popup()->hide(); - #if 0 - if( isAliasCompleter ) - hbRefreshCompleter( "" ); - #endif return; } @@ -1421,15 +1448,6 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) cr.setBottom( cr.bottom() + horzRulerHeight + 5 ); c->complete( cr ); // pop it up! - if( c->popup()->isHidden() && isAliasCompleter ){ - #if 0 - if( block ){ - PHB_ITEM p1 = hb_itemPutNI( NULL, 21041 ); - hb_vmEvalBlockV( block, 1, p1 ); - hb_itemRelease( p1 ); - } - #endif - } } /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h index a10403849b..62f516ae00 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h @@ -161,6 +161,8 @@ private: bool isSelectionPersistent; bool isShiftPressed; bool isAliasCompleter; + bool isCodeCompletionActive; + bool isCompletionTipsActive; protected: bool event( QEvent * event ); @@ -220,6 +222,8 @@ public slots: void hbSelectAll(); void hbSetFieldsListActive( bool active ) { isAliasCompleter = active; }; void hbRefreshCompleter( const QString & alias = "" ); + void hbToggleCodeCompetion() { isCodeCompletionActive = ! isCodeCompletionActive; }; + void hbToggleCompetionTips() { isCompletionTipsActive = ! isCompletionTipsActive; }; private slots: void hbSlotCursorPositionChanged(); diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp index 27454d68fb..6965d422f4 100644 --- a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp +++ b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp @@ -918,6 +918,34 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETFIELDSLISTACTIVE ) } } +/* + * void hbToggleCodeCompetion() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HBTOGGLECODECOMPETION ) +{ + HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 ); + if( p ) + ( p )->hbToggleCodeCompetion(); + else + { + HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBTOGGLECODECOMPETION FP=( p )->hbToggleCodeCompetion(); p is NULL" ) ); + } +} + +/* + * void hbToggleCompetionTips() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HBTOGGLECOMPETIONTIPS ) +{ + HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 ); + if( p ) + ( p )->hbToggleCompetionTips(); + else + { + HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBTOGGLECOMPETIONTIPS FP=( p )->hbToggleCompetionTips(); p is NULL" ) ); + } +} + /*----------------------------------------------------------------------*/ #endif /* #if QT_VERSION >= 0x040500 */ diff --git a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg index 24c1feb8e9..2bd684ddc4 100644 --- a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg +++ b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg @@ -121,6 +121,8 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit METHOD hbSetProtoStyle( cCss ) METHOD hbSelectAll() METHOD hbSetFieldsListActive( lActive ) + METHOD hbToggleCodeCompetion() + METHOD hbToggleCompetionTips() ENDCLASS @@ -349,3 +351,11 @@ METHOD HBQPlainTextEdit:hbSelectAll() METHOD HBQPlainTextEdit:hbSetFieldsListActive( lActive ) RETURN Qt_HBQPlainTextEdit_hbSetFieldsListActive( ::pPtr, lActive ) + +METHOD HBQPlainTextEdit:hbToggleCodeCompetion() + RETURN Qt_HBQPlainTextEdit_hbToggleCodeCompetion( ::pPtr ) + + +METHOD HBQPlainTextEdit:hbToggleCompetionTips() + RETURN Qt_HBQPlainTextEdit_hbToggleCompetionTips( ::pPtr ) + diff --git a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth index e60347060c..056196a0dc 100644 --- a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth +++ b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth @@ -152,6 +152,8 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT ) void hbSetProtoStyle( const QString & css ) void hbSelectAll() void hbSetFieldsListActive( bool active ) + void hbToggleCodeCompetion() + void hbToggleCompetionTips()