2011-05-18 17:53 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)

* contrib/hbide/idedocks.prg
  * contrib/hbide/ideedit.prg
  * contrib/hbide/ideeditor.prg
    + Added: some methods used internally to provide hbIDE speed advantage.

  * contrib/hbide/idesaveload.prg
    ! Changed: the default behavior of :lTrimTrailingBlanks to FALSE
      responsible to strip trailing blanks from saved sources.
      Now if this behavior is desired, change the settings from 
      <Setup><hbIDE Setup><General>.

  * contrib/hbide/idethemes.prg
  * contrib/hbqt/qtgui/hbqt_init.cpp
    + Added: Slot "QRect$int" for updateRequest(QRect,int) for QPlainTextEdit.

  * contrib/hbqt/qtgui/qth/HBQPlainTextEdit.qth
  * contrib/hbqt/qtgui/qth/HBQSyntaxHighlighter.qth
    + Added: more methods.

  * contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp
    ! Fixed: 2 pixel margin around a document text which was causing a 
      major visual glich which selecting text in an editing instance.
      Now it is 0,0 no matter which font and size is used.

  * contrib/hbqt/qtgui/hbqt_hbqplaintextedit.h
  * contrib/hbqt/qtgui/hbqt_hbqsyntaxhighlighter.cpp
  * contrib/hbqt/qtgui/hbqt_hbqsyntaxhighlighter.h
    + Synchronized: to apply syntax highlighting per page basis.
      Qt applies highlighting to the entire document when supplied 
      which, conceptually, should be onto the page brought forward.

      This has rendered hbIDE extremely fast at startup no matter 
      how many sources are loaded probably making hbIDE the fastest 
      IDE at startup.
This commit is contained in:
Pritpal Bedi
2011-05-18 01:12:58 +00:00
parent 97144dd51c
commit 9cfa81238d
13 changed files with 189 additions and 44 deletions

View File

@@ -16,6 +16,42 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-05-18 17:53 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbide/idedocks.prg
* contrib/hbide/ideedit.prg
* contrib/hbide/ideeditor.prg
+ Added: some methods used internally to provide hbIDE speed advantage.
* contrib/hbide/idesaveload.prg
! Changed: the default behavior of :lTrimTrailingBlanks to FALSE
responsible to strip trailing blanks from saved sources.
Now if this behavior is desired, change the settings from
<Setup><hbIDE Setup><General>.
* contrib/hbide/idethemes.prg
* contrib/hbqt/qtgui/hbqt_init.cpp
+ Added: Slot "QRect$int" for updateRequest(QRect,int) for QPlainTextEdit.
* contrib/hbqt/qtgui/qth/HBQPlainTextEdit.qth
* contrib/hbqt/qtgui/qth/HBQSyntaxHighlighter.qth
+ Added: more methods.
* contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp
! Fixed: 2 pixel margin around a document text which was causing a
major visual glich which selecting text in an editing instance.
Now it is 0,0 no matter which font and size is used.
* contrib/hbqt/qtgui/hbqt_hbqplaintextedit.h
* contrib/hbqt/qtgui/hbqt_hbqsyntaxhighlighter.cpp
* contrib/hbqt/qtgui/hbqt_hbqsyntaxhighlighter.h
+ Synchronized: to apply syntax highlighting per page basis.
Qt applies highlighting to the entire document when supplied
which, conceptually, should be onto the page brought forward.
This has rendered hbIDE extremely fast at startup no matter
how many sources are loaded probably making hbIDE the fastest
IDE at startup.
2011-05-18 01:46 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* src/rtl/gtwvt/gtwvt.c
! fixed regression referred to in 2011-05-18 01:06 UTC+0200 Viktor Szakats

View File

