2010-01-04 16:28 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/ideprojmanager.prg
  * contrib/hbide/idesaveload.prg
    ! Next round of reforms, stay patient.
    ! Implemented to hold last working project.
    ! Fixed to not generate error if an open project is tried 
      to reopen.
    ! Many small artifacts correctd.
This commit is contained in:
Pritpal Bedi
2010-01-05 00:30:15 +00:00
parent cbe60a6ebd
commit ccb74db573
8 changed files with 260 additions and 182 deletions

View File

@@ -17,6 +17,19 @@
past entries belonging to author(s): Viktor Szakats.
*/
2010-01-04 16:28 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/ideprojmanager.prg
* contrib/hbide/idesaveload.prg
! Next round of reforms, stay patient.
! Implemented to hold last working project.
! Fixed to not generate error if an open project is tried
to reopen.
! Many small artifacts correctd.
2010-01-05 00:40 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbqt/tests/demoqt.prg

View File

@@ -238,8 +238,6 @@ CLASS HbIde
METHOD createTags()
METHOD manageFocusInEditor()
METHOD convertSelection()
METHOD insertText()
METHOD loadUI()
METHOD setCodec()
@@ -324,6 +322,7 @@ METHOD HbIde:create( cProjIni )
::oDlg:Show()
/* Fill various elements of the IDE */
::cWrkProject := ::aINI[ INI_HBIDE, CurrentProject ]
::oPM:populate()
::loadSources()
::updateProjectMenu()
@@ -400,7 +399,7 @@ METHOD HbIde:create( cProjIni )
/*----------------------------------------------------------------------*/
METHOD HbIde:execAction( cKey )
LOCAL aPrj, cHbi, Tmp, n
LOCAL aPrj, cHbi, cTmp, n, aSrc
DO CASE
CASE cKey == "Exit"
@@ -422,25 +421,24 @@ METHOD HbIde:execAction( cKey )
CASE cKey == "SaveRebuildLaunch"
::oPM:buildProject( '', .T., .T. )
CASE cKey == "Compile"
//
CASE cKey == "CompilePPO"
::oPM:buildProject( '', .F., .F., .T. )
CASE cKey == "Properties"
IF Empty( ::cWrkProject )
MsgBox( 'No active project detected!' )
End
Tmp := ::oPM:getCurrentProject()
IF ( n := ascan( ::aProjects, {|e_| e_[ 3, PRJ_PRP_PROPERTIES, 2, E_oPrjTtl ] == Tmp } ) ) > 0
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 ] + s_pathSep + ;
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: ' + Tmp )
MsgBox( 'Invalid project: ' + cTmp )
End
CASE cKey == "SelectProject"
@@ -451,10 +449,8 @@ METHOD HbIde:execAction( cKey )
CASE cKey == "New"
::editSource( '' )
CASE cKey == "Open"
Tmp := ::selectSource( "openmany" )
IF !Empty( Tmp )
aEval( Tmp, {|f| ::editSource( f ) })
IF !empty( aSrc := ::selectSource( "openmany" ) )
aEval( aSrc, {|e| ::editSource( e ) } )
ENDIF
CASE cKey == "Save"
::saveSource( ::getCurrentTab() )
@@ -472,38 +468,24 @@ METHOD HbIde:execAction( cKey )
::closeAllSources()
CASE cKey == "CloseOther"
::closeAllOthers()
CASE cKey == "Print"
::oED:printPreview()
CASE cKey == "Undo"
IF !empty( ::qCurEdit )
::qCurEdit:undo()
ENDIF
::oED:undo()
CASE cKey == "Redo"
IF !empty( ::qCurEdit )
::qCurEdit:redo()
ENDIF
::oED:redo()
CASE cKey == "Cut"
IF !empty( ::qCurEdit )
::qCurEdit:cut()
ENDIF
::oED:cut()
CASE cKey == "Copy"
IF !empty( ::qCurEdit )
::qCurEdit:copy()
ENDIF
::oED:copy()
CASE cKey == "Paste"
IF !empty( ::qCurEdit )
::qCurEdit:paste()
ENDIF
::oED:paste()
CASE cKey == "SelectAll"
IF !empty( ::qCurEdit )
::qCurEdit:selectAll()
ENDIF
::oED:selectAll()
CASE cKey == "switchReadOnly"
IF !empty( ::qCurEdit )
::qCurEdit:setReadOnly( !::qCurEdit:isReadOnly() )
::oCurEditor:setTabImage()
ENDIF
::oED:switchToReadOnly()
CASE cKey == "Find"
IF !Empty( ::qCurEdit )
::oFR:show()
@@ -513,25 +495,21 @@ METHOD HbIde:execAction( cKey )
CASE cKey == "Goto"
::oED:goto()
CASE cKey == "ToUpper"
::convertSelection( cKey )
::oED:convertSelection( cKey )
CASE cKey == "ToLower"
::convertSelection( cKey )
::oED:convertSelection( cKey )
CASE cKey == "Invert"
::convertSelection( cKey )
::oED:convertSelection( cKey )
CASE cKey == "InsertDateTime"
::insertText( cKey )
::oED:insertText( cKey )
CASE cKey == "InsertRandomName"
::insertText( cKey )
::oED:insertText( cKey )
CASE cKey == "InsertExternalFile"
::insertText( cKey )
::oED:insertText( cKey )
CASE cKey == "ZoomIn"
IF !empty( ::qCurEdit )
//::qCurEdit:zoomIn()
ENDIF
::oED:zoom( cKey )
CASE cKey == "ZoomOut"
IF !empty( ::qCurEdit )
//::qCurEdit:zoomOut()
ENDIF
::oED:zoom( cKey )
CASE cKey == "ToggleProjectTree"
::lProjTreeVisible := !::lProjTreeVisible
@@ -562,10 +540,6 @@ METHOD HbIde:execAction( cKey )
ENDIF
::lDockRVisible := !( ::lDockRVisible )
CASE cKey == "Compile"
CASE cKey == "CompilePPO"
ENDCASE
::manageFocusInEditor()
@@ -574,111 +548,6 @@ METHOD HbIde:execAction( cKey )
/*----------------------------------------------------------------------*/
METHOD HbIde:convertSelection( cKey )
LOCAL cBuffer, i, s, nLen, c
LOCAL nB, nL
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
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD HbIde:insertText( cKey )
LOCAL b, c, t, n
LOCAL nB, nL
IF Empty( ::qCurEdit )
RETURN Self
ENDIF
::qCursor := QTextCursor():configure( ::qCurEdit:textCursor() )
DO CASE
CASE cKey == "InsertDateTime"
b := DTOC( Date() ) + ' - ' + Time()
CASE cKey == "InsertRandomName"
b := ''
t := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
WHILE Len(b) <> 10
c := Subst( t, HB_RANDOMINT( 1, Len(t) ), 1 )
IF !( c $ b )
IF Empty(b) .AND. IsDigit(c)
LOOP
ENDIF
b += c
ENDIF
End
b += '('
CASE cKey == "InsertExternalFile"
n := ::selectSource( "open" )
IF Empty(n) .OR. !hb_FileExists( n )
RETURN Self
ENDIF
msgbox(n)
IF !( hbide_isValidText( n ) )
MsgBox( 'File type unknown or unsupported: ' + n )
RETURN Self
ENDIF
b := hb_memoread( n )
OTHERWISE
RETURN Self
ENDCASE
IF !Empty( b )
nL := len( b )
nB := ::qCursor:position() + nL
::qCursor:beginEditBlock()
::qCursor:removeSelectedText()
::qCursor:insertText( b )
::qCursor:setPosition( nB )
::qCursor:endEditBlock()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD HbIde:setPosAndSizeByIni( qWidget, nPart )
LOCAL aRect

