2010-01-19 17:46 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbqt/hbqt_hbqsyntaxhighlighter.cpp
* contrib/hbqt/hbqt_hbqsyntaxhighlighter.h
* contrib/hbqt/qtgui/HBQSyntaxHighlighter.cpp
* contrib/hbqt/qtgui/THBQSyntaxHighlighter.prg
* contrib/hbqt/qth/HBQSyntaxHighLighter.qth
% Improved syntax highlighting.
* contrib/hbide/hbide.prg
* contrib/hbide/ideactions.prg
* contrib/hbide/ideeditor.prg
* contrib/hbide/ideobject.prg
* contrib/hbide/idethemes.prg
! Struggling to get some artifacts fixed, mainly at a time
when enter is pressed for new line.
+ Implemented F7 <Insert Separator> == "/*" + replicate( "-", 70 ) + "*/".
This commit is contained in:
@@ -17,6 +17,23 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-01-19 17:46 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* contrib/hbqt/hbqt_hbqsyntaxhighlighter.cpp
|
||||
* contrib/hbqt/hbqt_hbqsyntaxhighlighter.h
|
||||
* contrib/hbqt/qtgui/HBQSyntaxHighlighter.cpp
|
||||
* contrib/hbqt/qtgui/THBQSyntaxHighlighter.prg
|
||||
* contrib/hbqt/qth/HBQSyntaxHighLighter.qth
|
||||
% Improved syntax highlighting.
|
||||
|
||||
* contrib/hbide/hbide.prg
|
||||
* contrib/hbide/ideactions.prg
|
||||
* contrib/hbide/ideeditor.prg
|
||||
* contrib/hbide/ideobject.prg
|
||||
* contrib/hbide/idethemes.prg
|
||||
! Struggling to get some artifacts fixed, mainly at a time
|
||||
when enter is pressed for new line.
|
||||
+ Implemented F7 <Insert Separator> == "/*" + replicate( "-", 70 ) + "*/".
|
||||
|
||||
2010-01-19 23:12 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbwin/win_tprn.prg
|
||||
* contrib/hbwin/win_prn1.c
|
||||
|
||||
@@ -187,6 +187,7 @@ CLASS HbIde
|
||||
DATA cProcessInfo
|
||||
DATA cIniThemes
|
||||
DATA cWrkCodec INIT ""
|
||||
DATA cSeparator INIT "/*" + replicate( "-", 70 ) + "*/"
|
||||
|
||||
DATA nTabSpaces INIT 3 /* Via User Setup */
|
||||
DATA cTabSpaces INIT space( 3 ) //::nTabSpaces )
|
||||
@@ -500,6 +501,8 @@ METHOD HbIde:execAction( cKey )
|
||||
::oEM:convertSelection( cKey )
|
||||
CASE cKey == "MatchPairs"
|
||||
//
|
||||
CASE cKey == "InsertSeparator"
|
||||
::oEM:insertSeparator()
|
||||
CASE cKey == "InsertDateTime"
|
||||
::oEM:insertText( cKey )
|
||||
CASE cKey == "InsertRandomName"
|
||||
|
||||
@@ -252,6 +252,7 @@ METHOD IdeActions:loadActions()
|
||||
aadd( aAct, { "InsertDateTime" , "~Date && Time" , "insert-datetime", "Sh+F7", "No", "Yes" } )
|
||||
aadd( aAct, { "InsertRandomName" , "~Random Function Name" , "insert-procname", "Sh+F8", "No", "Yes" } )
|
||||
aadd( aAct, { "InsertExternalFile" , "~External File at Cursor" , "insert-external-file", "", "No", "Yes" } )
|
||||
aadd( aAct, { "InsertSeparator" , "~Separator" , "" , "F7" , "No", "Yes" } )
|
||||
aadd( aAct, { "switchReadOnly" , "Switch Read~Only Mode" , "readonly" , "" , "No", "Yes" } )
|
||||
aadd( aAct, { "Properties" , "Properties" , "" , "" , "No", "Yes" } )
|
||||
aadd( aAct, { "ProjAddSource" , "Add Source to Project" , "projectadd" , "" , "No", "Yes" } )
|
||||
@@ -445,6 +446,8 @@ METHOD IdeActions:buildMainMenu()
|
||||
hbide_menuAddSep( oSubMenu )
|
||||
|
||||
oSubMenu2 := XbpMenu():new( oSubMenu ):create()
|
||||
oSubMenu2:addItem( { ::getAction( "InsertSeparator" ), {|| oIde:execAction( "InsertSeparator" ) } } )
|
||||
hbide_menuAddSep( oSubMenu )
|
||||
oSubMenu2:addItem( { ::getAction( "InsertDateTime" ), {|| oIde:execAction( "InsertDateTime" ) } } )
|
||||
oSubMenu2:addItem( { ::getAction( "InsertRandomName" ), {|| oIde:execAction( "InsertRandomName" ) } } )
|
||||
oSubMenu2:addItem( { ::getAction( "InsertExternalFile" ), {|| oIde:execAction( "InsertExternalFile" ) } } )
|
||||
|
||||
@@ -123,6 +123,7 @@ CLASS IdeEditsManager INHERIT IdeObject
|
||||
METHOD switchToReadOnly()
|
||||
METHOD convertSelection( cKey )
|
||||
METHOD insertText( cKey )
|
||||
METHOD insertSeparator()
|
||||
METHOD zoom( nKey )
|
||||
METHOD printPreview()
|
||||
METHOD paintRequested( pPrinter )
|
||||
@@ -530,14 +531,36 @@ METHOD IdeEditsManager:convertSelection( cKey )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeEditsManager:insertText( cKey )
|
||||
LOCAL nB, nL, qCursor, cFile, cText
|
||||
METHOD IdeEditsManager:insertSeparator()
|
||||
LOCAL oEdit, qCursor
|
||||
|
||||
IF Empty( ::qCurEdit )
|
||||
IF empty( oEdit := ::getEditObjectCurrent() )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
|
||||
qCursor := QTextCursor():configure( ::qCurEdit:textCursor() )
|
||||
qCursor := QTextCursor():configure( oEdit:qEdit:textCursor() )
|
||||
|
||||
qCursor:beginEditBlock()
|
||||
qCursor:movePosition( QTextCursor_StartOfBlock )
|
||||
qCursor:insertBlock()
|
||||
qCursor:movePosition( QTextCursor_PreviousBlock )
|
||||
qCursor:insertText( ::cSeparator )
|
||||
qCursor:movePosition( QTextCursor_NextBlock )
|
||||
qCursor:movePosition( QTextCursor_StartOfBlock )
|
||||
qCursor:endEditBlock()
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeEditsManager:insertText( cKey )
|
||||
LOCAL nB, nL, qCursor, cFile, cText, oEdit
|
||||
|
||||
IF empty( oEdit := ::getEditObjectCurrent() )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
|
||||
qCursor := QTextCursor():configure( oEdit:qEdit:textCursor() )
|
||||
|
||||
DO CASE
|
||||
|
||||
@@ -896,7 +919,6 @@ FUNCTION hbide_handlePreviousWord( qEdit )
|
||||
cText := qTextBlock:text()
|
||||
nPos := qCursor:columnNumber()
|
||||
cWord := hbide_getPreviousWord( cText, nPos + 1 )
|
||||
hbide_dbg( cWord )
|
||||
|
||||
IF !empty( cWord )
|
||||
nL := len( cWord + " " )
|
||||
@@ -908,6 +930,7 @@ FUNCTION hbide_handlePreviousWord( qEdit )
|
||||
qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nL )
|
||||
qCursor:removeSelectedText()
|
||||
qCursor:insertText( upper( cWord ) + " " )
|
||||
|
||||
qEdit:setTextCursor( qCursor )
|
||||
qCursor:endEditBlock()
|
||||
ENDIF
|
||||
@@ -915,11 +938,14 @@ FUNCTION hbide_handlePreviousWord( qEdit )
|
||||
IF hbide_isStartingKeyword( cWord )
|
||||
qCursor:setPosition( nB )
|
||||
nPos := qCursor:columnNumber()
|
||||
|
||||
IF nPos > 0
|
||||
qCursor:beginEditBlock()
|
||||
qCursor:movePosition( QTextCursor_StartOfBlock )
|
||||
|
||||
qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nPos )
|
||||
qCursor:removeSelectedText()
|
||||
|
||||
qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_MoveAnchor, nL )
|
||||
qCursor:endEditBlock()
|
||||
ENDIF
|
||||
@@ -1003,11 +1029,12 @@ METHOD IdeEditor:findLastIndent()
|
||||
METHOD IdeEditor:exeEvent( nMode, o, p, p1, p2 )
|
||||
LOCAL qCursor, nSpaces, qChar
|
||||
|
||||
HB_SYMBOL_UNUSED( o )
|
||||
HB_SYMBOL_UNUSED( o )
|
||||
HB_SYMBOL_UNUSED( p1 )
|
||||
|
||||
SWITCH nMode
|
||||
CASE blockCountChanged
|
||||
hbide_dbg( "blockCountChanged(int)", p, p1 )
|
||||
hbide_dbg( "blockCountChanged(int)", p )
|
||||
::nPrevBlocks := ::nBlocks
|
||||
::nBlocks := p
|
||||
//
|
||||
@@ -1017,7 +1044,7 @@ METHOD IdeEditor:exeEvent( nMode, o, p, p1, p2 )
|
||||
qCursor:insertText( space( nSpaces ) )
|
||||
ENDIF
|
||||
ENDIF
|
||||
::qCoEdit:nPrevLineNo := ::qCoEdit:nCurLineNo
|
||||
//::qCoEdit:nPrevLineNo := ::qCoEdit:nCurLineNo
|
||||
EXIT
|
||||
CASE contentsChange
|
||||
IF p2 == 1 /* Characters Added */
|
||||
@@ -1303,13 +1330,14 @@ CLASS IdeEdit INHERIT IdeObject
|
||||
DATA qBrushNR INIT QBrush():new( "QColor", QColor():new( 255,255,255 ) )
|
||||
DATA qBrushMark INIT QBrush():new( "QColor", QColor():new( 0,255,255 ) )
|
||||
DATA qActionTab
|
||||
DATA qLastCursor
|
||||
DATA qLastCursor INIT QTextCursor():new()
|
||||
|
||||
DATA qCursorMark
|
||||
DATA qMarkUData INIT HBQTextBlockUserData():new()
|
||||
DATA aBookMarks INIT {}
|
||||
|
||||
DATA qSlots
|
||||
DATA lCursorPosChanging INIT .F.
|
||||
|
||||
METHOD new( oEditor, nMode )
|
||||
METHOD create( oEditor, nMode )
|
||||
@@ -1317,10 +1345,11 @@ CLASS IdeEdit INHERIT IdeObject
|
||||
METHOD exeEvent( nMode, oEdit, o, p, p1 )
|
||||
METHOD connectEditSlots( oEdit )
|
||||
METHOD disConnectEditSlots( oEdit )
|
||||
METHOD highlightCurrentLine( oEdit )
|
||||
METHOD highlightCurrentLine()
|
||||
METHOD setNewMark()
|
||||
METHOD gotoLastMark()
|
||||
METHOD getUserDataState( qB )
|
||||
METHOD deHighlightPreviousLine()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
@@ -1471,20 +1500,20 @@ METHOD IdeEdit:exeEvent( nMode, oEdit, o, p, p1 )
|
||||
ENDIF
|
||||
EXIT
|
||||
CASE textChanged
|
||||
hbide_dbg( "textChanged()" )
|
||||
//hbide_dbg( "textChanged()" )
|
||||
::oEditor:setTabImage( qEdit )
|
||||
EXIT
|
||||
CASE copyAvailable
|
||||
hbide_dbg( "copyAvailable(bool)", p )
|
||||
//hbide_dbg( "copyAvailable(bool)", p )
|
||||
EXIT
|
||||
CASE modificationChanged
|
||||
hbide_dbg( "modificationChanged(bool)", p )
|
||||
//hbide_dbg( "modificationChanged(bool)", p )
|
||||
EXIT
|
||||
CASE redoAvailable
|
||||
hbide_dbg( "redoAvailable(bool)", p )
|
||||
//hbide_dbg( "redoAvailable(bool)", p )
|
||||
EXIT
|
||||
CASE selectionChanged
|
||||
hbide_dbg( "selectionChanged()" )
|
||||
//hbide_dbg( "selectionChanged()" )
|
||||
::oEditor:qCqEdit := qEdit
|
||||
::oEditor:qCoEdit := oEdit
|
||||
|
||||
@@ -1492,10 +1521,10 @@ METHOD IdeEdit:exeEvent( nMode, oEdit, o, p, p1 )
|
||||
::oDK:setStatusText( SB_PNL_SELECTEDCHARS, len( qCursor:selectedText() ) )
|
||||
EXIT
|
||||
CASE undoAvailable
|
||||
hbide_dbg( "undoAvailable(bool)", p )
|
||||
//hbide_dbg( "undoAvailable(bool)", p )
|
||||
EXIT
|
||||
CASE updateRequest
|
||||
* hbide_dbg( "updateRequest" )
|
||||
//hbide_dbg( "updateRequest" )
|
||||
qCursor := QTextCursor():configure( qEdit:cursorForPosition( ::qPoint ) )
|
||||
nLineNo := qCursor:blockNumber()
|
||||
nBlocks := ::oEditor:qDocument:blockCount()
|
||||
@@ -1507,69 +1536,72 @@ METHOD IdeEdit:exeEvent( nMode, oEdit, o, p, p1 )
|
||||
ENDIF
|
||||
EXIT
|
||||
CASE cursorPositionChanged
|
||||
::oEditor:dispEditInfo( qEdit )
|
||||
::highlightCurrentLine( oEdit )
|
||||
EXIT
|
||||
CASE 71
|
||||
hbide_dbg( "CTRL+F2 Pressed" )
|
||||
/* This is a hack */
|
||||
IF !( ::lCursorPosChanging )
|
||||
//hbide_dbg( "cursorPositionChanged()" )
|
||||
::lCursorPosChanging := .T.
|
||||
::oEditor:dispEditInfo( qEdit )
|
||||
::highlightCurrentLine()
|
||||
::lCursorPosChanging := .F.
|
||||
ENDIF
|
||||
EXIT
|
||||
|
||||
ENDSWITCH
|
||||
|
||||
RETURN Nil
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeEdit:highlightCurrentLine( oEdit )
|
||||
LOCAL nCurLine, nLastLine, qCursor, lModified, qBlock, qDoc
|
||||
LOCAL qUData, qEdit, qBlockFmt, qB, lInvalidate
|
||||
METHOD IdeEdit:deHighlightPreviousLine()
|
||||
LOCAL qB, qDoc
|
||||
|
||||
qEdit := oEdit:qEdit
|
||||
qCursor := QTextCursor():configure( qEdit:textCursor() )
|
||||
qDoc := QTextDocument():configure( ::qEdit:document() )
|
||||
|
||||
IF ( qB := QTextBlock():configure( qDoc:findBlockByNumber( ::nLastLine ) ) ):isValid()
|
||||
IF ::getUserDataState( qB ) != 99
|
||||
::qLastCursor:setBlockFormat( QTextBlockFormat():new() )
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeEdit:highlightCurrentLine()
|
||||
LOCAL nCurLine, nLastLine, qCursor, lModified, qDoc, qEdit, qBlockFmt, qB
|
||||
|
||||
qEdit := ::qEdit
|
||||
qCursor := QTextCursor():new( qEdit:textCursor() )
|
||||
nCurLine := qCursor:blockNumber()
|
||||
nLastLine := oEdit:nLastLine
|
||||
nLastLine := ::nLastLine
|
||||
|
||||
IF !( nCurLine == nLastLine )
|
||||
IF ( qBlock := QTextBlock():configure( qCursor:block() ) ):isValid()
|
||||
qDoc := QTextDocument():configure( qEdit:document() )
|
||||
lModified := qDoc:isModified()
|
||||
qDoc := QTextDocument():configure( qEdit:document() )
|
||||
lModified := qDoc:isModified()
|
||||
|
||||
IF !empty( oEdit:qLastCursor )
|
||||
IF ( qB := QTextBlock():configure( oEdit:qLastCursor:block() ) ):isValid()
|
||||
IF ::getUserDataState( qB ) != 99
|
||||
oEdit:qLastCursor:setBlockFormat( QTextBlockFormat():new() )
|
||||
ENDIF
|
||||
ENDIF
|
||||
::deHighlightPreviousLine()
|
||||
|
||||
IF ( qB := QTextBlock():configure( qCursor:block() ) ):isValid()
|
||||
IF ::getUserDataState( qB ) != 99
|
||||
qBlockFmt := QTextBlockFormat():configure( qB:blockFormat() )
|
||||
qBlockFmt:setBackground( ::qBrushCL )
|
||||
qCursor:setBlockFormat( qBlockFmt )
|
||||
ENDIF
|
||||
|
||||
IF ( qB := QTextBlock():configure( qCursor:block() ) ):isValid()
|
||||
qUData := HBQTextBlockUserData():configure( qB:userData() )
|
||||
lInvalidate := empty( qUData:pPtr )
|
||||
IF !( lInvalidate )
|
||||
lInvalidate := qUData:hbState() != 99
|
||||
ENDIF
|
||||
IF lInvalidate
|
||||
qBlockFmt := QTextBlockFormat():configure( qBlock:blockFormat() )
|
||||
qBlockFmt:setBackground( ::qBrushCL )
|
||||
qCursor:setBlockFormat( qBlockFmt )
|
||||
qEdit:setTextCursor( qCursor )
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
qDoc:setModified( lModified )
|
||||
|
||||
/* Infact these must not be called from here but because changing the format */
|
||||
/* Qt consider that document has been modified, hence I need to put them here */
|
||||
|
||||
::qTabWidget:setTabIcon( ::qTabWidget:indexOf( oEdit:oEditor:oTab:oWidget ), ;
|
||||
::resPath + iif( lModified, "tabmodified.png", "tabunmodified.png" ) )
|
||||
::oDK:setStatusText( SB_PNL_MODIFIED, lModified )
|
||||
|
||||
ENDIF
|
||||
|
||||
oEdit:nLastLine := nCurLine
|
||||
oEdit:qLastCursor := qCursor
|
||||
/* Infact these must not be called from here but because changing the format */
|
||||
/* Qt consider that document has been modified, hence I need to put them here */
|
||||
qDoc:setModified( lModified )
|
||||
::qTabWidget:setTabIcon( ::qTabWidget:indexOf( ::oEditor:oTab:oWidget ), ;
|
||||
::resPath + iif( lModified, "tabmodified.png", "tabunmodified.png" ) )
|
||||
::oDK:setStatusText( SB_PNL_MODIFIED, lModified )
|
||||
ENDIF
|
||||
hbide_justACall( qB )
|
||||
|
||||
::nLastLine := nCurLine
|
||||
IF !( qCursor:isNull() )
|
||||
::qLastCursor := qCursor
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@@ -1581,7 +1613,6 @@ METHOD IdeEdit:setNewMark()
|
||||
lModified := qDoc:isModified()
|
||||
|
||||
IF empty( ::qCursorMark )
|
||||
hbide_dbg( ".................................. Set New Mark" )
|
||||
::qCursorMark := QTextCursor():configure( ::qEdit:textCursor() )
|
||||
|
||||
qTextBlock := QTextBlock():configure( ::qCursorMark:block() )
|
||||
@@ -1595,10 +1626,9 @@ hbide_dbg( ".................................. Set New Mark" )
|
||||
qTextBlock:setUserData( ::qMarkUData )
|
||||
|
||||
ELSE
|
||||
hbide_dbg( "........................................... Release Mark" )
|
||||
IF ( qTextBlock := QTextBlock():configure( ::qCursorMark:block() ) ):isValid()
|
||||
nState := ::getUserDataState( qTextBlock )
|
||||
hbide_dbg( 10001, nState )
|
||||
|
||||
IF nState == 99 /* Marked */
|
||||
::qMarkUData:hbSetState( -1 )
|
||||
::qCursorMark:setBlockFormat( QTextBlockFormat():new() )
|
||||
|
||||
@@ -121,6 +121,7 @@ CLASS IdeObject
|
||||
|
||||
ACCESS nTabSpaces INLINE ::oIde:nTabSpaces
|
||||
ACCESS cTabSpaces INLINE ::oIde:cTabSpaces
|
||||
ACCESS cSeparator INLINE ::oIde:cSeparator
|
||||
|
||||
ACCESS oDockPT INLINE ::oIde:oDockPT
|
||||
ACCESS oProjTree INLINE ::oIde:oProjTree
|
||||
|
||||
@@ -124,6 +124,7 @@ CLASS IdeThemes INHERIT IdeObject
|
||||
METHOD buildSyntaxFormat( aAttr )
|
||||
METHOD setForeBackGround( qEdit, cTheme )
|
||||
METHOD setMultiLineCommentRule( qHiliter, cTheme )
|
||||
METHOD setSingleLineCommentRule( qHiliter, cTheme )
|
||||
METHOD setSyntaxRule( qHiliter, cName, cPattern, aAttr )
|
||||
METHOD setSyntaxFormat( qHiliter, cName, aAttr )
|
||||
METHOD setSyntaxHilighting( qEdit, cTheme, lNew )
|
||||
@@ -206,8 +207,6 @@ METHOD IdeThemes:create( oIde, cIniFile )
|
||||
|
||||
aadd( ::aPatterns, { "TerminatedStrings" , [\".*\"|\'.*\'] } )
|
||||
|
||||
aadd( ::aPatterns, { "CommentsAndRemarks", "//[^\n]*" } )
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@@ -328,6 +327,17 @@ METHOD IdeThemes:setForeBackGround( qEdit, cTheme )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeThemes:setSingleLineCommentRule( qHiliter, cTheme )
|
||||
LOCAL aAttr
|
||||
|
||||
IF !empty( aAttr := ::getThemeAttribute( "CommentsAndRemarks", cTheme ) )
|
||||
qHiliter:hbSetSingleLineCommentFormat( ::buildSyntaxFormat( aAttr ) )
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeThemes:setMultiLineCommentRule( qHiliter, cTheme )
|
||||
LOCAL aAttr
|
||||
|
||||
@@ -379,6 +389,7 @@ METHOD IdeThemes:setSyntaxHilighting( qEdit, cTheme, lNew )
|
||||
ENDIF
|
||||
NEXT
|
||||
::setMultiLineCommentRule( qHiliter, cTheme )
|
||||
::setSingleLineCommentRule( qHiliter, cTheme )
|
||||
|
||||
RETURN qHiliter
|
||||
|
||||
|
||||
@@ -95,6 +95,8 @@ HBQSyntaxHighlighter::HBQSyntaxHighlighter( QTextDocument * parent )
|
||||
|
||||
commentStartExpression = QRegExp( "/\\*" );
|
||||
commentEndExpression = QRegExp( "\\*/" );
|
||||
|
||||
commentSingleLine = QRegExp( "//[^\n]*" );
|
||||
}
|
||||
|
||||
void HBQSyntaxHighlighter::hbSetRule( QString name, QString pattern, const QTextCharFormat & format )
|
||||
@@ -122,6 +124,10 @@ void HBQSyntaxHighlighter::hbSetMultiLineCommentFormat( const QTextCharFormat &
|
||||
{
|
||||
multiLineCommentFormat = format;
|
||||
}
|
||||
void HBQSyntaxHighlighter::hbSetSingleLineCommentFormat( const QTextCharFormat & format )
|
||||
{
|
||||
singleLineCommentFormat = format;
|
||||
}
|
||||
|
||||
void HBQSyntaxHighlighter::highlightBlock( const QString &text )
|
||||
{
|
||||
@@ -131,12 +137,26 @@ void HBQSyntaxHighlighter::highlightBlock( const QString &text )
|
||||
#endif
|
||||
|
||||
QRegExp expression;
|
||||
|
||||
#if 0
|
||||
QTextBlock curBlock( currentBlock() );
|
||||
bool bMerge = false;
|
||||
int iState = -1;
|
||||
HBQTextBlockUserData * data = ( HBQTextBlockUserData * ) curBlock.userData();
|
||||
|
||||
QTextBlockFormat fmt( curBlock.blockFormat() );
|
||||
if( data )
|
||||
bMerge = ( data->state == 99 );
|
||||
{
|
||||
iState = data->state;
|
||||
HB_TRACE( HB_TR_ALWAYS, ( "iState = %i", iState ) );
|
||||
|
||||
switch( iState )
|
||||
{
|
||||
case 99:
|
||||
fmt.setBackground( QColor( 255,255,0 ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
foreach( const HighlightingRule &rule, HighlightingRules )
|
||||
{
|
||||
@@ -145,24 +165,22 @@ void HBQSyntaxHighlighter::highlightBlock( const QString &text )
|
||||
while( index >= 0 )
|
||||
{
|
||||
int length = expression.matchedLength();
|
||||
QTextBlockFormat tBlockFormat( curBlock.blockFormat() );
|
||||
QBrush brush( tBlockFormat.background() );
|
||||
|
||||
if( bMerge )
|
||||
{
|
||||
HB_TRACE( HB_TR_ALWAYS, ( "text = %i", data->state ) );
|
||||
// setFormat( index, length, rule.format );
|
||||
}
|
||||
else
|
||||
{
|
||||
setFormat( index, length, rule.format );
|
||||
}
|
||||
|
||||
setFormat( index, length, rule.format );
|
||||
index = expression.indexIn( text, index + length );
|
||||
}
|
||||
}
|
||||
|
||||
/* Single Line Comments */
|
||||
int index = commentSingleLine.indexIn( text );
|
||||
while( index >= 0 )
|
||||
{
|
||||
int length = commentSingleLine.matchedLength();
|
||||
setFormat( index, length, singleLineCommentFormat );
|
||||
index = commentSingleLine.indexIn( text, index + length );
|
||||
}
|
||||
setCurrentBlockState( 0 );
|
||||
|
||||
/* Multi Line Comments */
|
||||
int startIndex = 0;
|
||||
if( previousBlockState() != 1 )
|
||||
startIndex = commentStartExpression.indexIn( text );
|
||||
|
||||
@@ -85,6 +85,7 @@ public:
|
||||
HBQSyntaxHighlighter( QTextDocument *parent = 0 );
|
||||
|
||||
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 );
|
||||
|
||||
@@ -110,6 +111,7 @@ protected:
|
||||
|
||||
QRegExp commentStartExpression;
|
||||
QRegExp commentEndExpression;
|
||||
QRegExp commentSingleLine;
|
||||
|
||||
QTextCharFormat keywordFormat;
|
||||
QTextCharFormat classFormat;
|
||||
|
||||
@@ -149,6 +149,14 @@ HB_FUNC( QT_HBQSYNTAXHIGHLIGHTER_HBSETMULTILINECOMMENTFORMAT )
|
||||
hbqt_par_HBQSyntaxHighlighter( 1 )->hbSetMultiLineCommentFormat( *hbqt_par_QTextCharFormat( 2 ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* void hbSetSingleLineCommentFormat( const QTextCharFormat & format )
|
||||
*/
|
||||
HB_FUNC( QT_HBQSYNTAXHIGHLIGHTER_HBSETSINGLELINECOMMENTFORMAT )
|
||||
{
|
||||
hbqt_par_HBQSyntaxHighlighter( 1 )->hbSetSingleLineCommentFormat( *hbqt_par_QTextCharFormat( 2 ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* void hbSetRule( QString name, QString pattern, QTextCharFormat & format )
|
||||
*/
|
||||
|
||||
@@ -68,6 +68,7 @@ CREATE CLASS HBQSyntaxHighlighter INHERIT HbQtObjectHandler, QSyntaxHighlighter
|
||||
METHOD new( ... )
|
||||
|
||||
METHOD hbSetMultiLineCommentFormat( pFormat )
|
||||
METHOD hbSetSingleLineCommentFormat( pFormat )
|
||||
METHOD hbSetRule( cName, cPattern, pFormat )
|
||||
METHOD hbSetFormat( cName, pFormat )
|
||||
|
||||
@@ -87,6 +88,10 @@ METHOD HBQSyntaxHighlighter:hbSetMultiLineCommentFormat( pFormat )
|
||||
RETURN Qt_HBQSyntaxHighlighter_hbSetMultiLineCommentFormat( ::pPtr, hbqt_ptr( pFormat ) )
|
||||
|
||||
|
||||
METHOD HBQSyntaxHighlighter:hbSetSingleLineCommentFormat( pFormat )
|
||||
RETURN Qt_HBQSyntaxHighlighter_hbSetSingleLineCommentFormat( ::pPtr, hbqt_ptr( pFormat ) )
|
||||
|
||||
|
||||
METHOD HBQSyntaxHighlighter:hbSetRule( cName, cPattern, pFormat )
|
||||
RETURN Qt_HBQSyntaxHighlighter_hbSetRule( ::pPtr, cName, cPattern, hbqt_ptr( pFormat ) )
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ HB_FUNC( QT_HBQSYNTAXHIGHLIGHTER )
|
||||
<PROTOS>
|
||||
|
||||
void hbSetMultiLineCommentFormat( const QTextCharFormat & format )
|
||||
void hbSetSingleLineCommentFormat( const QTextCharFormat & format )
|
||||
void hbSetRule( QString name, QString pattern, QTextCharFormat & format )
|
||||
void hbSetFormat( QString name, const QTextCharFormat & format )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user