From e1bbbb990e79b513cc3be0e1bdbe42ec9dfd1b76 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Tue, 29 Dec 2009 08:47:49 +0000 Subject: [PATCH] 2009-12-29 00:41 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/qtgui/QTextCursor.cpp * contrib/hbqt/qtgui/TQTextCursor.prg * contrib/hbqt/qth/QTextCursor.qth ! Enabled :block() commented out method. * contrib/hbide/hbide.prg * contrib/hbide/idedocks.prg * contrib/hbide/idemisc.prg + Implemented double-click on any error/warning compiler output. This opens or brings forward source file and cursor stays at the offending source line. --- harbour/ChangeLog | 13 +++++++ harbour/contrib/hbide/hbide.prg | 10 ++--- harbour/contrib/hbide/idedocks.prg | 26 +++++++++++-- harbour/contrib/hbide/idemisc.prg | 41 +++++++++++++-------- harbour/contrib/hbqt/qtgui/QTextCursor.cpp | 21 ++++++++--- harbour/contrib/hbqt/qtgui/TQTextCursor.prg | 20 +++++++++- harbour/contrib/hbqt/qth/QTextCursor.qth | 3 +- 7 files changed, 100 insertions(+), 34 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2a8e9f8164..8ed2cbf9a4 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,19 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-29 00:41 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbqt/qtgui/QTextCursor.cpp + * contrib/hbqt/qtgui/TQTextCursor.prg + * contrib/hbqt/qth/QTextCursor.qth + ! Enabled :block() commented out method. + + * contrib/hbide/hbide.prg + * contrib/hbide/idedocks.prg + * contrib/hbide/idemisc.prg + + Implemented double-click on any error/warning compiler output. + This opens or brings forward source file and cursor stays at the + offending source line. + 2009-12-28 18:54 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbide/idedocks.prg + Added skeleton to process double-click on compile output. diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index 96f6239b1a..6de0020a6e 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -634,10 +634,6 @@ METHOD HbIde:getCurCursor() METHOD HbIde:editSource( cSourceFile, nPos, nHPos, nVPos, lPPO ) LOCAL n - #if 0 - LOCAL oTab, qEdit, qHiliter, qLayout, qDocument, qHScr, qVScr - LOCAL lFirst := .t. - #endif IF !Empty( cSourceFile ) .AND. !( IsValidText( cSourceFile ) ) RETURN Self @@ -653,7 +649,7 @@ METHOD HbIde:editSource( cSourceFile, nPos, nHPos, nVPos, lPPO ) IF Empty( cSourceFile ) n := 0 ELSE - n := aScan( ::aTabs, {|a| a[ TAB_SOURCEFILE ] == cSourceFile }) + n := aScan( ::aTabs, {|a_| PathNormalized( a_[ TAB_SOURCEFILE ] ) == PathNormalized( cSourceFile ) } ) End IF n > 0 @@ -661,7 +657,6 @@ METHOD HbIde:editSource( cSourceFile, nPos, nHPos, nVPos, lPPO ) IF lPPO ::aTabs[ n, TAB_QEDIT ]:setPlainText( hb_memoRead( cSourceFile ) ) END - RETURN Self END @@ -1732,7 +1727,8 @@ METHOD HbIde:buildProject( cProject, lLaunch, lRebuild, lPPO ) End End - ::oOutputResult:oWidget:setHtml( ConvertBuildStatusMsgToHtml( cTmp ) ) + //::oOutputResult:oWidget:setHtml( ConvertBuildStatusMsgToHtml( cTmp ) ) + ConvertBuildStatusMsgToHtml( cTmp, ::oOutputResult:oWidget ) IF lDelHbp FErase( cHbpPath ) diff --git a/harbour/contrib/hbide/idedocks.prg b/harbour/contrib/hbide/idedocks.prg index 3f719fac35..405ba42f3b 100644 --- a/harbour/contrib/hbide/idedocks.prg +++ b/harbour/contrib/hbide/idedocks.prg @@ -350,18 +350,38 @@ METHOD IdeDocks:buildOutputResults() /*----------------------------------------------------------------------*/ METHOD IdeDocks:outputDoubleClicked( lSelected ) - LOCAL qCursor + LOCAL qCursor, cText, n, cSource, nLine, cLine IF lSelected ::nPass++ IF ::nPass == 1 qCursor := QTextCursor():configure( ::oOutputResult:oWidget:textCursor() ) - HB_TRACE( HB_TR_ALWAYS, "METHOD IdeDocks:outputDoubleClicked()", lSelected, qCursor:blockNumber() ) + cText := QTextBlock():configure( qCursor:block() ):text() + IF ( n := at( "Error", cText ) ) > 0 + cLine := alltrim( substr( cText, 1, n - 1 ) ) + ELSEIF ( n := at( "Warning", cText ) ) > 0 + cLine := alltrim( substr( cText, 1, n - 1 ) ) + ENDIF + IF !empty( cLine ) + IF ( n := at( "(", cLine ) ) > 0 + cSource := alltrim( substr( cLine, 1, n - 1 ) ) + cLine := substr( cLine, n + 1 ) + n := at( ")", cLine ) + nLine := val( substr( cLine, 1, n - 1 ) ) + ::oIde:editSource( cSource ) + qCursor := QTextCursor():configure( ::oIde:qCurEdit:textCursor() ) + qCursor:setPosition( 0 ) + qCursor:movePosition( QTextCursor_Down, QTextCursor_MoveAnchor, nLine ) + ::oIde:qCurEdit:setTextCursor( qCursor ) + ELSE + nLine := 0 + ENDIF + ENDIF ENDIF IF ::nPass >= 2 ::nPass := 0 ENDIF ENDIF - RETURN Self + RETURN nLine /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index 675751dab8..cbb2e70971 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -473,15 +473,17 @@ FUNCTION PathNormalized( cPath, lLower ) * * 28/12/2009 - 16:17:37 */ -FUNCTION ConvertBuildStatusMsgToHtml( cText ) +FUNCTION ConvertBuildStatusMsgToHtml( cText, oWidget ) LOCAL aLines LOCAL cLine LOCAL aRegWarns := {} LOCAL aRegErrors := {} - cText := StrTran( cText, Chr(13)+Chr(10), Chr(10) ) - cText := StrTran( cText, Chr(13), Chr(10) ) - cText := StrTran( cText, Chr(10)+Chr(10), Chr(10) ) + oWidget:clear() + + cText := StrTran( cText, Chr( 13 ) + Chr( 10 ), Chr( 10 ) ) + cText := StrTran( cText, Chr( 13 ) , Chr( 10 ) ) + cText := StrTran( cText, Chr( 10 ) + Chr( 10 ), Chr( 10 ) ) /* Convert some chars to valid HTML chars */ DO WHILE "<" $ cText @@ -492,28 +494,35 @@ FUNCTION ConvertBuildStatusMsgToHtml( cText ) cText := StrTran( cText, ">", ">" ) ENDDO - aLines := hb_aTokens( cText, Chr(10) ) + aLines := hb_aTokens( cText, Chr( 10 ) ) + cText := '
'
+   oWidget:insertHTML( cText )
 
    AAdd( aRegWarns, hb_RegexComp( ".*: warning.*" ) )
    AAdd( aRegWarns, hb_RegexComp( ".*\) Warning W.*" ) )
 
    AAdd( aRegErrors, hb_RegexComp( ".*: error.*" ) )
    AAdd( aRegErrors, hb_RegexComp( ".*\) Error E.*" ) )