View File

@@ -322,7 +322,7 @@ FUNCTION buildMainMenu( oWnd, oIde )
/*----------------------------------------------------------------------------*/
oSubMenu := XbpMenu():new( oMenuBar ):create()
oSubMenu:title := "~Project"
oSubMenu:addItem( { _T( "Properties" ) , {|| oIde:execAction( "Properties" ) } } )
oSubMenu:addItem( { _T( "Properties" ) , {|| oIde:execAction( "Properties" ) } } )
hbide_menuAddSep( oSubMenu )
oSubMenu:addItem( { _T( "Add File* | projectadd.png" ) , {|| oIde:execAction( "" ) } } )
oSubMenu:addItem( { _T( "Remove File* | projectdel.png" ) , {|| oIde:execAction( "" ) } } )
@@ -330,7 +330,7 @@ FUNCTION buildMainMenu( oWnd, oIde )
oSubMenu:disableItem( oSubMenu:numItems )
hbide_menuAddSep( oSubMenu )
oSubMenu:addItem( { _T( "Change Current Project" ) , {|| oIde:execAction( "SelectProject" ) } } )
oSubMenu:addItem( { _T( "Close Current Project" ) , {|| oIde:execAction( "CloseProject" ) } } )
oSubMenu:addItem( { _T( "Close Current Project" ) , {|| oIde:execAction( "CloseProject" ) } } )
oMenuBar:addItem( { oSubMenu, NIL } )
/*----------------------------------------------------------------------------*/
@@ -344,7 +344,7 @@ FUNCTION buildMainMenu( oWnd, oIde )
oSubMenu:addItem( { _T( "Re-build and Launch, Sh+^F9 | rebuildlaunch.png" ), {|| oIde:execAction( "SaveRebuildLaunch" ) } } )
hbide_menuAddSep( oSubMenu )
oSubMenu:addItem( { _T( "Save and Compile Current File | compile.png") , {|| oIde:execAction( "SaveCompileCurrent" ) } } )
oSubMenu:addItem( { _T( "Save and Compile to PPO | ppo.png" ) , {|| oIde:execAction( "CompilePPO" ) } } )
oSubMenu:addItem( { _T( "Save and Compile to PPO | ppo.png" ) , {|| oIde:execAction( "CompilePPO" ) } } )
hbide_menuAddSep( oSubMenu )
oSubMenu:addItem( { _T( "Launch, ^F10" ) , {|| oIde:execAction( "LaunchProject" ) } } )
* oSubMenu:addItem( { _T( "Run without Debug*, Sh+^F10 | runnodebug.png" ), {|| oIde:execAction( "" ) } } )
@@ -370,7 +370,7 @@ FUNCTION buildMainMenu( oWnd, oIde )
/*----------------------------------------------------------------------------*/
oSubMenu := XbpMenu():new( oMenuBar ):create()
oSubMenu:title := "~Options"
oSubMenu:addItem( { _T( "Themes" ) , {|| oIde:oThemes:fetch() } } )
oSubMenu:addItem( { _T( "Themes" ) , {|| oIde:oThemes:fetch() } } )
oMenuBar:addItem( { oSubMenu, NIL } )
/*----------------------------------------------------------------------------*/

