diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 53af08d945..fe6447fb20 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,70 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-21 23:59 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbqt/generator/qt45.qtp + + contrib/hbqt/qth/HBQPlainTextEdit.qth + * contrib/hbqt/qth/QApplication.qth + * contrib/hbqt/qth/QPlainTextEdit.qth + + * contrib/hbqt/qtgui/filelist.mk + * contrib/hbqt/qtgui/QApplication.cpp + * contrib/hbqt/qtgui/QPlainTextEdit.cpp + + contrib/hbqt/qtgui/HBQPlainTextEdit.cpp + + contrib/hbqt/qtgui/THBQPlainTextEdit.prg + + * contrib/hbqt/filelist.mk + * contrib/hbqt/hbqt.h + * contrib/hbqt/hbqt_garbage.h + + * contrib/hbide/hbide.prg + * contrib/hbide/ideactions.prg + * contrib/hbide/idedocks.prg + * contrib/hbide/ideeditor.prg + * contrib/hbide/idemisc.prg + * contrib/hbide/ideobject.prg + * contrib/hbide/ideprojmanager.prg + * contrib/hbide/idesources.prg + + + Added HBQPlainTextEdit() class which implements some constructs + which were not possible in pure prg code. The underlying code has + been borrowed from TextEdit.c of QWriter - a work of + Gancov Kostya , a big thank you. The code has been + extensively formatted and changed to adopt to Harbour standards. + + The direct benefits by adopting this class are: + : + * Current line highlighting is absolutely ok now. + * Line numbers display is extremely fast and optimized. + * Book-marks are shown at the left of line-numbers. + * Parenthesis matching is absolutely delightful. + * To Upper/Lower implementation is accurate spanning many lines. + * Stream commenting is made possible. + * Book-marks management is smooth. + + In IDE book-marks are implemented in different way than + most IDE's offer. Here is the description: + * Click on "Toggle Mark" icon on the toolbar. + * A small dot will appear on the left of current line. + * Look at status-bar, a small colored pushbutton will appear. + * Navigate the document as usual. + * Click on the colored push button staying in statusbar. + * The editing cursor will stay at book-mark represented by + that colored button and current line will appear highlighted + with the same color as that of button. + * Navigate to another location and click again on "Toggle Mark" icon. + * A new dot and one more colored button will appear in the statusbar. + * You can create 6 book marks as such and all will have different colors. + * You can click on any of desired usage. + * To delete a book-mark click on the button then "Toggle Mark" + * One button at the right will disappear. + * All tabs will contain their own book-marks. + * And every split window will have its own. + * Navigating different tabs or split windows will rearrange the + buttons according to its own settings. + + ; QUESTION : Is it worth the effort to save book-marks settings for next session? + 2010-01-22 01:25 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbtip/sendmail.prg ! Applied set of HB_SENDMAIL() patches sent by Francesco Perillo: diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index 43dd659f45..47ea60abc3 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -200,10 +200,11 @@ CLASS HbIde DATA aComments INIT {} DATA aProjects INIT {} + DATA aMarkTBtns INIT array( 6 ) + METHOD new( cProjIni ) METHOD create( cProjIni ) METHOD destroy() - METHOD execAction( cKey ) METHOD setPosAndSizeByIni( qWidget, nPart ) METHOD setPosByIni( qWidget, nPart ) METHOD setSizeByIni( qWidget, nPart ) @@ -219,6 +220,12 @@ CLASS HbIde METHOD updateTitleBar() METHOD setCodec( cCodec ) + METHOD execAction( cKey ) + METHOD execProjectAction( cKey ) + METHOD execSourceAction( cKey ) + METHOD execEditorAction( cKey ) + METHOD execWindowsAction( cKey ) + ENDCLASS /*----------------------------------------------------------------------*/ @@ -403,132 +410,74 @@ METHOD HbIde:create( cProjIni ) /*----------------------------------------------------------------------*/ METHOD HbIde:execAction( cKey ) - LOCAL aPrj, cHbi, cTmp, n - DO CASE - CASE cKey == "Exit" + SWITCH cKey + CASE "Exit" PostAppEvent( xbeP_Close, NIL, NIL, ::oDlg ) + EXIT + CASE "NewProject" + CASE "LoadProject" + CASE "LaunchProject" + CASE "Build" + CASE "BuildLaunch" + CASE "Rebuild" + CASE "RebuildLaunch" + CASE "Compile" + CASE "CompilePPO" + CASE "Properties" + CASE "SelectProject" + CASE "CloseProject" + ::execProjectAction( cKey ) + EXIT + CASE "New" + CASE "Open" + CASE "Save" + CASE "SaveAs" + CASE "SaveAll" + CASE "SaveExit" + CASE "Revert" + CASE "Close" + CASE "CloseAll" + CASE "CloseOther" + ::execSourceAction( cKey ) + EXIT + CASE "Print" + CASE "Undo" + CASE "Redo" + CASE "Cut" + CASE "Copy" + CASE "Paste" + CASE "SelectAll" + CASE "DuplicateLine" + CASE "BlockComment" + CASE "StreamComment" + CASE "switchReadOnly" + CASE "Find" + CASE "SetMark" + CASE "GotoMark" + CASE "Goto" + CASE "ToUpper" + CASE "ToLower" + CASE "Invert" + CASE "MatchPairs" + CASE "InsertSeparator" + CASE "InsertDateTime" + CASE "InsertRandomName" + CASE "InsertExternalFile" + CASE "ZoomIn" + CASE "ZoomOut" + CASE "FormatBraces" + CASE "RemoveTabs" + CASE "RemoveTrailingSpaces" + ::execEditorAction( cKey ) + EXIT + CASE "ToggleProjectTree" + CASE "ToggleBuildInfo" + CASE "ToggleFuncList" + ::execWindowsAction( cKey ) + EXIT - CASE cKey == "NewProject" - ::oPM:loadProperties( , .t., .t., .t. ) - CASE cKey == "LoadProject" - ::oPM:loadProperties( , .f., .f., .t. ) - CASE cKey == "LaunchProject" - ::oPM:launchProject() - CASE cKey == "Build" - ::oPM:buildProject( '', .F., .F. ) - CASE cKey == "BuildLaunch" - ::oPM:buildProject( '', .T., .F. ) - CASE cKey == "Rebuild" - ::oPM:buildProject( '', .F., .T. ) - CASE cKey == "RebuildLaunch" - ::oPM:buildProject( '', .T., .T. ) - CASE cKey == "Compile" - // - CASE cKey == "CompilePPO" - ::oPM:buildProject( '', .F., .F., .T., .T. ) - CASE cKey == "Properties" - IF Empty( ::cWrkProject ) - MsgBox( 'No active project detected' ) - ENDIF - cTmp := ::oPM:getCurrentProject() - IF ( n := ascan( ::aProjects, {|e_| e_[ 3, PRJ_PRP_PROPERTIES, 2, E_oPrjTtl ] == cTmp } ) ) > 0 - aPrj := ::aProjects[ n, 3 ] - cHbi := aPrj[ PRJ_PRP_PROPERTIES, 2, PRJ_PRP_LOCATION ] + ::pathSep + ; - aPrj[ PRJ_PRP_PROPERTIES, 2, PRJ_PRP_OUTPUT ] + ".hbi" - - ::oPM:loadProperties( cHbi, .f., .t., .t. ) - ELSE - MsgBox( 'Invalid project: ' + cTmp ) - ENDIF - CASE cKey == "SelectProject" - ::oPM:selectCurrentProject() - CASE cKey == "CloseProject" - ::oPM:closeProject() - - CASE cKey == "New" - ::oSM:editSource( '' ) - CASE cKey == "Open" - ::oSM:openSource() - CASE cKey == "Save" - ::oSM:saveSource( ::oEM:getTabCurrent(), .f., .f. ) - CASE cKey == "SaveAs" - ::oSM:saveSource( ::oEM:getTabCurrent(), .t., .t. ) - CASE cKey == "SaveAll" - ::oSM:saveAllSources() - CASE cKey == "SaveExit" - ::oSM:saveAndExit() - CASE cKey == "Revert" - ::oSM:RevertSource() - CASE cKey == "Close" - ::oSM:closeSource() - CASE cKey == "CloseAll" - ::oSM:closeAllSources() - CASE cKey == "CloseOther" - ::oSM:closeAllOthers() - - CASE cKey == "Print" - ::oEM:printPreview() - CASE cKey == "Undo" - ::oEM:undo() - CASE cKey == "Redo" - ::oEM:redo() - CASE cKey == "Cut" - ::oEM:cut() - CASE cKey == "Copy" - ::oEM:copy() - CASE cKey == "Paste" - ::oEM:paste() - CASE cKey == "SelectAll" - ::oEM:selectAll() - - CASE cKey == "switchReadOnly" - ::oEM:switchToReadOnly() - CASE cKey == "Find" - IF !Empty( ::qCurEdit ) - ::oFR:show() - ENDIF - CASE cKey == "SetMark" - ::oEM:setMark() - CASE cKey == "GotoMark" - ::oEM:gotoMark() - CASE cKey == "Goto" - ::oEM:goTo() - CASE cKey == "ToUpper" - ::oEM:convertSelection( cKey ) - CASE cKey == "ToLower" - ::oEM:convertSelection( cKey ) - CASE cKey == "Invert" - ::oEM:convertSelection( cKey ) - CASE cKey == "MatchPairs" - // - CASE cKey == "InsertSeparator" - ::oEM:insertSeparator() - CASE cKey == "InsertDateTime" - ::oEM:insertText( cKey ) - CASE cKey == "InsertRandomName" - ::oEM:insertText( cKey ) - CASE cKey == "InsertExternalFile" - ::oEM:insertText( cKey ) - CASE cKey == "ZoomIn" - ::oEM:zoom( 1 ) - CASE cKey == "ZoomOut" - ::oEM:zoom( 0 ) - - CASE cKey == "FormatBraces" - ::oEM:formatBraces() - CASE cKey == "RemoveTabs" - ::oEM:removeTabs() - CASE cKey == "RemoveTrailingSpaces" - ::oEM:removeTrailingSpaces() - - CASE cKey == "ToggleProjectTree" - ::oDK:toggleLeftDocks() - CASE cKey == "ToggleBuildInfo" - ::oDK:toggleBottomDocks() - CASE cKey == "ToggleFuncList" - ::oDK:toggleRightDocks() - ENDCASE + ENDSWITCH ::manageFocusInEditor() @@ -536,6 +485,197 @@ METHOD HbIde:execAction( cKey ) /*----------------------------------------------------------------------*/ +METHOD HbIde:execEditorAction( cKey ) + + SWITCH cKey + CASE "Print" + ::oEM:printPreview() + EXIT + CASE "Undo" + ::oEM:undo() + EXIT + CASE "Redo" + ::oEM:redo() + EXIT + CASE "Cut" + ::oEM:cut() + EXIT + CASE "Copy" + ::oEM:copy() + EXIT + CASE "Paste" + ::oEM:paste() + EXIT + CASE "SelectAll" + ::oEM:selectAll() + EXIT + CASE "DuplicateLine" + ::oEM:duplicateLine() + EXIT + CASE "BlockComment" + ::oEM:blockComment() + EXIT + CASE "StreamComment" + ::oEM:streamComment() + EXIT + CASE "switchReadOnly" + ::oEM:switchToReadOnly() + EXIT + CASE "Find" + IF !Empty( ::qCurEdit ) + ::oFR:show() + ENDIF + EXIT + CASE "SetMark" + ::oEM:setMark() + EXIT + CASE "GotoMark" + ::oEM:gotoMark() + EXIT + CASE "Goto" + ::oEM:goTo() + EXIT + CASE "ToUpper" + ::oEM:convertSelection( cKey ) + EXIT + CASE "ToLower" + ::oEM:convertSelection( cKey ) + EXIT + CASE "Invert" + ::oEM:convertSelection( cKey ) + EXIT + CASE "MatchPairs" + // + EXIT + CASE "InsertSeparator" + ::oEM:insertSeparator() + EXIT + CASE "InsertDateTime" + ::oEM:insertText( cKey ) + EXIT + CASE "InsertRandomName" + ::oEM:insertText( cKey ) + EXIT + CASE "InsertExternalFile" + ::oEM:insertText( cKey ) + EXIT + CASE "ZoomIn" + ::oEM:zoom( 1 ) + EXIT + CASE "ZoomOut" + ::oEM:zoom( 0 ) + EXIT + CASE "FormatBraces" + ::oEM:formatBraces() + EXIT + CASE "RemoveTabs" + ::oEM:removeTabs() + EXIT + CASE "RemoveTrailingSpaces" + ::oEM:removeTrailingSpaces() + EXIT + ENDSWITCH + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD HbIde:execSourceAction( cKey ) + SWITCH cKey + CASE "New" + ::oSM:editSource( '' ) + EXIT + CASE "Open" + ::oSM:openSource() + EXIT + CASE "Save" + ::oSM:saveSource( ::oEM:getTabCurrent(), .f., .f. ) + EXIT + CASE "SaveAs" + ::oSM:saveSource( ::oEM:getTabCurrent(), .t., .t. ) + EXIT + CASE "SaveAll" + ::oSM:saveAllSources() + EXIT + CASE "SaveExit" + ::oSM:saveAndExit() + EXIT + CASE "Revert" + ::oSM:RevertSource() + EXIT + CASE "Close" + ::oSM:closeSource() + EXIT + CASE "CloseAll" + ::oSM:closeAllSources() + EXIT + CASE "CloseOther" + ::oSM:closeAllOthers() + EXIT + ENDSWITCH + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD HbIde:execProjectAction( cKey ) + SWITCH cKey + CASE "NewProject" + ::oPM:loadProperties( , .t., .t., .t. ) + EXIT + CASE "LoadProject" + ::oPM:loadProperties( , .f., .f., .t. ) + EXIT + CASE "LaunchProject" + ::oPM:launchProject() + EXIT + CASE "Build" + ::oPM:buildProject( '', .F., .F. ) + EXIT + CASE "BuildLaunch" + ::oPM:buildProject( '', .T., .F. ) + EXIT + CASE "Rebuild" + ::oPM:buildProject( '', .F., .T. ) + EXIT + CASE "RebuildLaunch" + ::oPM:buildProject( '', .T., .T. ) + EXIT + CASE "Compile" + // + EXIT + CASE "CompilePPO" + ::oPM:buildProject( '', .F., .F., .T., .T. ) + EXIT + CASE "Properties" + ::oPM:getProperties() + EXIT + CASE "SelectProject" + ::oPM:selectCurrentProject() + EXIT + CASE "CloseProject" + ::oPM:closeProject() + EXIT + ENDSWITCH + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD HbIde:execWindowsAction( cKey ) + + SWITCH cKey + CASE "ToggleProjectTree" + ::oDK:toggleLeftDocks() + EXIT + CASE "ToggleBuildInfo" + ::oDK:toggleBottomDocks() + EXIT + CASE "ToggleFuncList" + ::oDK:toggleRightDocks() + EXIT + ENDSWITCH + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD HbIde:setPosAndSizeByIni( qWidget, nPart ) LOCAL aRect diff --git a/harbour/contrib/hbide/ideactions.prg b/harbour/contrib/hbide/ideactions.prg index 1ad3fd9076..c79b4fd670 100644 --- a/harbour/contrib/hbide/ideactions.prg +++ b/harbour/contrib/hbide/ideactions.prg @@ -197,7 +197,7 @@ METHOD IdeActions:loadActions() aadd( aAct, { "TB_SelectionMode" , "Toggle Selection Mode" , "stream" , "" , "No", "Yes" } ) aadd( aAct, { "TB_Find" , "~Find / Replace" , "find" , "" , "No", "Yes" } ) aadd( aAct, { "TB_Search" , "Search" , "search" , "" , "No", "Yes" } ) - aadd( aAct, { "TB_SetMark" , "Set Mark" , "placeremovemark", "" , "No", "Yes" } ) + aadd( aAct, { "TB_SetMark" , "Toggle Mark" , "placeremovemark", "" , "No", "Yes" } ) aadd( aAct, { "TB_GotoMark" , "Goto Mark" , "gotomark" , "" , "No", "Yes" } ) aadd( aAct, { "TB_Goto" , "~Goto Line" , "gotoline" , "" , "No", "Yes" } ) aadd( aAct, { "TB_ToUpper" , "To Upper" , "toupper" , "" , "No", "Yes" } ) @@ -287,8 +287,11 @@ METHOD IdeActions:loadActions() aadd( aAct, { "RebuildLaunchQt" , "Rebuild and Launch" , "rebuildlaunch" , "" , "No", "Yes" } ) aadd( aAct, { "RemoveTabs" , "Replace Tabs with Spaces" , "RemoveTabs" , "" , "No", "Yes" } ) - aadd( aAct, { "RemoveTrailingSpaces" , "Remove Trailing Spaces" , "RemoveTrailingSpaces", "" , "No", "Yes" } ) + aadd( aAct, { "RemoveTrailingSpaces" , "Remove Trailing Spaces" , "RemoveTrailingSpaces", "", "No", "Yes" } ) aadd( aAct, { "FormatBraces" , "Format Braces" , "FormatBraces" , "" , "No", "Yes" } ) + aadd( aAct, { "DuplicateLine" , "Duplicate Current Line" , "DuplicateLine" , "^D" , "No", "Yes" } ) + aadd( aAct, { "StreamComment" , "Stream Comment" , "StreamComment" , "Sh+^Q", "No", "Yes" } ) + aadd( aAct, { "BlockComment" , "Block Comment" , "BlockComment" , "Sh+^/", "No", "Yes" } ) RETURN aAct @@ -339,7 +342,7 @@ METHOD IdeActions:buildToolBar() oTBar:addItem( ::getAction( "TB_Search" ), , , , , , "Search" ) oTBar:addItem( , , , , , nSep ) oTBar:addItem( ::getAction( "TB_SetMark" ), , , , , , "SetMark" ) - oTBar:addItem( ::getAction( "TB_GotoMark" ), , , , , , "GotoMark" ) + * oTBar:addItem( ::getAction( "TB_GotoMark" ), , , , , , "GotoMark" ) oTBar:addItem( ::getAction( "TB_Goto" ), , , , , , "Goto" ) oTBar:addItem( , , , , , nSep ) oTBar:addItem( ::getAction( "TB_ToUpper" ), , , , , , "ToUpper" ) @@ -448,7 +451,10 @@ METHOD IdeActions:buildMainMenu() oSubMenu:addItem( { ::getAction( "Find" ), {|| oIde:execAction( "Find" ) } } ) oSubMenu:addItem( { ::getAction( "Goto" ), {|| oIde:execAction( "Goto" ) } } ) hbide_menuAddSep( oSubMenu ) - + oSubMenu:addItem( { ::getAction( "DuplicateLine" ), {|| oIde:execAction( "DuplicateLine" ) } } ) + oSubMenu:addItem( { ::getAction( "StreamComment" ), {|| oIde:execAction( "StreamComment" ) } } ) + oSubMenu:addItem( { ::getAction( "BlockComment" ), {|| oIde:execAction( "BlockComment" ) } } ) + hbide_menuAddSep( oSubMenu ) oSubMenu2 := XbpMenu():new( oSubMenu ):create() oSubMenu2:addItem( { ::getAction( "InsertSeparator" ), {|| oIde:execAction( "InsertSeparator" ) } } ) hbide_menuAddSep( oSubMenu ) @@ -457,7 +463,6 @@ METHOD IdeActions:buildMainMenu() oSubMenu2:addItem( { ::getAction( "InsertExternalFile" ), {|| oIde:execAction( "InsertExternalFile" ) } } ) oMenuBar:addItem( { oSubMenu2, _T( "~Insert" ) } ) - hbide_menuAddSep( oSubMenu ) oSubMenu2 := XbpMenu():new( oSubMenu ):create() oSubMenu2:addItem( { ::getAction( "RemoveTabs" ), {|| oIde:execAction( "RemoveTabs" ) } } ) hbide_menuAddSep( oSubMenu ) diff --git a/harbour/contrib/hbide/idedocks.prg b/harbour/contrib/hbide/idedocks.prg index 3145864903..196c777e98 100644 --- a/harbour/contrib/hbide/idedocks.prg +++ b/harbour/contrib/hbide/idedocks.prg @@ -93,6 +93,7 @@ CLASS IdeDockS INHERIT IdeObject METHOD toggleRightDocks() METHOD toggleBottomDocks() METHOD setStatusText( nPart, xValue ) + METHOD getMarkWidget( nIndex ) ENDCLASS @@ -398,6 +399,7 @@ METHOD IdeDocks:outputDoubleClicked( lSelected ) /*----------------------------------------------------------------------*/ METHOD IdeDocks:buildStatusBar() + LOCAL i ::oIde:oSBar := XbpStatusBar():new() ::oSBar:create( ::oDlg, , { 0,0 }, { ::oDlg:currentSize()[ 1 ], 30 } ) @@ -418,10 +420,30 @@ METHOD IdeDocks:buildStatusBar() ::oSBar:addItem( "", , , , "Codec" ):oWidget:setMinimumWidth( 20 ) ::oSBar:addItem( "", , , , "Project" ):oWidget:setMinimumWidth( 20 ) + FOR i := 1 TO 6 + ::oSBar:oWidget:addWidget( ::getMarkWidget( i ) ) + NEXT RETURN Self /*----------------------------------------------------------------------*/ +METHOD IdeDocks:getMarkWidget( nIndex ) + LOCAL aColors := { "rgb( 255,255,127 )", "rgb( 175,175,255 )", "rgb( 255,175,175 )", ; + "rgb( 175,255,175 )", "rgb( 255,190,125 )", "rgb( 175,255,255 )" } + + ::oIde:aMarkTBtns[ nIndex ] := QToolButton():new() + + ::oIde:aMarkTBtns[ nIndex ]:setMaximumHeight( 12 ) + ::oIde:aMarkTBtns[ nIndex ]:setMaximumWidth( 12 ) + ::oIde:aMarkTBtns[ nIndex ]:setStyleSheet( "background-color: " + aColors[ nIndex ] + ";" ) + ::oIde:aMarkTBtns[ nIndex ]:hide() + + ::connect( ::oIde:aMarkTBtns[ nIndex ], "clicked()", {|| ::oEM:gotoMark( nIndex ) } ) + + RETURN ::oIde:aMarkTBtns[ nIndex ] + +/*----------------------------------------------------------------------*/ + METHOD IdeDocks:toggleLeftDocks() IF ::lProjTreeVisible diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index e8ed6efa06..fff602d108 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -128,12 +128,15 @@ CLASS IdeEditsManager INHERIT IdeObject METHOD printPreview() METHOD paintRequested( pPrinter ) METHOD setMark() - METHOD gotoMark() + METHOD gotoMark( nIndex ) METHOD goto() METHOD formatBraces() METHOD removeTabs() METHOD RemoveTrailingSpaces() METHOD getSelectedText() + METHOD duplicateLine() + METHOD streamComment() + METHOD blockComment() ENDCLASS @@ -432,6 +435,7 @@ METHOD IdeEditsManager:setSourceVisibleByIndex( nIndex ) /* nIndex is 0 based */ IF ::qTabWidget:count() == 0 .OR. nIndex >= ::qTabWidget:count() nIndex := 0 ENDIF + ::qTabWidget:setCurrentIndex( nIndex ) ::getEditorByIndex( nIndex ):setDocumentProperties() @@ -487,6 +491,33 @@ METHOD IdeEditsManager:selectAll() /*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:duplicateLine() + LOCAL qEdit + IF !empty( qEdit := ::getEditCurrent() ) + qEdit:duplicateLine() + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEditsManager:streamComment() + LOCAL qEdit + IF !empty( qEdit := ::getEditCurrent() ) + qEdit:streamComment() + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEditsManager:blockComment() + LOCAL qEdit + IF !empty( qEdit := ::getEditCurrent() ) + qEdit:blockComment() + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeEditsManager:switchToReadOnly() IF !empty( ::qCurEdit ) ::qCurEdit:setReadOnly( !( ::qCurEdit:isReadOnly() ) ) @@ -497,38 +528,20 @@ METHOD IdeEditsManager:switchToReadOnly() /*----------------------------------------------------------------------*/ METHOD IdeEditsManager:convertSelection( cKey ) - LOCAL cBuffer, i, s, nLen, c, nB, nL, qCursor + LOCAL oEdit - IF !empty( ::qCurEdit ) - qCursor := QTextCursor():configure( ::qCurEdit:textCursor() ) - IF qCursor:hasSelection() .and. !empty( cBuffer := qCursor:selectedText() ) - DO CASE - CASE cKey == "ToUpper" - cBuffer := upper( cBuffer ) - CASE cKey == "ToLower" - cBuffer := lower( cBuffer ) - CASE cKey == "Invert" - s := "" - nLen := len( cBuffer ) - FOR i := 1 TO nLen - c := substr( cBuffer, i, 1 ) - s += iif( isUpper( c ), lower( c ), upper( c ) ) - NEXT - cBuffer := s - ENDCASE - nL := len( cBuffer ) - nB := qCursor:position() - nL - - qCursor:beginEditBlock() - qCursor:removeSelectedText() - qCursor:insertText( cBuffer ) - qCursor:setPosition( nB ) - qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nL ) - - ::qCurEdit:setTextCursor( qCursor ) - - qCursor:endEditBlock() - ENDIF + IF !empty( oEdit := ::getEditObjectCurrent() ) + SWITCH cKey + CASE "ToUpper" + oEdit:caseUpper() + EXIT + CASE "ToLower" + oEdit:caseLower() + EXIT + CASE "Invert" + oEdit:caseInvert() + EXIT + ENDSWITCH ENDIF RETURN Self @@ -730,11 +743,9 @@ METHOD IdeEditsManager:zoom( nKey ) qFont:setPointSize( nPointSize ) oEdit:qEdit:setFont( qFont ) - oEdit:qLineNos:setFont( qFont ) FOR EACH oEdit IN oEditor:aEdits oEdit:qEdit:setFont( qFont ) - oEdit:qLineNos:setFont( qFont ) NEXT ENDIF RETURN Self @@ -791,11 +802,11 @@ METHOD IdeEditsManager:setMark() /*----------------------------------------------------------------------*/ -METHOD IdeEditsManager:gotoMark() +METHOD IdeEditsManager:gotoMark( nIndex ) LOCAL oEdit IF !empty( oEdit := ::getEditObjectCurrent() ) - oEdit:gotoLastMark() + oEdit:gotoMark( nIndex ) ENDIF RETURN Self @@ -879,13 +890,13 @@ CLASS IdeEditor INHERIT IdeObject DATA aSplits INIT {} DATA qHLayout - DATA qLineNos DATA qLabel DATA nnRow INIT -99 DATA qPoint INIT QPoint():new() DATA qEvents DATA qSlots + DATA qMarkLayoutOld METHOD new( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme ) METHOD create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme ) @@ -899,7 +910,6 @@ CLASS IdeEditor INHERIT IdeObject METHOD dispEditInfo( qEdit ) METHOD setTabImage( qEdit ) METHOD applyTheme( cTheme ) - METHOD findLastIndent() ENDCLASS @@ -992,198 +1002,32 @@ hbide_dbg( 2001, ::qSlots:hbConnect( ::qDocument, "blockCountChanged(int)" /*----------------------------------------------------------------------*/ -FUNCTION hbide_isHarbourKeyword( cWord ) - LOCAL b_:= { 'function','return','static','local','default', ; - 'if','else','elseif','endif','end', ; - 'docase','case','endcase','otherwise', ; - 'do','while','exit',; - 'for','each','next','step','to',; - 'class','endclass','method','data','var','destructor','inline','assign','access',; - 'inherit','init','create','virtual','message',; - 'begin','sequence','try','catch','always','recover','hb_symbol_unused', ; - 'error','handler' } - - cWord := lower( cWord ) - - RETURN ascan( b_, {|e| e == cWord } ) > 0 - -/*----------------------------------------------------------------------*/ - -FUNCTION hbide_isIndentableKeyword( cWord ) - LOCAL b_:= { 'function',; - 'if','else','elseif', ; - 'docase','case','otherwise', ; - 'do','while',; - 'for',; - 'class','method',; - 'begin','sequence','try','catch','always','recover','finally' } - - cWord := lower( cWord ) - - RETURN ascan( b_, {|e| e == cWord } ) > 0 - -/*----------------------------------------------------------------------*/ - -FUNCTION hbide_isStartingKeyword( cWord ) - LOCAL b_:= { 'function','method' } - - cWord := lower( cWord ) - - RETURN ascan( b_, {|e| e == cWord } ) > 0 - -/*----------------------------------------------------------------------*/ - -FUNCTION hbide_handlePreviousWord( qEdit ) - LOCAL qCursor, qTextBlock, cText, nPos, cWord, nB, nL - - qCursor := QTextCursor():configure( qEdit:textCursor() ) - qTextBlock := QTextBlock():configure( qCursor:block() ) - cText := qTextBlock:text() - nPos := qCursor:columnNumber() - cWord := hbide_getPreviousWord( cText, nPos + 1 ) - - IF !empty( cWord ) - nL := len( cWord + " " ) - nB := qCursor:position() - nL - - IF hbide_isHarbourKeyword( cWord ) - qCursor:beginEditBlock() - qCursor:setPosition( nB ) - qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nL ) - qCursor:removeSelectedText() - qCursor:insertText( upper( cWord ) + " " ) - - qEdit:setTextCursor( qCursor ) - qCursor:endEditBlock() - ENDIF - - 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 - ENDIF - ENDIF - RETURN .t. - -/*----------------------------------------------------------------------*/ - -FUNCTION hbide_getPreviousWord( cText, nPos ) - LOCAL cWord, n - - cText := alltrim( substr( cText, 1, nPos ) ) - IF ( n := rat( " ", cText ) ) > 0 - cWord := substr( cText, n + 1 ) - ELSE - cWord := cText - ENDIF - - RETURN cWord - -/*----------------------------------------------------------------------*/ - -FUNCTION hbide_getFirstWord( cText ) - LOCAL cWord, n - - cText := alltrim( cText ) - IF ( n := at( " ", cText ) ) > 0 - cWord := left( cText, n-1 ) - ELSE - cWord := cText - ENDIF - - RETURN cWord - -/*----------------------------------------------------------------------*/ - -FUNCTION hbide_getFrontSpacesAndWord( cText, cWord ) - LOCAL n := 0 - - DO WHILE .t. - IF substr( cText, ++n, 1 ) != " " - EXIT - ENDIF - ENDDO - n-- - - cWord := hbide_getFirstWord( cText ) - - RETURN n - -/*----------------------------------------------------------------------*/ - -METHOD IdeEditor:findLastIndent() - LOCAL qCursor, qTextBlock, cText, cWord - LOCAL nSpaces := 0 - - qCursor := QTextCursor():configure( ::qCqEdit:textCursor() ) - qTextBlock := QTextBlock():configure( qCursor:block() ) - - DO WHILE .t. - IF !( qTextBlock:isValid() ) - EXIT - ENDIF - IF !empty( cText := qTextBlock:text() ) - nSpaces := hbide_getFrontSpacesAndWord( cText, @cWord ) - IF !empty( cWord ) - IF hbide_isIndentableKeyword( cWord ) - nSpaces += ::nTabSpaces - ENDIF - EXIT - ENDIF - ENDIF - qTextBlock := QTextBlock():configure( qTextBlock:previous() ) - ENDDO - - RETURN nSpaces - -/*----------------------------------------------------------------------*/ - METHOD IdeEditor:exeEvent( nMode, o, p, p1, p2 ) - LOCAL qCursor, qChar, nSpaces + LOCAL qChar HB_SYMBOL_UNUSED( o ) HB_SYMBOL_UNUSED( p1 ) SWITCH nMode + CASE blockCountChanged - hbide_dbg( "blockCountChanged(int)", p ) + //hbide_dbg( "blockCountChanged(int)", p ) ::nPrevBlocks := ::nBlocks ::nBlocks := p - // - IF ::qCoEdit:nPrevLineNo <= 0 .OR. ::qCoEdit:nCurLineNo == ::qCoEdit:nPrevLineNo + 1 - IF ( nSpaces := ::findLastIndent() ) > 0 - qCursor := QTextCursor():configure( ::qCqEdit:textCursor() ) - qCursor:insertText( space( nSpaces ) ) - ENDIF - ENDIF - ::qCoEdit:nPrevLineNo := ::qCoEdit:nCurLineNo - EXIT + CASE contentsChange + //hbide_dbg( "contentsChange()", p, p1, p2 ) IF p2 == 1 /* Characters Added */ qChar := QChar():configure( ::qDocument:characterAt( p ) ) SWITCH qChar:toAscii() - CASE 9 /* Tab Key */ - qCursor := QTextCursor():configure( ::qCqEdit:textCursor() ) - qCursor:deletePreviousChar() - qCursor:insertText( ::cTabSpaces ) - EXIT CASE 32 /* Space Key */ - hbide_handlePreviousWord( ::qCqEdit ) + ::qCoEdit:lUpdatePrevWord := .t. EXIT ENDSWITCH ENDIF EXIT + ENDSWITCH RETURN Nil @@ -1197,10 +1041,8 @@ METHOD IdeEditor:relay( oEdit ) FOR EACH oEdt IN ::aEdits ::qLayout:removeItem( oEdt:qHLayout ) // - oEdt:qHLayout:removeWidget( oEdt:qLineNos ) oEdt:qHLayout:removeWidget( oEdt:qEdit ) oEdt:qHLayout := QHBoxLayout():new() - oEdt:qHLayout:addWidget( oEdt:qLineNos ) oEdt:qHLayout:addWidget( oEdt:qEdit ) NEXT @@ -1245,12 +1087,13 @@ METHOD IdeEditor:split( nOrient, oEditP ) METHOD IdeEditor:destroy() LOCAL n, oEdit - +hbide_dbg( "IdeEditor:destroy()", 0 ) ::disconnect( ::qDocument, "blockCountChanged(int)" ) ::disconnect( ::qDocument, "contentsChange(int,int,int)" ) ::qCqEdit := NIL - ::qEdit := NIL + ::qCoEdit := NIL + ::qEdit := NIL DO WHILE len( ::aEdits ) > 0 oEdit := ::aEdits[ 1 ] hb_adel( ::aEdits, 1, .t. ) @@ -1290,7 +1133,7 @@ METHOD IdeEditor:destroy() ::oIde:lDockRVisible := .f. ENDIF ENDIF - +hbide_dbg( "IdeEditor:destroy()", 1 ) RETURN Self /*----------------------------------------------------------------------*/ @@ -1301,6 +1144,7 @@ METHOD IdeEditor:setDocumentProperties() qCursor := QTextCursor():configure( ::qEdit:textCursor() ) IF !( ::lLoaded ) /* First Time */ + ::qEdit:clear() ::qEdit:setPlainText( hb_memoRead( ::sourceFile ) ) qCursor:setPosition( ::nPos ) ::qEdit:setTextCursor( qCursor ) @@ -1338,6 +1182,7 @@ METHOD IdeEditor:activateTab( mp1, mp2, oXbp ) IF !empty( oEdit := ::oEM:getEditorByTabObject( oXbp ) ) oEdit:setDocumentProperties() + oEdit:qCoEdit:relayMarkButtons() ENDIF RETURN Self @@ -1440,7 +1285,6 @@ CLASS IdeEdit INHERIT IdeObject DATA qEdit DATA qHLayout - DATA qLineNos DATA nOrient INIT 0 DATA nMode INIT 0 @@ -1464,8 +1308,9 @@ CLASS IdeEdit INHERIT IdeObject DATA aBookMarks INIT {} DATA qSlots - DATA lCursorPosChanging INIT .F. DATA lModified INIT .F. + DATA lIndentIt INIT .f. + DATA lUpdatePrevWord INIT .f. METHOD new( oEditor, nMode ) METHOD create( oEditor, nMode ) @@ -1474,12 +1319,17 @@ CLASS IdeEdit INHERIT IdeObject METHOD execEvent( nMode, nEvent, p ) METHOD connectEditSlots( oEdit ) METHOD disConnectEditSlots( oEdit ) - METHOD highlightCurrentLine() + METHOD setNewMark() - METHOD gotoLastMark() - METHOD getUserDataState( qB ) - METHOD deHighlightPreviousLine() + METHOD gotoMark( nIndex ) METHOD duplicateLine() + METHOD blockComment() + METHOD streamComment() + METHOD caseUpper() + METHOD caseLower() + METHOD caseInvert() + METHOD findLastIndent() + METHOD reLayMarkButtons() ENDCLASS @@ -1503,54 +1353,73 @@ METHOD IdeEdit:create( oEditor, nMode ) ::nMode := nMode ::oIde := ::oEditor:oIde - ::qEdit := QPlainTextEdit():new() + ::qEdit := HBQPlainTextEdit():new() // ::qEdit:setLineWrapMode( QTextEdit_NoWrap ) ::qEdit:setFont( ::oFont:oWidget ) ::qEdit:ensureCursorVisible() ::qEdit:setContextMenuPolicy( Qt_CustomContextMenu ) - + ::qEdit:setSpaces( ::nTabSpaces ) ::qEdit:installEventFilter( ::pEvents ) + ::qEdit:highlightCurrentLine( .t. ) /* Via user-setup */ + Qt_Events_Connect( ::pEvents, ::qEdit, QEvent_KeyPress, {|o,p| ::execEvent( 1, QEvent_KeyPress, p, o ) } ) Qt_Events_Connect( ::pEvents, ::qEdit, QEvent_Wheel , {|o,p| ::execEvent( 1, QEvent_Wheel , p, o ) } ) ::qHLayout := QHBoxLayout():new() ::qHLayout:setSpacing( 0 ) - ::qLineNos := QTextEdit():new() - ::qLineNos:setTextBackgroundColor( QColor():new( 240,240,240 ) ) - ::qLineNos:setAcceptRichText( .t. ) - ::qLineNos:setAlignment( Qt_AlignRight ) - ::qLineNos:setVerticalScrollBarPolicy( Qt_ScrollBarAlwaysOff ) - ::qLineNos:setHorizontalScrollBarPolicy( Qt_ScrollBarAlwaysOff ) - ::qLineNos:setFrameStyle( QFrame_NoFrame ) - ::qLineNos:setReadOnly( .t. ) - ::qLineNos:setLineWrapMode( QTextEdit_NoWrap ) - ::qLineNos:setFont( ::oFont:oWidget ) - ::qLineNos:setContextMenuPolicy( Qt_NoContextMenu ) - ::qLineNos:setMinimumWidth( EDT_LINNO_WIDTH ) - ::qLineNos:setMaximumWidth( EDT_LINNO_WIDTH ) - ::qLineNos:setStyleSheet( "background-color: rgb( 240,240,240 );" ) - // - ::qLineNos:installEventFilter( ::pEvents ) - Qt_Events_Connect( ::pEvents, ::qLineNos, QEvent_Wheel , {|o,p| ::execEvent( 2, QEvent_Wheel , p, o ) } ) - // - ::qHLayout:addWidget( ::qLineNos ) - ::qHLayout:addWidget( ::qEdit ) - - #if 0 - ::qActionTab := QAction():new( ::qEdit ) - ::qActionTab:setText( "Editor Tab" ) - ::qActionTab:setShortcut( QKeySequence():new( "Ctrl+F2" ) ) - ::connect( ::qActionTab, "triggered(bool)", {|| ::execSlot( 71, Self ) } ) - #endif - + ::qHLayout:addWidget( ::qEdit ) ::connectEditSlots( Self ) RETURN Self /*----------------------------------------------------------------------*/ +METHOD IdeEdit:gotoMark( nIndex ) + IF len( ::aBookMarks ) >= nIndex + ::qEdit:gotoBookmark( ::aBookMarks[ nIndex ] ) + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:relayMarkButtons() + LOCAL oBtn + FOR EACH oBtn IN ::aMarkTBtns + oBtn:hide() + NEXT + FOR EACH oBtn IN ::aBookMarks + ::aMarkTBtns[ oBtn:__enumIndex() ]:show() + NEXT + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:setNewMark() + LOCAL qCursor, nBlock, n + + IF !( qCursor := QTextCursor():configure( ::qEdit:textCursor() ) ):isNull() + nBlock := qCursor:blockNumber() + 1 + + IF ( n := ascan( ::aBookMarks, nBlock ) ) > 0 + hb_adel( ::aBookMarks, n, .t. ) + ::aMarkTBtns[ len( ::aBookMarks ) + 1 ]:hide() + ELSE + IF len( ::aBookMarks ) == 6 + RETURN Self + ENDIF + aadd( ::aBookMarks, nBlock ) + n := len( ::aBookMarks ) + ::aMarkTBtns[ n ]:show() + ENDIF + + ::qEdit:bookMarks( nBlock ) + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeEdit:destroy() ::disConnectEditSlots( Self ) @@ -1558,11 +1427,10 @@ METHOD IdeEdit:destroy() ::oEditor:qLayout:removeItem( ::qHLayout ) // ::qHLayout:removeWidget( ::qEdit ) - ::qHLayout:removeWidget( ::qLineNos ) - ::qLineNos := NIL - ::qEdit := NIL - ::qHLayout := NIL + ::qEdit:pPtr := NIL + ::qEdit := nil + ::qHLayout := NIL RETURN Self @@ -1600,122 +1468,49 @@ METHOD IdeEdit:connectEditSlots( oEdit ) /*----------------------------------------------------------------------*/ -METHOD IdeEdit:deHighlightPreviousLine() - LOCAL qB, qDoc - - qDoc := QTextDocument():configure( ::qEdit:document() ) - - IF ( qB := QTextBlock():configure( qDoc:findBlockByNumber( ::nLastLine ) ) ):isValid() - IF ::getUserDataState( qB ) != 99 - ::qLastCursor:setBlockFormat( QTextBlockFormat():new() ) - ENDIF - ENDIF - +METHOD IdeEdit:blockComment() + ::qEdit:blockComment() RETURN Self /*----------------------------------------------------------------------*/ -METHOD IdeEdit:highlightCurrentLine() - LOCAL nCurLine, nLastLine, qCursor, qDoc, qEdit, qBlockFmt, qB, lOldModified +METHOD IdeEdit:streamComment() + ::qEdit:streamComment() + RETURN Self - qEdit := ::qEdit - qCursor := QTextCursor():new( qEdit:textCursor() ) +/*----------------------------------------------------------------------*/ - qDoc := QTextDocument():configure( qEdit:document() ) - lOldModified := ::lModified - ::lModified := qDoc:isModified() +METHOD IdeEdit:caseUpper() + ::qEdit:caseUpper() + RETURN Self - qCursor:beginEditBlock() +/*----------------------------------------------------------------------*/ - nCurLine := qCursor:blockNumber() - nLastLine := ::nLastLine +METHOD IdeEdit:caseLower() + ::qEdit:caseLower() + RETURN Self - IF !( nCurLine == nLastLine ) +/*----------------------------------------------------------------------*/ - ::deHighlightPreviousLine() +METHOD IdeEdit:caseInvert() + LOCAL qCursor, i, c, s, cBuffer, nLen // qDoc, nBlock - IF ( qB := QTextBlock():configure( qCursor:block() ) ):isValid() - IF ::getUserDataState( qB ) != 99 - qBlockFmt := QTextBlockFormat():configure( qB:blockFormat() ) - qBlockFmt:setBackground( ::qBrushCL ) - qCursor:setBlockFormat( qBlockFmt ) + qCursor := QTextCursor():configure( ::qCurEdit:textCursor() ) + IF qCursor:hasSelection() .and. !empty( cBuffer := qCursor:selectedText() ) + //qDoc := QTextDocument()configure( ::qEdit:document() ) + s := "" + nLen := len( cBuffer ) + //nStart := qCursor:startSelection() + FOR i := 1 TO nLen + c := substr( cBuffer, i, 1 ) + IF isAlpha( c ) //!( c $ CRLF ) .AND. + s += iif( isUpper( c ), lower( c ), upper( c ) ) + ELSE + s += c ENDIF - ENDIF - ENDIF - - qCursor:endEditBlock() - - ::nLastLine := nCurLine - IF !( qCursor:isNull() ) - ::qLastCursor := qCursor - ENDIF - - /* 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 */ - IF ( lOldModified != ::lModified ) - qDoc:setModified( ::lModified ) - ::qTabWidget:setTabIcon( ::qTabWidget:indexOf( ::oEditor:oTab:oWidget ), ; - ::resPath + iif( ::lModified, "tabmodified.png", "tabunmodified.png" ) ) - ::oDK:setStatusText( SB_PNL_MODIFIED, ::lModified ) - ENDIF - - RETURN Self - -/*----------------------------------------------------------------------*/ - -METHOD IdeEdit:setNewMark() - LOCAL qBlockFmt, qTextBlock, qDoc, lModified, nState - - qDoc := QTextDocument():configure( ::qEdit:document() ) - lModified := qDoc:isModified() - - IF empty( ::qCursorMark ) - ::qCursorMark := QTextCursor():configure( ::qEdit:textCursor() ) - - qTextBlock := QTextBlock():configure( ::qCursorMark:block() ) - qBlockFmt := QTextBlockFormat():new() - - qBlockFmt:setBackground( ::qBrushMark ) - ::qCursorMark:setBlockFormat( qBlockFmt ) - - ::qMarkUData := HBQTextBlockUserData():new() - ::qMarkUData:hbSetState( 99 ) - qTextBlock:setUserData( ::qMarkUData ) - - ELSE - IF ( qTextBlock := QTextBlock():configure( ::qCursorMark:block() ) ):isValid() - nState := ::getUserDataState( qTextBlock ) - - IF nState == 99 /* Marked */ - ::qMarkUData:hbSetState( -1 ) - ::qCursorMark:setBlockFormat( QTextBlockFormat():new() ) - ::qCursorMark:pPtr := NIL // Should We ? - ::qCursorMark := NIL - ENDIF - ENDIF - ENDIF - - 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 ) - ::qEdit:setTextCursor( ::qCursorMark ) + NEXT +hbide_dbg( s ) + ::qEdit:replaceSelection( s ) ENDIF RETURN Self @@ -1723,30 +1518,13 @@ METHOD IdeEdit:gotoLastMark() /*----------------------------------------------------------------------*/ METHOD IdeEdit:duplicateLine() - LOCAL qCursor, qC, cLine, qEdit - - qEdit := ::qEdit - qCursor := QTextCursor():configure( qEdit:textCursor() ) - qC := QTextCursor():configure( qEdit:textCursor() ) - - qCursor:beginEditBlock() - qCursor:movePosition( QTextCursor_StartOfLine ) - qCursor:movePosition( QTextCursor_EndOfLine, QTextCursor_KeepAnchor ) - // - cLine := qCursor:selectedText() - // - qCursor:movePosition( QTextCursor_EndOfLine ) - qEdit:setTextCursor( qCursor ) - qEdit:insertPlainText( CRLF + cLine ) - qEdit:setTextCursor( qC ) - qCursor:endEditBlock() - - RETURN Self + ::qEdit:duplicateLine() + RETURN Self /*----------------------------------------------------------------------*/ METHOD IdeEdit:execSlot( nMode, oEdit, o, p, p1 ) - LOCAL pAct, qAct, n, qCursor, qEdit, oo, nBlocks, nLineNo + LOCAL pAct, qAct, n, qCursor, qEdit, oo, nSpaces HB_SYMBOL_UNUSED( o ) HB_SYMBOL_UNUSED( p1 ) @@ -1795,34 +1573,37 @@ METHOD IdeEdit:execSlot( nMode, oEdit, o, p, p1 ) //hbide_dbg( "redoAvailable(bool)", p ) EXIT CASE selectionChanged - //hbide_dbg( "selectionChanged()" ) + hbide_dbg( "selectionChanged()" ) ::oEditor:qCqEdit := qEdit ::oEditor:qCoEdit := oEdit + ::relayMarkButtons() + qCursor := QTextCursor():configure( qEdit:TextCursor() ) ::oDK:setStatusText( SB_PNL_SELECTEDCHARS, len( qCursor:selectedText() ) ) + EXIT CASE undoAvailable //hbide_dbg( "undoAvailable(bool)", p ) EXIT CASE updateRequest - //hbide_dbg( "updateRequest" ) - qCursor := QTextCursor():configure( qEdit:cursorForPosition( ::qPoint ) ) - nLineNo := qCursor:blockNumber() - nBlocks := ::oEditor:qDocument:blockCount() - IF oEdit:nLineNo != nLineNo .OR. !( ::oEditor:lLoaded ) .OR. !( nBlocks == ::oEditor:nPrevBlocks ) - ::oEditor:nPrevBlocks := nBlocks - oEdit:nLineNo := nLineNo - oEdit:qLineNos:setHTML( hbide_buildLinesLabel( ::nLineNo + 1, ; - ::oEditor:qDocument:blockCount(), ::nMaxDigits, ::nMaxRows ) ) - ENDIF EXIT CASE cursorPositionChanged - // hbide_dbg( "cursorPositionChanged()" ) - ::lCursorPosChanging := .T. + //hbide_dbg( "cursorPositionChanged()" ) ::oEditor:dispEditInfo( qEdit ) - ::highlightCurrentLine() - ::lCursorPosChanging := .F. + IF ::lUpdatePrevWord + ::lUpdatePrevWord := .f. + hbide_handlePreviousWord( ::qEdit ) + ENDIF + + IF ::lIndentIt + ::lIndentIt := .f. + IF ( nSpaces := ::findLastIndent() ) > 0 + qCursor := QTextCursor():configure( ::qEdit:textCursor() ) + qCursor:insertText( space( nSpaces ) ) + ENDIF + ENDIF + //hbide_dbg( "cursorPositionChanged() 1" ) EXIT ENDSWITCH @@ -1832,7 +1613,7 @@ METHOD IdeEdit:execSlot( nMode, oEdit, o, p, p1 ) /*----------------------------------------------------------------------*/ METHOD IdeEdit:execEvent( nMode, nEvent, p ) - LOCAL key, kbm, txt, qEvent, qCursor + LOCAL key, kbm, txt, qEvent LOCAL lAlt := .f. LOCAL lCtrl := .f. LOCAL lShift := .f. @@ -1857,17 +1638,25 @@ METHOD IdeEdit:execEvent( nMode, nEvent, p ) ENDIF SWITCH ( key ) + + CASE Qt_Key_Q /* All these actions will be pulled from user-setup */ + IF lCtrl .AND. lShift + ::streamComment() + ENDIF + EXIT + CASE Qt_Key_Slash + IF lCtrl + ::blockComment() + ENDIF + EXIT CASE Qt_Key_D IF lCtrl ::duplicateLine() - RETURN .T. /* NOTE */ ENDIF EXIT CASE Qt_Key_Return CASE Qt_Key_Enter - qCursor := QTextCursor():configure( ::qEdit:textCursor() ) - qCursor:setBlockFormat( QTextBlockFormat():new() ) - ::qEdit:setTextCursor( qCursor ) + ::lIndentIt := .t. EXIT CASE Qt_Key_Tab CASE Qt_Key_Backtab @@ -1880,33 +1669,8 @@ METHOD IdeEdit:execEvent( nMode, nEvent, p ) EXIT CASE QEvent_Wheel - #if 0 /* Of no use */ - qEvent := QWheelEvent():configure( p ) - - IF nMode == 1 /* QPlainTextEdit */ - IF hb_bitAnd( qEvent:modifiers(), Qt_ControlModifier ) == Qt_ControlModifier - IF qEvent:delta() > 0 - ::oEM:zoom( 1 ) - - ELSE - ::oEM:zoom( 0 ) - - ENDIF - - qEvent:ignore() - - RETURN .t. /* Tells Qt that we are done, no more processing */ - ENDIF - - ELSE - - qEvent:setAccepted( .f. ) - RETURN .f. /* We do not want it to be processed at all - it is line no area */ - - ENDIF - #endif - EXIT + ENDSWITCH hbide_justACall( txt, lAlt, lShift, lCtrl, qEvent, nMode ) @@ -1914,3 +1678,166 @@ METHOD IdeEdit:execEvent( nMode, nEvent, p ) /*----------------------------------------------------------------------*/ +METHOD IdeEdit:findLastIndent() + LOCAL qCursor, qTextBlock, cText, cWord + LOCAL nSpaces := 0 + + qCursor := QTextCursor():configure( ::qEdit:textCursor() ) + qTextBlock := QTextBlock():configure( qCursor:block() ) + + DO WHILE .t. + IF !( qTextBlock:isValid() ) + EXIT + ENDIF + IF !empty( cText := qTextBlock:text() ) + nSpaces := hbide_getFrontSpacesAndWord( cText, @cWord ) + IF !empty( cWord ) + IF hbide_isIndentableKeyword( cWord ) + nSpaces += ::nTabSpaces + ENDIF + EXIT + ENDIF + ENDIF + qTextBlock := QTextBlock():configure( qTextBlock:previous() ) + ENDDO + + RETURN nSpaces + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_isHarbourKeyword( cWord ) + LOCAL b_:= { 'function','return','static','local','default', ; + 'if','else','elseif','endif','end', ; + 'docase','case','endcase','otherwise', ; + 'do','while','exit',; + 'for','each','next','step','to',; + 'class','endclass','method','data','var','destructor','inline','assign','access',; + 'inherit','init','create','virtual','message',; + 'begin','sequence','try','catch','always','recover','hb_symbol_unused', ; + 'error','handler' } + + cWord := lower( cWord ) + + RETURN ascan( b_, {|e| e == cWord } ) > 0 + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_isIndentableKeyword( cWord ) + LOCAL b_:= { 'function',; + 'if','else','elseif', ; + 'docase','case','otherwise', ; + 'do','while',; + 'for',; + 'class','method',; + 'begin','sequence','try','catch','always','recover','finally' } + + cWord := lower( cWord ) + + RETURN ascan( b_, {|e| e == cWord } ) > 0 + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_isStartingKeyword( cWord ) + LOCAL b_:= { 'function','method' } + + cWord := lower( cWord ) + + RETURN ascan( b_, {|e| e == cWord } ) > 0 + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_handlePreviousWord( qEdit ) + LOCAL qCursor, qTextBlock, cText, nPos, cWord, nB, nL + + qCursor := QTextCursor():configure( qEdit:textCursor() ) + qTextBlock := QTextBlock():configure( qCursor:block() ) + cText := qTextBlock:text() + nPos := qCursor:columnNumber() + IF ( substr( cText, nPos - 1, 1 ) == " " ) + RETURN nil + ENDIF + + cWord := hbide_getPreviousWord( cText, nPos + 1 ) + + IF !empty( cWord ) + nL := len( cWord + " " ) + nB := qCursor:position() - nL + + IF hbide_isHarbourKeyword( cWord ) + //qEdit:setToolTip( cWord ) + + qCursor:beginEditBlock() + qCursor:setPosition( nB ) + qCursor:movePosition( QTextCursor_NextCharacter, QTextCursor_KeepAnchor, nL ) + qCursor:removeSelectedText() + qCursor:insertText( upper( cWord ) + " " ) + + qEdit:setTextCursor( qCursor ) + qCursor:endEditBlock() + ENDIF + + 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 + ENDIF + ENDIF + RETURN .t. + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_getPreviousWord( cText, nPos ) + LOCAL cWord, n + + cText := alltrim( substr( cText, 1, nPos ) ) + IF ( n := rat( " ", cText ) ) > 0 + cWord := substr( cText, n + 1 ) + ELSE + cWord := cText + ENDIF + + RETURN cWord + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_getFirstWord( cText ) + LOCAL cWord, n + + cText := alltrim( cText ) + IF ( n := at( " ", cText ) ) > 0 + cWord := left( cText, n-1 ) + ELSE + cWord := cText + ENDIF + + RETURN cWord + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_getFrontSpacesAndWord( cText, cWord ) + LOCAL n := 0 + + DO WHILE .t. + IF substr( cText, ++n, 1 ) != " " + EXIT + ENDIF + ENDDO + n-- + + cWord := hbide_getFirstWord( cText ) + + RETURN n + +/*----------------------------------------------------------------------*/ + + diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index bd2d1a1063..77aceaf290 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -514,7 +514,7 @@ FUNCTION hbide_isValidText( cSourceFile ) hb_fNameSplit( cSourceFile, , , @cExt ) RETURN ( lower( cExt ) $ ".c,.cpp,.prg,.h,.ch,.txt,.log,.ini,.env,.ppo," + ; - ".cc,.hbc,.hbp,.hbm,.xml,.bat,.sh,.rc" ) + ".cc,.hbc,.hbp,.hbm,.xml,.bat,.sh,.rc,.ui,.bak" ) /*----------------------------------------------------------------------*/ @@ -764,7 +764,7 @@ FUNCTION hbide_parseKeyValPair( s, cKey, cVal ) /*----------------------------------------------------------------------*/ FUNCTION hbide_dbg( ... ) - HB_TRACE( HB_TR_ALWAYS, ... ) + HB_TRACE( HB_TR_ALWAYS, procname(1),... ) RETURN nil /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbide/ideobject.prg b/harbour/contrib/hbide/ideobject.prg index 2ba84d4be4..94e5e71472 100644 --- a/harbour/contrib/hbide/ideobject.prg +++ b/harbour/contrib/hbide/ideobject.prg @@ -143,6 +143,8 @@ CLASS IdeObject ACCESS lDockBVisible INLINE ::oIde:lDockBVisible ACCESS lTabCloseRequested INLINE ::oIde:lTabCloseRequested + ACCESS aMarkTBtns INLINE ::oIde:aMarkTBtns + DATA aSlots INIT {} DATA aEvents INIT {} METHOD connect( qWidget, cSlot, bBlock ) diff --git a/harbour/contrib/hbide/ideprojmanager.prg b/harbour/contrib/hbide/ideprojmanager.prg index 127ebf5088..c24e2348c3 100644 --- a/harbour/contrib/hbide/ideprojmanager.prg +++ b/harbour/contrib/hbide/ideprojmanager.prg @@ -201,6 +201,7 @@ CLASS IdeProjManager INHERIT IdeObject METHOD populate() METHOD loadProperties( cProjFileName, lNew, lFetch, lUpdateTree ) METHOD fetchProperties() + METHOD getProperties() METHOD sortSources( cMode ) METHOD updateMetaData() METHOD save( lCanClose ) @@ -258,6 +259,27 @@ METHOD IdeProjManager:populate() /*----------------------------------------------------------------------*/ +METHOD IdeProjManager:getProperties() + LOCAL aPrj, cHbi, cTmp, n + + IF Empty( ::cWrkProject ) + MsgBox( 'No active project detected' ) + ENDIF + cTmp := ::getCurrentProject() + IF ( n := ascan( ::aProjects, {|e_| e_[ 3, PRJ_PRP_PROPERTIES, 2, E_oPrjTtl ] == cTmp } ) ) > 0 + aPrj := ::aProjects[ n, 3 ] + cHbi := aPrj[ PRJ_PRP_PROPERTIES, 2, PRJ_PRP_LOCATION ] + ::pathSep + ; + aPrj[ PRJ_PRP_PROPERTIES, 2, PRJ_PRP_OUTPUT ] + ".hbi" + + ::loadProperties( cHbi, .f., .t., .t. ) + ELSE + MsgBox( 'Invalid project: ' + cTmp ) + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeProjManager:loadProperties( cProjFileName, lNew, lFetch, lUpdateTree ) LOCAL n, t, cWrkProject diff --git a/harbour/contrib/hbide/idesources.prg b/harbour/contrib/hbide/idesources.prg index b7dbd5bbcd..5cc456a657 100644 --- a/harbour/contrib/hbide/idesources.prg +++ b/harbour/contrib/hbide/idesources.prg @@ -110,15 +110,15 @@ METHOD IdeSourcesManager:create( oIde ) /*----------------------------------------------------------------------*/ METHOD IdeSourcesManager:loadSources() - LOCAL a_ + LOCAL a_, nIndex IF !empty( ::aIni[ INI_FILES ] ) FOR EACH a_ IN ::aIni[ INI_FILES ] /* File nPos nVPos nHPos cTheme lAlert lVisible */ ::editSource( a_[ 1 ], a_[ 2 ], a_[ 3 ], a_[ 4 ], a_[ 5 ], .t., .f. ) NEXT - - ::oEM:setSourceVisibleByIndex( val( ::aIni[ INI_HBIDE, RecentTabIndex ] ) ) + nIndex := max( 0, val( ::aIni[ INI_HBIDE, RecentTabIndex ] ) ) + ::oEM:setSourceVisibleByIndex( nIndex ) ENDIF RETURN Self diff --git a/harbour/contrib/hbqt/filelist.mk b/harbour/contrib/hbqt/filelist.mk index afbdd4300a..4c6e810969 100644 --- a/harbour/contrib/hbqt/filelist.mk +++ b/harbour/contrib/hbqt/filelist.mk @@ -6,6 +6,7 @@ MOC_HEADERS := \ hbqt_hbdbfmodel.h \ hbqt_hbevents.h \ hbqt_hbqmainwindow.h \ + hbqt_hbqplaintextedit.h \ hbqt_hbqsyntaxhighlighter.h \ hbqt_hbqtableview.h \ hbqt_hbslots.h \ @@ -17,6 +18,7 @@ CPP_SOURCES := \ hbqt_hbdbfmodel.cpp \ hbqt_hbevents.cpp \ hbqt_hbqmainwindow.cpp \ + hbqt_hbqplaintextedit.cpp \ hbqt_hbqsyntaxhighlighter.cpp \ hbqt_hbqtableview.cpp \ hbqt_hbslots.cpp \ diff --git a/harbour/contrib/hbqt/generator/qt45.qtp b/harbour/contrib/hbqt/generator/qt45.qtp index 30f0f9cd58..45c2b799a2 100644 --- a/harbour/contrib/hbqt/generator/qt45.qtp +++ b/harbour/contrib/hbqt/generator/qt45.qtp @@ -16,6 +16,7 @@ HBDbfModel.qth HBEvents.qth +HBQPlainTextEdit.qth HBQSyntaxHighlighter.qth HBQTableView.qth HBQTextBlockUserData.qth diff --git a/harbour/contrib/hbqt/hbqt.h b/harbour/contrib/hbqt/hbqt.h index 17baa7cb4b..1b32f05e76 100644 --- a/harbour/contrib/hbqt/hbqt.h +++ b/harbour/contrib/hbqt/hbqt.h @@ -391,6 +391,7 @@ extern void * hbqt_pPtrFromItem( PHB_ITEM pObj ); #define hbqt_par_HBDbfModel( n ) ( ( HBDbfModel * ) hbqt_gcpointer( n ) ) #define hbqt_par_HBEvents( n ) ( ( HBEvents * ) hbqt_gcpointer( n ) ) #define hbqt_par_HBQMainWindow( n ) ( ( HBQMainWindow * ) hbqt_gcpointer( n ) ) +#define hbqt_par_HBQPlainTextEdit( n ) ( ( HBQPlainTextEdit * ) hbqt_gcpointer( n ) ) #define hbqt_par_HBQTableView( n ) ( ( HBQTableView * ) hbqt_gcpointer( n ) ) #define hbqt_par_HBQSyntaxHighlighter( n ) ( ( HBQSyntaxHighlighter * ) hbqt_gcpointer( n ) ) #define hbqt_par_HBQTextBlockUserData( n ) ( ( HBQTextBlockUserData * ) hbqt_gcpointer( n ) ) diff --git a/harbour/contrib/hbqt/hbqt_garbage.h b/harbour/contrib/hbqt/hbqt_garbage.h index 1a60e0532b..e537d42aa9 100644 --- a/harbour/contrib/hbqt/hbqt_garbage.h +++ b/harbour/contrib/hbqt/hbqt_garbage.h @@ -10,6 +10,7 @@ extern QT_G_FUNC( hbqt_gcRelease_HBDbfModel ); extern QT_G_FUNC( hbqt_gcRelease_HBEvents ); +extern QT_G_FUNC( hbqt_gcRelease_HBQPlainTextEdit ); extern QT_G_FUNC( hbqt_gcRelease_HBQSyntaxHighlighter ); extern QT_G_FUNC( hbqt_gcRelease_HBQTableView ); extern QT_G_FUNC( hbqt_gcRelease_HBQTextBlockUserData ); @@ -292,6 +293,7 @@ extern QT_G_FUNC( hbqt_gcRelease_QWizardPage ); extern void * hbqt_gcAllocate_HBDbfModel( void * pObj, bool bNew ); extern void * hbqt_gcAllocate_HBEvents( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_HBQPlainTextEdit( void * pObj, bool bNew ); extern void * hbqt_gcAllocate_HBQSyntaxHighlighter( void * pObj, bool bNew ); extern void * hbqt_gcAllocate_HBQTableView( void * pObj, bool bNew ); extern void * hbqt_gcAllocate_HBQTextBlockUserData( void * pObj, bool bNew ); diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp new file mode 100644 index 0000000000..a97fec6559 --- /dev/null +++ b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp @@ -0,0 +1,368 @@ +/* + * $Id$ + */ + +/* -------------------------------------------------------------------- */ +/* WARNING: Automatically generated source file. DO NOT EDIT! */ +/* Instead, edit corresponding .qth file, */ +/* or the generator tool itself, and run regenarate. */ +/* -------------------------------------------------------------------- */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009-2010 Pritpal Bedi + * + * Copyright 2009 Marcos Antonio Gambeta + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ + +#include "hbapi.h" +#include "../hbqt.h" + +/*----------------------------------------------------------------------*/ +#if QT_VERSION >= 0x040500 +/*----------------------------------------------------------------------*/ + +#include + +#include + +#include "../hbqt_hbqplaintextedit.h" + +/* + * HBQPlainTextEdit ( QWidget * parent = 0 ) + * HBQPlainTextEdit ( const QString & text, QWidget * parent = 0 ) + * virtual ~HBQPlainTextEdit () + */ + +typedef struct +{ + void * ph; + bool bNew; + QT_G_FUNC_PTR func; + QPointer< HBQPlainTextEdit > pq; +} QGC_POINTER_HBQPlainTextEdit; + +QT_G_FUNC( hbqt_gcRelease_HBQPlainTextEdit ) +{ + QGC_POINTER_HBQPlainTextEdit * p = ( QGC_POINTER_HBQPlainTextEdit * ) Cargo; + + if( p && p->bNew ) + { + if( p->ph && p->pq ) + { + const QMetaObject * m = ( ( QObject * ) p->ph )->metaObject(); + if( ( QString ) m->className() != ( QString ) "QObject" ) + { + delete ( ( HBQPlainTextEdit * ) p->ph ); + HB_TRACE( HB_TR_DEBUG, ( "YES_rel_HBQPlainTextEdit ph=%p pq=%p %i B %i KB", p->ph, (void *)(p->pq), ( int ) hb_xquery( 1001 ), hbqt_getmemused() ) ); + p->ph = NULL; + } + else + { + HB_TRACE( HB_TR_DEBUG, ( "NO__rel_HBQPlainTextEdit ph=%p pq=%p %i B %i KB", p->ph, (void *)(p->pq), ( int ) hb_xquery( 1001 ), hbqt_getmemused() ) ); + } + } + else + { + HB_TRACE( HB_TR_DEBUG, ( "DEL_rel_HBQPlainTextEdit Object already deleted!" ) ); + } + } + else + { + HB_TRACE( HB_TR_DEBUG, ( "PTR_rel_HBQPlainTextEdit Object not created with - new" ) ); + p->ph = NULL; + } +} + +void * hbqt_gcAllocate_HBQPlainTextEdit( void * pObj, bool bNew ) +{ + QGC_POINTER_HBQPlainTextEdit * p = ( QGC_POINTER_HBQPlainTextEdit * ) hb_gcAllocate( sizeof( QGC_POINTER_HBQPlainTextEdit ), hbqt_gcFuncs() ); + + p->ph = pObj; + p->bNew = bNew; + p->func = hbqt_gcRelease_HBQPlainTextEdit; + + if( bNew ) + { + new( & p->pq ) QPointer< HBQPlainTextEdit >( ( HBQPlainTextEdit * ) pObj ); + HB_TRACE( HB_TR_DEBUG, ( " _new_HBQPlainTextEdit ph=%p %i B %i KB", pObj, ( int ) hb_xquery( 1001 ), hbqt_getmemused() ) ); + } + return p; +} + +HB_FUNC( QT_HBQPLAINTEXTEDIT ) +{ + void * pObj = NULL; + + if( hb_pcount() == 1 && HB_ISCHAR( 1 ) ) + { + pObj = new HBQPlainTextEdit() ; + } + else if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + pObj = new HBQPlainTextEdit( hbqt_par_QWidget( 1 ) ) ; + } + else + { + pObj = new HBQPlainTextEdit() ; + } + + hb_retptrGC( hbqt_gcAllocate_HBQPlainTextEdit( pObj, true ) ); +} + +/* + * int getIndex( const QTextCursor & crQTextCursor) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_GETINDEX ) +{ + hb_retni( hbqt_par_HBQPlainTextEdit( 1 )->getIndex( *hbqt_par_QTextCursor( 2 ) ) ); +} + +/* + * int getLine( const QTextCursor & crQTextCursor) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_GETLINE ) +{ + hb_retni( hbqt_par_HBQPlainTextEdit( 1 )->getLine( *hbqt_par_QTextCursor( 2 ) ) ); +} + +/* + * int lineNumberAreaWidth() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_LINENUMBERAREAWIDTH ) +{ + hb_retni( hbqt_par_HBQPlainTextEdit( 1 )->lineNumberAreaWidth() ); +} + +/* + * int getSpaces() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_GETSPACES ) +{ + hb_retni( hbqt_par_HBQPlainTextEdit( 1 )->getSpaces() ); +} + +/* + * void setSpaces(int newSpaces) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_SETSPACES ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->setSpaces( hb_parni( 2 ) ); +} + +/* + * void bookmarks(int block) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_BOOKMARKS ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->bookmarks( hb_parni( 2 ) ); +} + +/* + * void nextBookmark(int block) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_NEXTBOOKMARK ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->nextBookmark( hb_parni( 2 ) ); +} + +/* + * void prevBookmark(int block) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_PREVBOOKMARK ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->prevBookmark( hb_parni( 2 ) ); +} + +/* + * void gotoBookmark(int block) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_GOTOBOOKMARK ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->gotoBookmark( hb_parni( 2 ) ); +} + +/* + * void numberBlockVisible(bool b) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_NUMBERBLOCKVISIBLE ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->numberBlockVisible( hb_parl( 2 ) ); +} + +/* + * bool numberBlockVisible() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_NUMBERBLOCKVISIBLE_1 ) +{ + hb_retl( hbqt_par_HBQPlainTextEdit( 1 )->numberBlockVisible() ); +} + +/* + * void highlightCurrentLine(bool b) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HIGHLIGHTCURRENTLINE ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->highlightCurrentLine( hb_parl( 2 ) ); +} + +/* + * bool highlightCurrentLine() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HIGHLIGHTCURRENTLINE_1 ) +{ + hb_retl( hbqt_par_HBQPlainTextEdit( 1 )->highlightCurrentLine() ); +} + +/* + * void updateLineNumberAreaWidth( int newBlockCount ) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_UPDATELINENUMBERAREAWIDTH ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->updateLineNumberAreaWidth( hb_parni( 2 ) ); +} + +/* + * void caseUpper() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_CASEUPPER ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->caseUpper(); +} + +/* + * void caseLower() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_CASELOWER ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->caseLower(); +} + +/* + * void escapeQuotes() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_ESCAPEQUOTES ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->escapeQuotes(); +} + +/* + * void escapeDQuotes() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_ESCAPEDQUOTES ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->escapeDQuotes(); +} + +/* + * void unescapeQuotes() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_UNESCAPEQUOTES ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->unescapeQuotes(); +} + +/* + * void unescapeDQuotes() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_UNESCAPEDQUOTES ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->unescapeDQuotes(); +} + +/* + * void convertQuotes() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_CONVERTQUOTES ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->convertQuotes(); +} + +/* + * void convertDQuotes() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_CONVERTDQUOTES ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->convertDQuotes(); +} + +/* + * void blockComment() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_BLOCKCOMMENT ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->blockComment(); +} + +/* + * void streamComment() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_STREAMCOMMENT ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->streamComment(); +} + +/* + * void duplicateLine() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_DUPLICATELINE ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->duplicateLine(); +} + +/* + * void replaceSelection( const QString & txt ) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_REPLACESELECTION ) +{ + hbqt_par_HBQPlainTextEdit( 1 )->replaceSelection( HBQPlainTextEdit::tr( hb_parc( 2 ) ) ); +} + + +/*----------------------------------------------------------------------*/ +#endif /* #if QT_VERSION >= 0x040500 */ +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbqt/qtgui/QApplication.cpp b/harbour/contrib/hbqt/qtgui/QApplication.cpp index 77d44b2eca..23081789ae 100644 --- a/harbour/contrib/hbqt/qtgui/QApplication.cpp +++ b/harbour/contrib/hbqt/qtgui/QApplication.cpp @@ -89,6 +89,7 @@ #include #include #include +#include #include static QApplication * s_app = NULL; @@ -124,6 +125,10 @@ static void hbqt_Init( void * cargo ) { HB_SYMBOL_UNUSED( cargo ); + QTextCodec *codec = QTextCodec::codecForLocale(); + QTextCodec::setCodecForTr( codec ); + QTextCodec::setCodecForCStrings( codec ); + s_argc = hb_cmdargARGC(); s_argv = hb_cmdargARGV(); diff --git a/harbour/contrib/hbqt/qtgui/QPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/QPlainTextEdit.cpp index 7727ac9551..ab53ac12ab 100644 --- a/harbour/contrib/hbqt/qtgui/QPlainTextEdit.cpp +++ b/harbour/contrib/hbqt/qtgui/QPlainTextEdit.cpp @@ -71,18 +71,13 @@ */ /* - * Constructed[ 57/64 [ 89.06% ] ] + * Constructed[ 57/59 [ 96.61% ] ] * * *** Unconvered Prototypes *** * ----------------------------- * * QList extraSelections () const * void setExtraSelections ( const QList & selections ) - * 15 public functions inherited from QAbstractScrollArea - * 13 public functions inherited from QFrame - * 207 public functions inherited from QWidget - * 29 public functions inherited from QObject - * 12 public functions inherited from QPaintDevice */ #include diff --git a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg new file mode 100644 index 0000000000..cb2ecd8b8a --- /dev/null +++ b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg @@ -0,0 +1,211 @@ +/* + * $Id$ + */ + +/* -------------------------------------------------------------------- */ +/* WARNING: Automatically generated source file. DO NOT EDIT! */ +/* Instead, edit corresponding .qth file, */ +/* or the generator tool itself, and run regenarate. */ +/* -------------------------------------------------------------------- */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009-2010 Pritpal Bedi + * + * Copyright 2009 Marcos Antonio Gambeta + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ + + +#include "hbclass.ch" + + +CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit + + METHOD new( ... ) + + METHOD getIndex( pCrQTextCursor ) + METHOD getLine( pCrQTextCursor ) + METHOD lineNumberAreaWidth() + METHOD getSpaces() + METHOD setSpaces( nNewSpaces ) + METHOD bookmarks( nBlock ) + METHOD nextBookmark( nBlock ) + METHOD prevBookmark( nBlock ) + METHOD gotoBookmark( nBlock ) + METHOD numberBlockVisible( lB ) + METHOD numberBlockVisible_1() + METHOD highlightCurrentLine( lB ) + METHOD highlightCurrentLine_1() + METHOD updateLineNumberAreaWidth( nNewBlockCount ) + METHOD caseUpper() + METHOD caseLower() + METHOD escapeQuotes() + METHOD escapeDQuotes() + METHOD unescapeQuotes() + METHOD unescapeDQuotes() + METHOD convertQuotes() + METHOD convertDQuotes() + METHOD blockComment() + METHOD streamComment() + METHOD duplicateLine() + METHOD replaceSelection( cTxt ) + + ENDCLASS + + +METHOD HBQPlainTextEdit:new( ... ) + LOCAL p + FOR EACH p IN { ... } + hb_pvalue( p:__enumIndex(), hbqt_ptr( p ) ) + NEXT + ::pPtr := Qt_HBQPlainTextEdit( ... ) + RETURN Self + + +METHOD HBQPlainTextEdit:getIndex( pCrQTextCursor ) + RETURN Qt_HBQPlainTextEdit_getIndex( ::pPtr, hbqt_ptr( pCrQTextCursor ) ) + + +METHOD HBQPlainTextEdit:getLine( pCrQTextCursor ) + RETURN Qt_HBQPlainTextEdit_getLine( ::pPtr, hbqt_ptr( pCrQTextCursor ) ) + + +METHOD HBQPlainTextEdit:lineNumberAreaWidth() + RETURN Qt_HBQPlainTextEdit_lineNumberAreaWidth( ::pPtr ) + + +METHOD HBQPlainTextEdit:getSpaces() + RETURN Qt_HBQPlainTextEdit_getSpaces( ::pPtr ) + + +METHOD HBQPlainTextEdit:setSpaces( nNewSpaces ) + RETURN Qt_HBQPlainTextEdit_setSpaces( ::pPtr, nNewSpaces ) + + +METHOD HBQPlainTextEdit:bookmarks( nBlock ) + RETURN Qt_HBQPlainTextEdit_bookmarks( ::pPtr, nBlock ) + + +METHOD HBQPlainTextEdit:nextBookmark( nBlock ) + RETURN Qt_HBQPlainTextEdit_nextBookmark( ::pPtr, nBlock ) + + +METHOD HBQPlainTextEdit:prevBookmark( nBlock ) + RETURN Qt_HBQPlainTextEdit_prevBookmark( ::pPtr, nBlock ) + + +METHOD HBQPlainTextEdit:gotoBookmark( nBlock ) + RETURN Qt_HBQPlainTextEdit_gotoBookmark( ::pPtr, nBlock ) + + +METHOD HBQPlainTextEdit:numberBlockVisible( lB ) + RETURN Qt_HBQPlainTextEdit_numberBlockVisible( ::pPtr, lB ) + + +METHOD HBQPlainTextEdit:numberBlockVisible_1() + RETURN Qt_HBQPlainTextEdit_numberBlockVisible_1( ::pPtr ) + + +METHOD HBQPlainTextEdit:highlightCurrentLine( lB ) + RETURN Qt_HBQPlainTextEdit_highlightCurrentLine( ::pPtr, lB ) + + +METHOD HBQPlainTextEdit:highlightCurrentLine_1() + RETURN Qt_HBQPlainTextEdit_highlightCurrentLine_1( ::pPtr ) + + +METHOD HBQPlainTextEdit:updateLineNumberAreaWidth( nNewBlockCount ) + RETURN Qt_HBQPlainTextEdit_updateLineNumberAreaWidth( ::pPtr, nNewBlockCount ) + + +METHOD HBQPlainTextEdit:caseUpper() + RETURN Qt_HBQPlainTextEdit_caseUpper( ::pPtr ) + + +METHOD HBQPlainTextEdit:caseLower() + RETURN Qt_HBQPlainTextEdit_caseLower( ::pPtr ) + + +METHOD HBQPlainTextEdit:escapeQuotes() + RETURN Qt_HBQPlainTextEdit_escapeQuotes( ::pPtr ) + + +METHOD HBQPlainTextEdit:escapeDQuotes() + RETURN Qt_HBQPlainTextEdit_escapeDQuotes( ::pPtr ) + + +METHOD HBQPlainTextEdit:unescapeQuotes() + RETURN Qt_HBQPlainTextEdit_unescapeQuotes( ::pPtr ) + + +METHOD HBQPlainTextEdit:unescapeDQuotes() + RETURN Qt_HBQPlainTextEdit_unescapeDQuotes( ::pPtr ) + + +METHOD HBQPlainTextEdit:convertQuotes() + RETURN Qt_HBQPlainTextEdit_convertQuotes( ::pPtr ) + + +METHOD HBQPlainTextEdit:convertDQuotes() + RETURN Qt_HBQPlainTextEdit_convertDQuotes( ::pPtr ) + + +METHOD HBQPlainTextEdit:blockComment() + RETURN Qt_HBQPlainTextEdit_blockComment( ::pPtr ) + + +METHOD HBQPlainTextEdit:streamComment() + RETURN Qt_HBQPlainTextEdit_streamComment( ::pPtr ) + + +METHOD HBQPlainTextEdit:duplicateLine() + RETURN Qt_HBQPlainTextEdit_duplicateLine( ::pPtr ) + + +METHOD HBQPlainTextEdit:replaceSelection( cTxt ) + RETURN Qt_HBQPlainTextEdit_replaceSelection( ::pPtr, cTxt ) + diff --git a/harbour/contrib/hbqt/qtgui/filelist.mk b/harbour/contrib/hbqt/qtgui/filelist.mk index 8c84b9e361..29f3f6ee00 100644 --- a/harbour/contrib/hbqt/qtgui/filelist.mk +++ b/harbour/contrib/hbqt/qtgui/filelist.mk @@ -9,6 +9,7 @@ # -------------------------------------------------------------------- CPP_SOURCES := \ + HBQPlainTextEdit.cpp \ HBQSyntaxHighlighter.cpp \ HBQTableView.cpp \ HBQTextBlockUserData.cpp \ @@ -226,6 +227,7 @@ CPP_SOURCES := \ PRG_SOURCES := \ + THBQPlainTextEdit.prg \ THBQSyntaxHighlighter.prg \ THBQTableView.prg \ THBQTextBlockUserData.prg \ diff --git a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth new file mode 100644 index 0000000000..433420ae8b --- /dev/null +++ b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth @@ -0,0 +1,130 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT Source Generator for Harbour + * + * Copyright 2009 Pritpal Bedi + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ +; +; Header File to Generate QT Wrapper Sources +; + + +QObject = +Inherits = QPlainTextEdit +Type = +New = + + + + + + +#include + +#include "../hbqt_hbqplaintextedit.h" + +/* + * HBQPlainTextEdit ( QWidget * parent = 0 ) + * HBQPlainTextEdit ( const QString & text, QWidget * parent = 0 ) + * virtual ~HBQPlainTextEdit () + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT ) +{ + if( hb_pcount() == 1 && HB_ISCHAR( 1 ) ) + { + hb_retptr( new HBQPlainTextEdit() ); + } + else if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + hb_retptr( new HBQPlainTextEdit( hbqt_par_QWidget( 1 ) ) ); + } + else + { + hb_retptr( new HBQPlainTextEdit() ); + } +} + + + + + + + int getIndex( const QTextCursor & crQTextCursor) + int getLine( const QTextCursor & crQTextCursor) + int lineNumberAreaWidth() + int getSpaces() + void setSpaces(int newSpaces) + void bookmarks(int block) + void nextBookmark(int block) + void prevBookmark(int block) + void gotoBookmark(int block) + void numberBlockVisible(bool b) + bool numberBlockVisible() + void highlightCurrentLine(bool b) + bool highlightCurrentLine() + + + + void updateLineNumberAreaWidth( int newBlockCount ) + void caseUpper() + void caseLower() + void escapeQuotes() + void escapeDQuotes() + void unescapeQuotes() + void unescapeDQuotes() + void convertQuotes() + void convertDQuotes() + void blockComment() + void streamComment() + void duplicateLine() + void replaceSelection( const QString & txt ) + + + + diff --git a/harbour/contrib/hbqt/qth/QApplication.qth b/harbour/contrib/hbqt/qth/QApplication.qth index 79b13c2c60..18947744b1 100644 --- a/harbour/contrib/hbqt/qth/QApplication.qth +++ b/harbour/contrib/hbqt/qth/QApplication.qth @@ -76,6 +76,7 @@ New = #include #include #include +#include #include static QApplication * s_app = NULL; @@ -115,6 +116,10 @@ static void hbqt_Init( void * cargo ) { HB_SYMBOL_UNUSED( cargo ); + QTextCodec *codec = QTextCodec::codecForLocale(); + QTextCodec::setCodecForTr( codec ); + QTextCodec::setCodecForCStrings( codec ); + s_argc = hb_cmdargARGC(); s_argv = hb_cmdargARGV(); diff --git a/harbour/contrib/hbqt/qth/QPlainTextEdit.qth b/harbour/contrib/hbqt/qth/QPlainTextEdit.qth index 94d561b4d8..cbc8b5defb 100644 --- a/harbour/contrib/hbqt/qth/QPlainTextEdit.qth +++ b/harbour/contrib/hbqt/qth/QPlainTextEdit.qth @@ -146,11 +146,6 @@ QTextCursor textCursor () const Qt::TextInteractionFlags textInteractionFlags () const QString toPlainText () const QTextOption::WrapMode wordWrapMode () const -15 public functions inherited from QAbstractScrollArea -13 public functions inherited from QFrame -207 public functions inherited from QWidget -29 public functions inherited from QObject -12 public functions inherited from QPaintDevice