@@ -1044,7 +1044,7 @@ METHOD IdeDocks:setView( cView )
EXIT
OTHERWISE
IF ( n := ascan( ::aViews, {|o| o:oWidget:objectName() == cView } ) ) > 0
IF ( n := ascan( ::aViews, {|o| iif( hb_isChar( o:oWidget:objectName() ), o:oWidget:objectName() == cView, .f. ) } ) ) > 0
::oIde:cWrkView := cView
IF !( cView == "Stats" )
::oIde:qTabWidget := ::aViews[ n ]:oTabWidget:oWidget

View File

@@ -246,6 +246,8 @@ CLASS IdeEdit INHERIT IdeObject
METHOD unHighlight()
METHOD parseCodeCompletion( cSyntax )
METHOD highlightPage()
ENDCLASS
/*----------------------------------------------------------------------*/
@@ -400,8 +402,8 @@ METHOD IdeEdit:disconnectEditSignals( oEdit )
oEdit:qEdit:disConnect( "copyAvailable(bool)" )
#if 0
oEdit:qEdit:disConnect( "modificationChanged(bool)" )
oEdit:qEdit:disConnect( "updateRequest(QRect,int)" )
oEdit:qEdit:disConnect( "modificationChanged(bool)" )
oEdit:qEdit:disConnect( "redoAvailable(bool)" )
oEdit:qEdit:disConnect( "undoAvailable(bool)" )
#endif
@@ -411,17 +413,18 @@ METHOD IdeEdit:disconnectEditSignals( oEdit )
/*----------------------------------------------------------------------*/
METHOD IdeEdit:connectEditSignals( oEdit )
HB_SYMBOL_UNUSED( oEdit )
oEdit:qEdit:connect( "customContextMenuRequested(QPoint)", {|p | ::execEvent( 1, oEdit, p ) } )
oEdit:qEdit:Connect( "textChanged()" , {| | ::execEvent( 2, oEdit, ) } )
oEdit:qEdit:Connect( "selectionChanged()" , {|p | ::execEvent( 6, oEdit, p ) } )
oEdit:qEdit:Connect( "cursorPositionChanged()" , {| | ::execEvent( 9, oEdit, ) } )
oEdit:qEdit:Connect( "copyAvailable(bool)" , {|p | ::execEvent( 3, oEdit, p ) } )
oEdit:qEdit:connect( "textChanged()" , {| | ::execEvent( 2, oEdit, ) } )
oEdit:qEdit:connect( "selectionChanged()" , {|p | ::execEvent( 6, oEdit, p ) } )
oEdit:qEdit:connect( "cursorPositionChanged()" , {| | ::execEvent( 9, oEdit, ) } )
oEdit:qEdit:connect( "copyAvailable(bool)" , {|p | ::execEvent( 3, oEdit, p ) } )
#if 0
oEdit:qEdit:connect( "updateRequest(QRect,int)" , {|p,p1| ::execEvent( updateRequest, oEdit, p, p1 ) } )
oEdit:qEdit:connect( "modificationChanged(bool)" , {|p | ::execEvent( 4, oEdit, p ) } )
oEdit:qEdit:connect( "updateRequest(QRect,int)" , {|p,p1| ::execEvent( 8, oEdit, p, p1 ) } )
oEdit:qEdit:connect( "redoAvailable(bool)" , {|p | ::execEvent( 5, oEdit, p ) } )
oEdit:qEdit:connect( "undoAvailable(bool)" , {|p | ::execEvent( 7, oEdit, p ) } )
#endif
@@ -442,7 +445,6 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 )
SWITCH nMode
CASE customContextMenuRequested
//::oEM:aActions[ 17, 2 ]:setEnabled( !empty( qCursor:selectedText() ) )
::oEM:aActions[ 17, 2 ]:setEnabled( !empty( qCursor:selectedText() ) )
n := ascan( ::oEditor:aEdits, {|o| o == oEdit } )
@@ -726,6 +728,14 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 )
/*----------------------------------------------------------------------*/
METHOD IdeEdit:highlightPage()
::qEdit:hbHighlightPage()
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEdit:dispStatusInfo()
LOCAL nMode