-   
+
    FOR EACH cLine IN aLines
-       IF Empty( cLine )
-          *
-       ELSEIF aScan( aRegWarns,   {| reg | !Empty(hb_RegEx( reg, cLine )) } ) > 0
-          cLine := '' + cLine + ''
+      IF Empty( cLine )
+         *
+      ELSEIF aScan( aRegWarns,   {| reg | !Empty( hb_RegEx( reg, cLine ) ) } ) > 0
+         cLine := '' + cLine + ''
 
-       ELSEIF aScan( aRegErrors, {| reg | !Empty(hb_RegEx( reg, cLine )) } ) > 0
-          cLine := '' + cLine + ''
-       End
-       cText += cLine + '
' - End + ELSEIF aScan( aRegErrors, {| reg | !Empty( hb_RegEx( reg, cLine ) ) } ) > 0 + cLine := '' + cLine + '' + + ENDIF + + oWidget:append( cLine ) + + cText += cLine + '
' + NEXT + + cText += '
' - cText += '' RETURN cText /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbqt/qtgui/QTextCursor.cpp b/harbour/contrib/hbqt/qtgui/QTextCursor.cpp index fe998c083e..530ef77cb4 100644 --- a/harbour/contrib/hbqt/qtgui/QTextCursor.cpp +++ b/harbour/contrib/hbqt/qtgui/QTextCursor.cpp @@ -74,6 +74,7 @@ #include +#include #include #include @@ -87,22 +88,22 @@ * ~QTextCursor () */ -QT_G_FUNC( hbqt_gcRelease_QTextCursor ) +QT_G_FUNC( release_QTextCursor ) { QGC_POINTER * p = ( QGC_POINTER * ) Cargo; - HB_TRACE( HB_TR_DEBUG, ( "hbqt_gcRelease_QTextCursor p=%p", p ) ); - HB_TRACE( HB_TR_DEBUG, ( "hbqt_gcRelease_QTextCursor ph=%p", p->ph ) ); + HB_TRACE( HB_TR_DEBUG, ( "release_QTextCursor p=%p", p ) ); + HB_TRACE( HB_TR_DEBUG, ( "release_QTextCursor ph=%p", p->ph ) ); if( p && p->ph ) { delete ( ( QTextCursor * ) p->ph ); p->ph = NULL; - HB_TRACE( HB_TR_DEBUG, ( "YES hbqt_gcRelease_QTextCursor Object deleted! %i B %i KB", ( int ) hb_xquery( 1001 ), hbqt_getmemused() ) ); + HB_TRACE( HB_TR_DEBUG, ( "YES release_QTextCursor Object deleted! %i B %i KB", ( int ) hb_xquery( 1001 ), hbqt_getmemused() ) ); } else { - HB_TRACE( HB_TR_DEBUG, ( "DEL hbqt_gcRelease_QTextCursor Object Already deleted!" ) ); + HB_TRACE( HB_TR_DEBUG, ( "DEL release_QTextCursor Object Already deleted!" ) ); } } @@ -111,7 +112,7 @@ void * hbqt_gcAllocate_QTextCursor( void * pObj ) QGC_POINTER * p = ( QGC_POINTER * ) hb_gcAllocate( sizeof( QGC_POINTER ), hbqt_gcFuncs() ); p->ph = pObj; - p->func = hbqt_gcRelease_QTextCursor; + p->func = release_QTextCursor; HB_TRACE( HB_TR_DEBUG, ( " new_QTextCursor %i B %i KB", ( int ) hb_xquery( 1001 ), hbqt_getmemused() ) ); return( p ); } @@ -200,6 +201,14 @@ HB_FUNC( QT_QTEXTCURSOR_BEGINEDITBLOCK ) hbqt_par_QTextCursor( 1 )->beginEditBlock(); } +/* + * QTextBlock block () const + */ +HB_FUNC( QT_QTEXTCURSOR_BLOCK ) +{ + hb_retptrGC( hbqt_gcAllocate_QTextBlock( new QTextBlock( hbqt_par_QTextCursor( 1 )->block() ) ) ); +} + /* * QTextCharFormat blockCharFormat () const */ diff --git a/harbour/contrib/hbqt/qtgui/TQTextCursor.prg b/harbour/contrib/hbqt/qtgui/TQTextCursor.prg index cb26e0fc8a..cb5ab3cb27 100644 --- a/harbour/contrib/hbqt/qtgui/TQTextCursor.prg +++ b/harbour/contrib/hbqt/qtgui/TQTextCursor.prg @@ -63,9 +63,12 @@ #include "hbclass.ch" -CREATE CLASS QTextCursor INHERIT HbQtObjectHandler +CREATE CLASS QTextCursor + + VAR pPtr METHOD new() + METHOD configure( xObject ) METHOD anchor() METHOD atBlockEnd() @@ -73,6 +76,7 @@ CREATE CLASS QTextCursor INHERIT HbQtObjectHandler METHOD atEnd() METHOD atStart() METHOD beginEditBlock() + METHOD block() METHOD blockCharFormat() METHOD blockFormat() METHOD blockNumber() @@ -130,6 +134,7 @@ CREATE CLASS QTextCursor INHERIT HbQtObjectHandler ENDCLASS +/*----------------------------------------------------------------------*/ METHOD QTextCursor:new( ... ) LOCAL p @@ -141,6 +146,15 @@ METHOD QTextCursor:new( ... ) RETURN Self +METHOD QTextCursor:configure( xObject ) + IF hb_isObject( xObject ) + ::pPtr := xObject:pPtr + ELSEIF hb_isPointer( xObject ) + ::pPtr := xObject + ENDIF + RETURN Self + + METHOD QTextCursor:anchor() RETURN Qt_QTextCursor_anchor( ::pPtr ) @@ -165,6 +179,10 @@ METHOD QTextCursor:beginEditBlock() RETURN Qt_QTextCursor_beginEditBlock( ::pPtr ) +METHOD QTextCursor:block() + RETURN Qt_QTextCursor_block( ::pPtr ) + + METHOD QTextCursor:blockCharFormat() RETURN Qt_QTextCursor_blockCharFormat( ::pPtr ) diff --git a/harbour/contrib/hbqt/qth/QTextCursor.qth b/harbour/contrib/hbqt/qth/QTextCursor.qth index 33f31c8c6d..6bfaadb5e4 100644 --- a/harbour/contrib/hbqt/qth/QTextCursor.qth +++ b/harbour/contrib/hbqt/qth/QTextCursor.qth @@ -70,6 +70,7 @@ oTextCursor := QTextCursor():new( "QTextFrame" , pQTextFrame ) +#include #include #include @@ -130,7 +131,7 @@ bool atEnd () const bool atStart () const void beginEditBlock () # -//QTextBlock block () const +QTextBlock block () const # QTextCharFormat blockCharFormat () const QTextBlockFormat blockFormat () const