View File

@@ -79,11 +79,25 @@ CLASS IdeEditsManager INHERIT IdeObject
METHOD create()
METHOD goto()
METHOD undo()
METHOD redo()
METHOD cut()
METHOD copy()
METHOD paste()
METHOD selectAll()
METHOD switchToReadOnly()
METHOD insertText()
METHOD printPreview()
METHOD paintRequested()
METHOD showPPO()
METHOD closePPO()
METHOD convertSelection()
METHOD zoom()
ENDCLASS
/*----------------------------------------------------------------------*/
@@ -106,6 +120,176 @@ METHOD IdeEditsManager:create( oIde )
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:undo()
IF !empty( ::qCurEdit )
::qCurEdit:undo()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:redo()
IF !empty( ::qCurEdit )
::qCurEdit:redo()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:cut()
IF !empty( ::qCurEdit )
::qCurEdit:cut()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:copy()
IF !empty( ::qCurEdit )
::qCurEdit:copy()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:paste()
IF !empty( ::qCurEdit )
::qCurEdit:paste()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:selectAll()
IF !empty( ::qCurEdit )
::qCurEdit:selectAll()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:switchToReadOnly()
IF !empty( ::qCurEdit )
::qCurEdit:setReadOnly( !( ::qCurEdit:isReadOnly() ) )
::oCurEditor:setTabImage()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:convertSelection( cKey )
LOCAL cBuffer, i, s, nLen, c, nB, nL, qCursor
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
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:insertText( cKey )
LOCAL nB, nL, qCursor, cFile, cText
IF Empty( ::qCurEdit )
RETURN Self
ENDIF
qCursor := QTextCursor():configure( ::qCurEdit:textCursor() )
DO CASE
CASE cKey == "InsertDateTime"
cText := DTOC( Date() ) + ' - ' + Time()
CASE cKey == "InsertRandomName"
cText := hbide_getUniqueFuncName()
CASE cKey == "InsertExternalFile"
cFile := ::selectSource( "open" )
IF Empty( cFile ) .OR. !hb_FileExists( cFile )
RETURN Self
ENDIF
IF !( hbide_isValidText( cFile ) )
MsgBox( 'File type unknown or unsupported: ' + cFile )
RETURN Self
ENDIF
cText := hb_memoread( cFile )
OTHERWISE
RETURN Self
ENDCASE
IF !Empty( cText )
nL := len( cText )
nB := qCursor:position() + nL
qCursor:beginEditBlock()
qCursor:removeSelectedText()
qCursor:insertText( cText )
qCursor:setPosition( nB )
qCursor:endEditBlock()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:zoom( cKey )
IF empty( ::qCurEdit )
RETURN Self
ENDIF
IF upper( cKey ) == "ZOOMIN"
ELSEIF upper( cKey ) == "ZOOMOUT"
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
#if 0
METHOD IdeEditsManager:()
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:()
RETURN Self
#endif
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:printPreview()
LOCAL qDlg