View File

@@ -1351,10 +1351,11 @@ METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView, a
::oEdit:qEdit:connect( "updateRequest(QRect,int)", {|| ::scrollThumbnail() } )
::qDocument := ::qEdit:document()
#if 0
IF !( ::cType == "U" )
::qHiliter := ::oTH:SetSyntaxHilighting( ::oEdit:qEdit, @::cTheme )
ENDIF
#endif
::qCursor := ::qEdit:textCursor()
/* Populate Tabs Array */
@@ -1368,7 +1369,10 @@ METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView, a
::oEdit:setReadOnly( .t. )
::qEdit:setTextInteractionFlags( Qt_TextSelectableByMouse + Qt_TextSelectableByKeyboard )
ENDIF
::setTabImage()
::qDocument:setModified( .f. )
::qTabWidget:setTabIcon( ::qTabWidget:indexOf( ::oTab:oWidget ), ;
hbide_image( iif( ::lReadOnly, "tabreadonly", "tabunmodified" ) ) )
RETURN Self
@@ -1430,7 +1434,8 @@ METHOD IdeEditor:split( nOrient, oEditP )
METHOD IdeEditor:destroy()
LOCAL n, oEdit
HB_TRACE( HB_TR_DEBUG, "..........................................................IdeEditor:destroy()", 0 )
HB_TRACE( HB_TR_DEBUG, "..........................................................IdeEditor:destroy()", 0 )
::oEdit:qEdit:disconnect( "updateRequest(QRect,int)" )
IF !empty( ::qTimerSave )
@@ -1480,7 +1485,7 @@ HB_TRACE( HB_TR_DEBUG, "........................................................
::oIde:lDockRVisible := .f.
ENDIF
ENDIF
HB_TRACE( HB_TR_DEBUG, "................................................................IdeEditor:destroy()", 1 )
HB_TRACE( HB_TR_DEBUG, "................................................................IdeEditor:destroy()", 1 )
RETURN Self
/*----------------------------------------------------------------------*/
@@ -1545,6 +1550,11 @@ METHOD IdeEditor:setDocumentProperties()
IF !( ::lLoaded ) /* First Time */
::qEdit:setPlainText( ::prepareBufferToLoad( hb_memoread( ::sourceFile ) ) )
#if 1
IF !( ::cType == "U" )
::qHiliter := ::oTH:setSyntaxHilighting( ::qEdit, @::cTheme )
ENDIF
#endif
qCursor:setPosition( ::nPos )
::qEdit:setTextCursor( qCursor )
@@ -1563,7 +1573,6 @@ METHOD IdeEditor:setDocumentProperties()
::qTimerSave:connect( "timeout()", {|| ::execEvent( "qTimeSave_timeout" ) } )
::qTimerSave:start()
ENDIF
::oUpDn:show()
ENDIF
@@ -1623,6 +1632,7 @@ METHOD IdeEditor:activateTab( mp1, mp2, oXbp )
oEdit:qCoEdit:dispStatusInfo()
::oUpDn:show()
oEdit:changeThumbnail()
oEdit:qCoEdit:highlightPage()
ENDIF
RETURN Self

View File

@@ -138,7 +138,7 @@ CLASS IdeINI INHERIT IdeObject
DATA nPointSize INIT 10
DATA cLineEndingMode INIT ""
DATA lTrimTrailingBlanks INIT .t.
DATA lTrimTrailingBlanks INIT .f.
DATA lSaveSourceWhenComp INIT .t.
DATA lSupressHbKWordsToUpper INIT .f.
DATA lReturnAsBeginKeyword INIT .f.

View File

@@ -482,9 +482,12 @@ METHOD IdeThemes:setSyntaxHilighting( qEdit, cTheme, lNew )
aAttr := ::getThemeAttribute( "SelectionBackground", cTheme )
qEdit:hbSetSelectionColor( QColor( aAttr[ THM_ATR_R ], aAttr[ THM_ATR_G ], aAttr[ THM_ATR_B ] ) )
qEdit:hbSetHighLighter( qHiliter )
ENDIF
qHiliter:setDocument( qEdit:document() )
qHiliter:hbSetEditor( qEdit )
RETURN qHiliter

View File

@@ -178,6 +178,9 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent
connect( timer, SIGNAL( timeout() ), this, SLOT( hbUpdateCaret() ) );
timer->start( 500 );
#endif
QTextDocument * doc = document();
doc->setDocumentMargin( 0 );
}
/*----------------------------------------------------------------------*/
@@ -1629,6 +1632,25 @@ void HBQPlainTextEdit::hbUpdateCaret()
/*----------------------------------------------------------------------*/
int HBQPlainTextEdit::lastVisibleBlockNumber()
{
QTextBlock block = firstVisibleBlock();
int blockNumber = block.blockNumber();
int top = ( int ) blockBoundingGeometry( block ).translated( contentOffset() ).top();
int height = ( int ) blockBoundingRect( block ).height();
int vpHeight = viewport()->height();
while( block.isValid() && top < vpHeight )
{
top += height;
++blockNumber;
block = block.next();
}
return blockNumber;
}
/*----------------------------------------------------------------------*/
void HBQPlainTextEdit::horzRulerPaintEvent( QPaintEvent *event )
{
int fontWidth = fontMetrics().averageCharWidth();
@@ -1762,7 +1784,8 @@ void HBQPlainTextEdit::hbPaintSelection( QPaintEvent * event )
{
QPainter p( viewport() );
int marginX = ( c > 0 ? 0 : contentsRect().left() ) + 2 ;
//int marginX = ( c > 0 ? 0 : contentsRect().left() ) + 2 ;
int marginX = ( c > 0 ? 0 : contentsRect().left() ) ;
int fontWidth = fontMetrics().averageCharWidth();
int top = ( ( rb <= t ) ? 0 : ( ( rb - t ) * fontHeight ) ) + ttop;
@@ -2065,10 +2088,63 @@ void HBQPlainTextEdit::hbUpdateHorzRuler( const QRect & rect, int dy )
/*----------------------------------------------------------------------*/
void HBQPlainTextEdit::hbHighlightPage()
{
int iLastVisBlockNum = lastVisibleBlockNumber();
QTextBlock block = firstVisibleBlock();
if( block.isValid() )
{
int i;
for( i = block.blockNumber(); i < iLastVisBlockNum; i++ )
{
highlighter->rehighlightBlock( block );
block = block.next();
if( ! block.isValid() )
break;
}
}
}
/*----------------------------------------------------------------------*/
void HBQPlainTextEdit::hbUpdateLineNumberArea( const QRect &rect, int dy )
{
if( dy )
{
lineNumberArea->scroll( 0, dy );
#if QT_VERSION >= 0x040600
int rows = abs( dy / fontMetrics().height() );
int i;
QTextBlock block;
if( dy < 0 )
{
int iLastVisBlockNum = lastVisibleBlockNumber();
for( i = iLastVisBlockNum - rows; i <= iLastVisBlockNum; i++ )
{
block = document()->findBlockByNumber( i );
if( block.isValid() )
{
highlighter->rehighlightBlock( block );
}
}
}
else
{
block = firstVisibleBlock();
for( i = 0; i < rows; i++ )
{
highlighter->rehighlightBlock( block );
block = block.next();
}
}
#else
highlighter->rehighlight();
#endif
}
else
lineNumberArea->update( 0, rect.y(), lineNumberArea->width(), rect.height() );

View File

@@ -117,6 +117,11 @@ public:
void hbSetEventBlock( PHB_ITEM pBlock );
int horzRulerHeight;
void hbUpdateHorzRulerHeight( int height );
void hbSetHighLighter( HBQSyntaxHighlighter * hilighter ){ highlighter = hilighter; };
void hbHighlightPage();
int firstVisibleBlockNumber() { return QPlainTextEdit::firstVisibleBlock().blockNumber(); };
int lastVisibleBlockNumber();
private:
QVector<int> bookMark;

View File

@@ -55,6 +55,7 @@
#if QT_VERSION >= 0x040500
#include "hbqt_hbqsyntaxhighlighter.h"
#include "hbqt_hbqplaintextedit.h"
#include <QtCore/QPointer>
#include <QtCore/QHash>
@@ -145,44 +146,24 @@ void HBQSyntaxHighlighter::hbSetFormatColumnSelection( int start, int count, con
void HBQSyntaxHighlighter::highlightBlock( const QString &text )
{
#if 0
QTextBlock curBlock( currentBlock() );
int iState = -1;
HBQTextBlockUserData * data = ( HBQTextBlockUserData * ) curBlock.userData();
int iFirstBlock = editor->firstVisibleBlockNumber();
int iLastBlock = editor->lastVisibleBlockNumber();
int iBlock = currentBlock().blockNumber();
QTextBlockFormat fmt( curBlock.blockFormat() );
if( data )
if( iBlock < iFirstBlock || iBlock > iLastBlock )
{
iState = data->state;
HB_TRACE( HB_TR_DEBUG, ( "iState = %i", iState ) );
switch( iState )
{
case 99:
fmt.setBackground( QColor( 255,255,0 ) );
break;
}
return;
}
#endif
int index = 0;
int length = 0;
foreach( const HighlightingRule &rule, HighlightingRules )
{
#if 0
QRegExp expression( rule.pattern );
index = expression.indexIn( text );
while( index >= 0 )
{
int length = expression.matchedLength();
setFormat( index, length, rule.format );
index = expression.indexIn( text, index + length );
}
#endif
index = rule.pattern.indexIn( text );
while( index >= 0 )
{
int length = rule.pattern.matchedLength();
length = rule.pattern.matchedLength();
setFormat( index, length, rule.format );
index = rule.pattern.indexIn( text, index + length );
}
@@ -192,7 +173,7 @@ void HBQSyntaxHighlighter::highlightBlock( const QString &text )
index = patternQuotation.indexIn( text );
while( index >= 0 )
{
int length = patternQuotation.matchedLength();
length = patternQuotation.matchedLength();
setFormat( index, length, quotationFormat );
index = patternQuotation.indexIn( text, index + length );
}
@@ -201,7 +182,7 @@ void HBQSyntaxHighlighter::highlightBlock( const QString &text )
index = commentSingleLine.indexIn( text );
while( index >= 0 )
{
int length = commentSingleLine.matchedLength();
length = commentSingleLine.matchedLength();
setFormat( index, length, singleLineCommentFormat );
index = commentSingleLine.indexIn( text, index + length );
}

View File

@@ -59,8 +59,10 @@
#include <QtGui/QSyntaxHighlighter>
#include <QtGui/QTextBlockUserData>
#include <QtGui/QPlainTextEdit>
class QTextDocument;
class HBQPlainTextEdit;
class HBQTextBlockUserData : public QTextBlockUserData
{
@@ -86,12 +88,15 @@ class HBQSyntaxHighlighter : public QSyntaxHighlighter
public:
HBQSyntaxHighlighter( QTextDocument *parent = 0 );
HBQPlainTextEdit * editor;
void hbSetMultiLineCommentFormat( const QTextCharFormat & format );
void hbSetSingleLineCommentFormat( const QTextCharFormat & format );
void hbSetRule( QString name, QString pattern, const QTextCharFormat & format );
void hbSetFormat( QString name, const QTextCharFormat & format );
void hbSetFormatColumnSelection( int start, int count, const QColor & color );
void hbSetRuleWithRegExp( QString name, const QRegExp & reg, const QTextCharFormat & format );
void hbSetEditor( HBQPlainTextEdit * edit ){ editor = edit; };
protected:
void highlightBlock( const QString &text );

View File

@@ -101,6 +101,7 @@ extern void * hbqt_gcAllocate_QListWidgetItem( void * pObj, bool bNew );
extern void * hbqt_gcAllocate_QTreeWidgetItem( void * pObj, bool bNew );
extern void * hbqt_gcAllocate_QTableWidgetItem( void * pObj, bool bNew );
extern void * hbqt_gcAllocate_QWidget( void * pObj, bool bNew );
extern void * hbqt_gcAllocate_QRect( void * pObj, bool bNew );
extern void * hbqt_gcAllocate_QActionEvent( void * pObj, bool bNew );
extern void * hbqt_gcAllocate_QContextMenuEvent( void * pObj, bool bNew );
@@ -352,6 +353,17 @@ static void hbqt_SlotsExecQWidgetInt( PHB_ITEM * codeBlock, void ** arguments, Q
hb_vmSend( 2 );
}
static void hbqt_SlotsExecQRectInt( PHB_ITEM * codeBlock, void ** arguments, QStringList pList )
{
Q_UNUSED( pList );
hb_vmPushEvalSym();
hb_vmPush( codeBlock );
hb_vmPush( hbqt_create_objectGC( hbqt_gcAllocate_QRect( new QRect( ( *reinterpret_cast< QRect( * ) >( arguments[ 1 ] ) ) ), true ), "hb_QRect" ) );
hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) );
hb_vmSend( 2 );
}
HB_FUNC_EXTERN( HB_QABSTRACTBUTTON );
HB_FUNC_EXTERN( HB_QACTION );
@@ -460,6 +472,7 @@ static void hbqt_registerCallbacks( void )
hbqt_slots_register_callback( "QTreeWidgetItem*" , hbqt_SlotsExecQTreeWidgetItem );
hbqt_slots_register_callback( "QListWidgetItem*" , hbqt_SlotsExecQListWidgetItem );
hbqt_slots_register_callback( "QWidget*" , hbqt_SlotsExecQWidget );
hbqt_slots_register_callback( "QRect$int" , hbqt_SlotsExecQRectInt );
hbqt_events_register_createobj( QEvent::MouseButtonPress , "hb_QMouseEvent" , hbqt_gcAllocate_QMouseEvent );
hbqt_events_register_createobj( QEvent::MouseButtonRelease , "hb_QMouseEvent" , hbqt_gcAllocate_QMouseEvent );

View File

@@ -25,6 +25,7 @@ New =
#include <QtGui/QPlainTextEdit>
#include "hbqt_hbqplaintextedit.h"
#include "hbqt_hbqsyntaxhighlighter.h"
HBQT_GC_FUNC( hbqt_gcMark_HBQPlainTextEdit )
{
@@ -86,6 +87,8 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT )
void hbHighlightCurrentLine(bool b)
bool hbHighlightCurrentLine()
void hbSetEventBlock( PHB_ITEM block )
void hbSetHighLighter( HBQSyntaxHighlighter * hilighter )
void hbHighlightPage()
</PROTOS>
<SLOTS>

View File

@@ -26,7 +26,9 @@ New =
<CODE>
#include <QtGui/QSyntaxHighlighter>
#include <QtGui/QPlainTextEdit>
#include "hbqt_hbqsyntaxhighlighter.h"
#include "hbqt_hbqplaintextedit.h"
/*
* HBQSyntaxHighlighter ( QTextDocument * textDocument )
@@ -49,6 +51,7 @@ void hbSetRule( QString name, QString pattern, QTextCharFormat & format )
void hbSetFormat( QString name, const QTextCharFormat & format )
void hbSetFormatColumnSelection( int start, int count, const QColor & color )
void hbSetRuleWithRegExp( QString name, const QRegExp & reg, const QTextCharFormat & format )
void hbSetEditor( HBQPlainTextEdit * edit )
# QTextBlock currentBlock () const
# int currentBlockState () const