From 04e44f2eed3375d39b265124e8dc9557a5531a7b Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 18 Jan 2010 18:01:06 +0000 Subject: [PATCH] 2010-01-18 09:55 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbide/hbide.prg * contrib/hbide/ideactions.prg * contrib/hbide/ideeditor.prg * contrib/hbide/idemisc.prg * contrib/hbide/ideobject.prg * contrib/hbide/idesources.prg * contrib/hbide/idethemes.prg ! Updated to honor latest changes. + Added: ZoomIn, ZoomOut feature, currently via toolbar. ! Fixed: open dialog respecting last opened path. ! Fixed: to display codec in the statusbar at the startup. ! Fixed: context menu gpf'ing if no prompt is selected. + Prepared: to allow extended book-"Mark" feature. + Prepared: to handle extended syntax highlighting. ! More artifacts I must be missing. --- harbour/ChangeLog | 17 +++++ harbour/contrib/hbide/hbide.prg | 7 +- harbour/contrib/hbide/ideactions.prg | 3 + harbour/contrib/hbide/ideeditor.prg | 97 +++++++++++++++++++++------- harbour/contrib/hbide/idemisc.prg | 4 +- harbour/contrib/hbide/ideobject.prg | 1 + harbour/contrib/hbide/idesources.prg | 12 +++- harbour/contrib/hbide/idethemes.prg | 8 +-- 8 files changed, 113 insertions(+), 36 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 96399cb663..48863f38d3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,23 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-18 09:55 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbide/hbide.prg + * contrib/hbide/ideactions.prg + * contrib/hbide/ideeditor.prg + * contrib/hbide/idemisc.prg + * contrib/hbide/ideobject.prg + * contrib/hbide/idesources.prg + * contrib/hbide/idethemes.prg + ! Updated to honor latest changes. + + Added: ZoomIn, ZoomOut feature, currently via toolbar. + ! Fixed: open dialog respecting last opened path. + ! Fixed: to display codec in the statusbar at the startup. + ! Fixed: context menu gpf'ing if no prompt is selected. + + Prepared: to allow extended book-"Mark" feature. + + Prepared: to handle extended syntax highlighting. + ! More artifacts I must be missing. + 2010-01-18 09:14 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/hbqt.h * contrib/hbqt/hbqt_base.cpp diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index c5198d5658..13b95d2745 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -181,6 +181,7 @@ CLASS HbIde DATA oOpenedSources DATA resPath INIT hb_DirBase() + "resources" + hb_OsPathSeparator() DATA pathSep INIT hb_OsPathSeparator() + DATA cLastFileOpenPath INIT hb_DirBase() + "projects" DATA cWrkProject INIT "" DATA cWrkTheme INIT "" DATA cProcessInfo @@ -315,6 +316,8 @@ METHOD HbIde:create( cProjIni ) /* Restore Settings */ hbide_restSettings( Self ) + /* Again to be displayed in Statusbar */ + HbXbp_SetCodec( ::cWrkCodec ) /* Request Main Window to Appear on the Screen */ ::oDlg:Show() @@ -497,9 +500,9 @@ METHOD HbIde:execAction( cKey ) CASE cKey == "InsertExternalFile" ::oEM:insertText( cKey ) CASE cKey == "ZoomIn" - ::oEM:zoom( cKey ) + ::oEM:zoom( 1 ) CASE cKey == "ZoomOut" - ::oEM:zoom( cKey ) + ::oEM:zoom( 0 ) CASE cKey == "ToggleProjectTree" ::oDK:toggleLeftDocks() diff --git a/harbour/contrib/hbide/ideactions.prg b/harbour/contrib/hbide/ideactions.prg index c44f9a6df7..b459b79fd2 100644 --- a/harbour/contrib/hbide/ideactions.prg +++ b/harbour/contrib/hbide/ideactions.prg @@ -342,6 +342,9 @@ METHOD IdeActions:buildToolBar() oTBar:addItem( ::getAction( "TB_Invert" ), , , , , , "Invert" ) oTBar:addItem( ::getAction( "TB_MatchPairs" ), , , , , , "MatchPairs" ) oTBar:addItem( , , , , , nSep ) + oTBar:addItem( ::getAction( "ZoomIn" ), , , , , , "ZoomIn" ) + oTBar:addItem( ::getAction( "ZoomOut" ), , , , , , "ZoomOut" ) + oTBar:addItem( , , , , , nSep ) RETURN Self diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index 7da261e1d4..87dbcd8812 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -123,7 +123,7 @@ CLASS IdeEditsManager INHERIT IdeObject METHOD switchToReadOnly() METHOD convertSelection( cKey ) METHOD insertText( cKey ) - METHOD zoom( cKey ) + METHOD zoom( nKey ) METHOD printPreview() METHOD paintRequested( pPrinter ) METHOD setMark() @@ -578,14 +578,23 @@ METHOD IdeEditsManager:insertText( cKey ) /*----------------------------------------------------------------------*/ -METHOD IdeEditsManager:zoom( cKey ) +METHOD IdeEditsManager:zoom( nKey ) + LOCAL nPointSize, oEdit, qFont - IF empty( ::qCurEdit ) + IF empty( oEdit := ::getEditObjectCurrent() ) RETURN Self ENDIF - IF upper( cKey ) == "ZOOMIN" - ELSEIF upper( cKey ) == "ZOOMOUT" + qFont := QFont():configure( oEdit:qEdit:font() ) + qFont:setFamily( "Courier New" ) + qFont:setFixedPitch( .t. ) + nPointSize := qFont:pointSize() + nPointSize += iif( nKey == 1, 1, -1 ) + + IF nPointSize > 4 .AND. nPointSize < 37 + qFont:setPointSize( nPointSize ) + oEdit:qEdit:setFont( qFont ) + oEdit:qLineNos:setFont( qFont ) ENDIF RETURN Self @@ -724,6 +733,8 @@ CLASS IdeEditor INHERIT IdeObject DATA nnRow INIT -99 DATA qPoint INIT QPoint():new() + DATA qEvents + DATA qSlots METHOD new( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme ) METHOD create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme ) @@ -764,6 +775,8 @@ METHOD IdeEditor:new( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme ) METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme ) + ::qSlots := HBSlots():new() + DEFAULT oIde TO ::oIde DEFAULT cSourceFile TO ::sourceFile DEFAULT nPos TO ::nPos @@ -799,8 +812,13 @@ METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme ) ::qCoEdit := ::oEdit ::qDocument := QTextDocument():configure( ::qEdit:document() ) + #if 0 ::connect( ::qDocument, "blockCountChanged(int)" , {|o,p | ::exeEvent( 21, o, p ) } ) ::connect( ::qDocument, "contentsChange(int,int,int)", {|o,p,p1,p2| ::exeEvent( 22, o, p, p1, p2 ) } ) + #endif +hbide_dbg( 2001, ::qSlots:hbConnect( ::qDocument, "blockCountChanged(int)" , {|o,p | ::exeEvent( 21, o, p ) } ) ) + ::qSlots:hbConnect( ::qDocument, "contentsChange(int,int,int)", {|o,p,p1,p2| ::exeEvent( 22, o, p, p1, p2 ) } ) + IF ::cType != "U" ::qHiliter := ::oThemes:SetSyntaxHilighting( ::oEdit:qEdit, @::cTheme ) ENDIF @@ -1076,8 +1094,11 @@ CLASS IdeEdit INHERIT IdeObject DATA qLastCursor DATA qCursorMark + DATA qMarkUData INIT HBQTextBlockUserData():new() DATA aBookMarks INIT {} + DATA qSlots + METHOD new( oEditor, nMode ) METHOD create( oEditor, nMode ) METHOD destroy() @@ -1087,6 +1108,7 @@ CLASS IdeEdit INHERIT IdeObject METHOD highlightCurrentLine( oEdit ) METHOD setNewMark() METHOD gotoLastMark() + METHOD getUserDataState( qB ) ENDCLASS @@ -1215,7 +1237,8 @@ METHOD IdeEdit:exeEvent( nMode, oEdit, o, p, p1 ) SWITCH nMode CASE customContextMenuRequested - IF !empty( pAct := ::oEM:qContextMenu:exec_1( qEdit:mapToGlobal( p ) ) ) + pAct := ::oEM:qContextMenu:exec_1( qEdit:mapToGlobal( p ) ) + IF !hbqt_isEmptyQtPointer( pAct ) qAct := QAction():configure( pAct ) DO CASE CASE qAct:text() == "Split Horizontally" @@ -1283,7 +1306,8 @@ METHOD IdeEdit:exeEvent( nMode, oEdit, o, p, p1 ) /*----------------------------------------------------------------------*/ METHOD IdeEdit:highlightCurrentLine( oEdit ) - LOCAL nCurLine, nLastLine, qCursor, lModified, qBlock, qDoc, qEdit, qBlockFmt, lClear, qB + LOCAL nCurLine, nLastLine, qCursor, lModified, qBlock, qDoc + LOCAL qUData, qEdit, qBlockFmt, qB, lInvalidate qEdit := oEdit:qEdit qCursor := QTextCursor():configure( qEdit:textCursor() ) @@ -1297,14 +1321,19 @@ METHOD IdeEdit:highlightCurrentLine( oEdit ) IF !empty( oEdit:qLastCursor ) IF ( qB := QTextBlock():configure( oEdit:qLastCursor:block() ) ):isValid() - IF qB:userState() != 77 + IF ::getUserDataState( qB ) != 99 oEdit:qLastCursor:setBlockFormat( QTextBlockFormat():new() ) ENDIF ENDIF ENDIF IF ( qB := QTextBlock():configure( qCursor:block() ) ):isValid() - IF qB:userState() != 77 + 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 ) @@ -1326,42 +1355,62 @@ METHOD IdeEdit:highlightCurrentLine( oEdit ) oEdit:nLastLine := nCurLine oEdit:qLastCursor := qCursor ENDIF - lclear := 12 - hbide_justACall( qB, lclear ) + hbide_justACall( qB ) RETURN Self /*----------------------------------------------------------------------*/ METHOD IdeEdit:setNewMark() - LOCAL qBlockFmt, qTextBlock, qDoc, lModified, qUData + LOCAL qBlockFmt, qTextBlock, qDoc, lModified, nState + + qDoc := QTextDocument():configure( ::qEdit:document() ) + lModified := qDoc:isModified() IF empty( ::qCursorMark ) - qDoc := QTextDocument():configure( ::qEdit:document() ) - lModified := qDoc:isModified() - +hbide_dbg( ".................................. Set New Mark" ) ::qCursorMark := QTextCursor():configure( ::qEdit:textCursor() ) qTextBlock := QTextBlock():configure( ::qCursorMark:block() ) qBlockFmt := QTextBlockFormat():new() + qBlockFmt:setBackground( ::qBrushMark ) ::qCursorMark:setBlockFormat( qBlockFmt ) - qTextBlock:setUserState( 77 ) - qUData := HBQTextBlockUserData():new() - qUData:setData( 99 ) - qTextBlock:setUserData( qUData ) + ::qMarkUData := HBQTextBlockUserData():new() + ::qMarkUData:hbSetState( 99 ) + qTextBlock:setUserData( ::qMarkUData ) - qDoc:setModified( lModified ) ELSE - ::qCursorMark:setBlockFormat( QTextBlockFormat():new() ) - ::qCursorMark:pPtr := 0 - ::qCursorMark := NIL +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() ) + ::qCursorMark:pPtr := NIL // Should We ? + ::qCursorMark := NIL + ENDIF + ENDIF ENDIF - hbide_justACall( qTextBlock ) + + qDoc:setModified( lModified ) + RETURN Self /*----------------------------------------------------------------------*/ +METHOD IdeEdit:getUserDataState( qB ) + LOCAL qUData := HBQTextBlockUserData():configure( qB:userData() ) + + IF !empty( qUData:pPtr ) + RETURN qUData:hbState() + ENDIF + + RETURN -1 + +/*----------------------------------------------------------------------*/ + METHOD IdeEdit:gotoLastMark() IF !empty( ::qCursorMark ) diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index 94dd68c72e..87a8c2549c 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -116,9 +116,7 @@ FUNCTION hbide_execPopup( aPops, aPos, qParent ) qPoint := QPoint():new( aPos[ 1 ], aPos[ 2 ] ) pAct := qPop:exec_1( qPoint ) - - //IF !empty( qAct:pPtr ) .and. !empty( cAct := qAct:text() ) - IF !empty( pAct ) + IF !hbqt_isEmptyQtPointer( pAct ) qAct := QAction():configure( pAct ) cAct := qAct:text() FOR EACH a_ IN aPops diff --git a/harbour/contrib/hbide/ideobject.prg b/harbour/contrib/hbide/ideobject.prg index 38cb5f0c94..19b60d3b0e 100644 --- a/harbour/contrib/hbide/ideobject.prg +++ b/harbour/contrib/hbide/ideobject.prg @@ -110,6 +110,7 @@ CLASS IdeObject ACCESS cWrkCodec INLINE ::oIde:cWrkCodec ACCESS resPath INLINE ::oIde:resPath ACCESS pathSep INLINE ::oIde:pathSep + ACCESS cLastFileOpenPath INLINE ::oIde:cLastFileOpenPath ACCESS aProjects INLINE ::oIde:aProjects ACCESS aINI INLINE ::oIde:aINI diff --git a/harbour/contrib/hbide/idesources.prg b/harbour/contrib/hbide/idesources.prg index 3861a674c0..b7dbd5bbcd 100644 --- a/harbour/contrib/hbide/idesources.prg +++ b/harbour/contrib/hbide/idesources.prg @@ -427,7 +427,10 @@ METHOD IdeSourcesManager:selectSource( cMode, cFile, cTitle ) oDlg:center := .t. oDlg:fileFilters := { { "All Files" , "*.*" }, { "PRG Sources", "*.prg" }, { "C Sources" , "*.c" },; { "CPP Sources", "*.cpp" }, { "H Headers" , "*.h" }, { "CH Headers", "*.ch" } } - cFile := oDlg:open( , , .f. ) + cFile := oDlg:open( ::cLastFileOpenPath, , .f. ) + IF !empty( cFile ) + ::oIde:cLastFileOpenPath := cFile + ENDIF ELSEIF cMode == "openmany" oDlg:title := "Select Sources" @@ -435,7 +438,10 @@ METHOD IdeSourcesManager:selectSource( cMode, cFile, cTitle ) oDlg:defExtension:= 'prg' oDlg:fileFilters := { { "All Files" , "*.*" }, { "PRG Sources", "*.prg" }, { "C Sources" , "*.c" },; { "CPP Sources", "*.cpp" }, { "H Headers" , "*.h" }, { "CH Headers", "*.ch" } } - cFile := oDlg:open( , , .t. ) + cFile := oDlg:open( ::cLastFileOpenPath, , .t. ) + IF !empty( cFile ) .AND. !empty( cFile[ 1 ] ) + ::oIde:cLastFileOpenPath := cFile[ 1 ] + ENDIF ELSEIF cMode == "save" oDlg:title := iif( !hb_isChar( cTitle ), "Save as...", cTitle ) @@ -451,7 +457,7 @@ METHOD IdeSourcesManager:selectSource( cMode, cFile, cTitle ) Endif oDlg:fileFilters := { { "PRG Sources", "*.prg" }, { "C Sources", "*.c" }, { "CPP Sources", "*.cpp" }, ; - { "H Headers", "*.h" }, { "CH Headers", "*.ch" } } + { "H Headers", "*.h" }, { "CH Headers", "*.ch" } } cFile := oDlg:saveAs( cPath ) ELSE diff --git a/harbour/contrib/hbide/idethemes.prg b/harbour/contrib/hbide/idethemes.prg index c7501b0314..602961dc99 100644 --- a/harbour/contrib/hbide/idethemes.prg +++ b/harbour/contrib/hbide/idethemes.prg @@ -332,7 +332,7 @@ METHOD IdeThemes:setMultiLineCommentRule( qHiliter, cTheme ) LOCAL aAttr IF !empty( aAttr := ::getThemeAttribute( "CommentsAndRemarks", cTheme ) ) - qHiliter:setHBMultiLineCommentFormat( ::buildSyntaxFormat( aAttr ) ) + qHiliter:hbSetMultiLineCommentFormat( ::buildSyntaxFormat( aAttr ) ) ENDIF RETURN Self @@ -341,7 +341,7 @@ METHOD IdeThemes:setMultiLineCommentRule( qHiliter, cTheme ) METHOD IdeThemes:setSyntaxRule( qHiliter, cName, cPattern, aAttr ) - qHiliter:setHBRule( cName, cPattern, ::buildSyntaxFormat( aAttr ) ) + qHiliter:hbSetRule( cName, cPattern, ::buildSyntaxFormat( aAttr ) ) RETURN Self @@ -349,7 +349,7 @@ METHOD IdeThemes:setSyntaxRule( qHiliter, cName, cPattern, aAttr ) METHOD IdeThemes:setSyntaxFormat( qHiliter, cName, aAttr ) - qHiliter:setHBFormat( cName, ::buildSyntaxFormat( aAttr ) ) + qHiliter:hbSetFormat( cName, ::buildSyntaxFormat( aAttr ) ) // qHiliter:rehighlight() RETURN Self @@ -843,7 +843,7 @@ STATIC FUNCTION hbide_setSyntaxAttrbs( qHiliter, cPattern, cName, nR, nG, nB, lI ENDIF qFormat:setForeGround( QBrush():new( "QColor", QColor():new( nR, nG, nB ) ) ) - qHiliter:setHBRule( cName, cPattern, qFormat ) + qHiliter:hbSetRule( cName, cPattern, qFormat ) RETURN nil