View File

@@ -913,3 +913,24 @@ FUNCTION hbide_help( nOption )
/*----------------------------------------------------------------------*/
FUNCTION hbide_getUniqueFuncName()
LOCAL t, b, c, n
t := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
n := len( t )
b := ''
WHILE Len( b ) <> 10
c := Substr( t, HB_RANDOMINT( 1, n ), 1 )
IF !( c $ b )
IF Empty( b ) .AND. IsDigit( c )
LOOP
ENDIF
b += c
ENDIF
End
b += '( '
RETURN b
/*----------------------------------------------------------------------*/

View File

@@ -84,6 +84,7 @@ CLASS IdeObject
ACCESS oDK INLINE ::oIde:oDK
ACCESS qCurEdit INLINE ::oIde:qCurEdit
ACCESS oCurEditor INLINE ::oIde:oCurEditor
ACCESS qTabWidget INLINE ::oIde:oDA:oTabWidget:oWidget
ACCESS cWrkProject INLINE ::oIde:cWrkProject

View File

@@ -604,12 +604,7 @@ METHOD IdeProjManager:buildProjectViaQt( cProject )
METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
LOCAL cOutput, cErrors, n, aPrj, cHbpPath, aHbp, qStringList
LOCAL cTmp, nResult
LOCAL nseconds
LOCAL cTargetFN
LOCAL cPath
LOCAL cFileName
LOCAL lDelHbp
LOCAL cTmp, nResult, nSeconds, cTargetFN, cPath, cFileName, lDelHbp
DEFAULT lLaunch TO .F.
DEFAULT lRebuild TO .F.
@@ -637,9 +632,6 @@ METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
cTargetFN := aPrj[ PRJ_PRP_PROPERTIES, 2, PRJ_PRP_LOCATION ] + ::pathSep + aPrj[ PRJ_PRP_PROPERTIES, 2, PRJ_PRP_OUTPUT ]
cTargetFN := hbide_pathToOSPath( cTargetFN )
// cTargetFN := StrTran( cTargetFN, '/', ::pathSep )
// cTargetFN := StrTran( cTargetFN, '\', ::pathSep )
/*
* Creates a temporary file to avoid erase the file. Hbp correct this project.
* 26/12/2009 - 04:17:56 - vailtom
@@ -648,7 +640,7 @@ METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
cHbpPath := cTargetFN + '.' + hb_md5( alltrim( str( seconds() ) ) ) + ".hbp"
ELSE
cHbpPath := cTargetFN + ".hbp"
End
ENDIF
DO CASE
CASE aPrj[ PRJ_PRP_PROPERTIES, 2, E_qPrjType ] == "Lib"
@@ -658,13 +650,13 @@ METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
ENDCASE
aadd( aHbp, "-o" + cTargetFN )
aadd( aHbp, "-q" )
aadd( aHbp, "-trace" )
aadd( aHbp, "-info" )
hbide_dbg( cTargetFN )
aadd( aHbp, "-q" )
aadd( aHbp, "-trace" )
aadd( aHbp, "-info" )
IF lRebuild
aadd( aHbp, "-rebuild" )
End
ENDIF
aeval( aPrj[ PRJ_PRP_FLAGS, 2 ], {|e| aadd( aHbp, e ) } )
@@ -676,10 +668,10 @@ hbide_dbg( cTargetFN )
n := ::getCurrentTab()
hb_FNameSplit( ::aTabs[ n, 5 ], @cPath, @cFileName, @cTmp )
hb_FNameSplit( ::aTabs[ n, TAB_SOURCEFILE ], @cPath, @cFileName, @cTmp )
IF !( lower( cTmp ) $ ".prg,?" )
MsgBox( 'Operation not supported for this file type: "'+cTmp+'"' )
MsgBox( 'Operation not supported for this file type: "' + cTmp + '"' )
RETURN Self
ENDIF
@@ -687,7 +679,7 @@ hbide_dbg( cTargetFN )
// TODO: We have to test if the current file is part of a project, and we
// pull your settings, even though this is not the active project - vailtom
aadd( aHbp, ::aTabs[ n, 5 ] )
aadd( aHbp, ::aTabs[ n, TAB_SOURCEFILE ] )
FErase( cFileName )
ENDIF
@@ -714,8 +706,6 @@ hbide_dbg( cTargetFN )
qStringList:append( cHbpPath )
::qProcess := QProcess():new()
//::qProcess:setProcessChannelMode( 0 )
//::qProcess:setReadChannel( 0 )
::cFileOut := hbide_pathToOSPath( cTargetFN + '.' + hb_md5( alltrim( str( seconds() ) ) ) + ".out" )
::cFileErr := hbide_pathToOSPath( cTargetFN + '.' + hb_md5( alltrim( str( seconds() ) ) ) + ".err" )

View File

@@ -84,7 +84,7 @@ FUNCTION hbide_saveINI( oIde )
aadd( txt_, "FunctionListVisible = " + IIF( oIde:lDockRVisible, "YES", "NO" ) )
aadd( txt_, "FunctionListGeometry = " + hbide_posAndSize( oIde:oFuncList:oWidget ) )
aadd( txt_, "RecentTabIndex = " + hb_ntos( oIde:qTabWidget:currentIndex() ) )
aadd( txt_, "CurrentProject = " + "" )
aadd( txt_, "CurrentProject = " + oIde:cWrkProject )
aadd( txt_, "GotoDialogGeometry = " + oIde:aIni[ INI_HBIDE, GotoDialogGeometry ] )
aadd( txt_, "PropsDialogGeometry = " + oIde:aIni[ INI_HBIDE, PropsDialogGeometry ] )
aadd( txt_, "FindDialogGeometry = " + oIde:aIni[ INI_HBIDE, FindDialogGeometry ] )