2010-01-09 15:39 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbide/hbide.ch
* contrib/hbide/hbide.hbp
* contrib/hbide/hbide.prg
* contrib/hbide/idemisc.prg
* contrib/hbide/ideobject.prg
* contrib/hbide/ideprojmanager.prg
+ contrib/hbide/idesources.prg
* contrib/hbide/projects/hbide.hbi
! Next round of reforms, may be second-last,
mainly concentrating on accessing the different
components with ease.
! Some formattig and code optimizations.
This commit is contained in:
@@ -17,6 +17,21 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-01-09 15:39 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* contrib/hbide/hbide.ch
|
||||
* contrib/hbide/hbide.hbp
|
||||
* contrib/hbide/hbide.prg
|
||||
* contrib/hbide/idemisc.prg
|
||||
* contrib/hbide/ideobject.prg
|
||||
* contrib/hbide/ideprojmanager.prg
|
||||
+ contrib/hbide/idesources.prg
|
||||
* contrib/hbide/projects/hbide.hbi
|
||||
! Next round of reforms, may be second-last,
|
||||
mainly concentrating on accessing the different
|
||||
components with ease.
|
||||
|
||||
! Some formattig and code optimizations.
|
||||
|
||||
2010-01-09 10:53 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* contrib/hbqt/hbqt_hbslots.cpp
|
||||
* contrib/hbqt/hbqt_hbslots.h
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
#define PRJ_PRP_FLAGS 2
|
||||
#define PRJ_PRP_SOURCES 3
|
||||
#define PRJ_PRP_METADATA 4
|
||||
|
||||
//
|
||||
#define PRJ_PRP_SECTIONS 4
|
||||
|
||||
#define PRJ_PRP_TYPE 1
|
||||
@@ -100,7 +100,7 @@
|
||||
#define PRJ_PRP_OUTPUT 6
|
||||
#define PRJ_PRP_LPARAMS 7
|
||||
#define PRJ_PRP_LPROGRAM 8
|
||||
|
||||
//
|
||||
#define PRJ_PRP_PRP_VRBLS 8
|
||||
|
||||
/* Project Properties array elements */
|
||||
|
||||
@@ -27,5 +27,6 @@ idesaveload.prg
|
||||
iderequests.prg
|
||||
idethemes.prg
|
||||
ideprojmanager.prg
|
||||
idesources.prg
|
||||
|
||||
ideparseexpr.c
|
||||
|
||||
@@ -113,13 +113,14 @@ CLASS HbIde
|
||||
ACCESS pSlots INLINE hbxbp_getSlotsPtr()
|
||||
ACCESS pEvents INLINE hbxbp_getEventsPtr()
|
||||
|
||||
DATA oPM
|
||||
DATA oFR
|
||||
DATA oDK
|
||||
DATA oED
|
||||
DATA oAC
|
||||
DATA oPM /* Project Manager */
|
||||
DATA oDK /* Main Window Components Manager */
|
||||
DATA oAC /* Actions Manager */
|
||||
DATA oED /* Editor Tabs Manager */
|
||||
DATA oSM /* Souces Manager */
|
||||
DATA oFR /* Find Replace Manager */
|
||||
|
||||
DATA aMeta INIT {} /* Holds current definition only */
|
||||
DATA aMeta INIT {} /* Holds current definition only */
|
||||
|
||||
DATA mp1, mp2, oXbp, nEvent
|
||||
DATA aTabs INIT {}
|
||||
@@ -220,18 +221,6 @@ CLASS HbIde
|
||||
METHOD manageFuncContext()
|
||||
METHOD manageProjectContext()
|
||||
|
||||
METHOD loadSources()
|
||||
METHOD openSource()
|
||||
METHOD editSource()
|
||||
METHOD selectSource()
|
||||
METHOD closeSource()
|
||||
METHOD closeAllSources()
|
||||
METHOD closeAllOthers()
|
||||
METHOD saveSource()
|
||||
METHOD saveAllSources()
|
||||
METHOD saveAndExit()
|
||||
METHOD revertSource()
|
||||
|
||||
METHOD updateFuncList()
|
||||
METHOD gotoFunction()
|
||||
|
||||
@@ -301,6 +290,9 @@ METHOD HbIde:create( cProjIni )
|
||||
/* Once create Find/Replace dialog */
|
||||
::oFR := IdeFindReplace():new():create( Self )
|
||||
|
||||
/* Sources Manager */
|
||||
::oSM := IdeSourcesManager():new( Self ):create()
|
||||
|
||||
/* Edits Manager */
|
||||
::oED := IdeEditsManager():new( Self ):create()
|
||||
|
||||
@@ -332,7 +324,7 @@ METHOD HbIde:create( cProjIni )
|
||||
/* Fill various elements of the IDE */
|
||||
::cWrkProject := ::aINI[ INI_HBIDE, CurrentProject ]
|
||||
::oPM:populate()
|
||||
::loadSources()
|
||||
::oSM:loadSources()
|
||||
::updateProjectMenu()
|
||||
::updateTitleBar()
|
||||
/* Set some last settings */
|
||||
@@ -357,7 +349,7 @@ METHOD HbIde:create( cProjIni )
|
||||
|
||||
IF ::nEvent == xbeP_Close
|
||||
hbide_saveINI( Self )
|
||||
::closeAllSources()
|
||||
::oSM:closeAllSources()
|
||||
EXIT
|
||||
|
||||
ELSEIF ::nEvent == xbeP_Keyboard
|
||||
@@ -370,7 +362,7 @@ METHOD HbIde:create( cProjIni )
|
||||
ENDIF
|
||||
|
||||
CASE ::mp1 == xbeK_ESC
|
||||
::closeSource()
|
||||
::oSM:closeSource()
|
||||
|
||||
CASE ::mp1 == xbeK_CTRL_G
|
||||
::oED:goto()
|
||||
@@ -462,25 +454,25 @@ METHOD HbIde:execAction( cKey )
|
||||
::oPM:closeProject()
|
||||
|
||||
CASE cKey == "New"
|
||||
::editSource( '' )
|
||||
::oSM:editSource( '' )
|
||||
CASE cKey == "Open"
|
||||
::openSource()
|
||||
::oSM:openSource()
|
||||
CASE cKey == "Save"
|
||||
::saveSource( ::getCurrentTab(), .f., .f. )
|
||||
CASE cKey == "SaveAs"
|
||||
::saveSource( ::getCurrentTab(), .t., .t. )
|
||||
::oSM:saveSource( ::getCurrentTab(), .t., .t. )
|
||||
CASE cKey == "SaveAll"
|
||||
::saveAllSources()
|
||||
::oSM:saveAllSources()
|
||||
CASE cKey == "SaveExit"
|
||||
::saveAndExit()
|
||||
::oSM:saveAndExit()
|
||||
CASE cKey == "Revert"
|
||||
::RevertSource()
|
||||
::oSM:RevertSource()
|
||||
CASE cKey == "Close"
|
||||
::closeSource()
|
||||
::oSM:closeSource()
|
||||
CASE cKey == "CloseAll"
|
||||
::closeAllSources()
|
||||
::oSM:closeAllSources()
|
||||
CASE cKey == "CloseOther"
|
||||
::closeAllOthers()
|
||||
::oSM:closeAllOthers()
|
||||
|
||||
CASE cKey == "Print"
|
||||
::oED:printPreview()
|
||||
@@ -601,338 +593,6 @@ METHOD HbIde:getCurCursor()
|
||||
|
||||
RETURN ::qCursor
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
// Source Editor
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD HbIde:loadSources()
|
||||
LOCAL a_
|
||||
|
||||
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
|
||||
::oED:setSourceVisibleByIndex( val( ::aIni[ INI_HBIDE, RecentTabIndex ] ) )
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Save selected Tab on harddisk and return .T. if successfull!
|
||||
*/
|
||||
METHOD HbIde:saveSource( nTab, lCancel, lAs )
|
||||
LOCAL oEdit, lNew, cBuffer, qDocument, nIndex, cSource, cFile, cExt, cNewFile
|
||||
LOCAL cFileToSave
|
||||
|
||||
DEFAULT nTab TO ::getCurrentTab()
|
||||
DEFAULT lAs TO .F.
|
||||
|
||||
lCancel := .F.
|
||||
|
||||
IF !empty( oEdit := ::oED:getEditorByTabPosition( nTab ) )
|
||||
cSource := oEdit:sourceFile
|
||||
lNew := Empty( cSource ) .OR. lAs
|
||||
IF lNew
|
||||
cNewFile := ::selectSource( 'save', ;
|
||||
iif( !Empty( cSource ), cSource, hb_dirBase() + "projects\" ),;
|
||||
"Save " + oEdit:oTab:caption + " as..." )
|
||||
IF empty( cNewFile )
|
||||
// will check later what decision to take
|
||||
RETURN .f.
|
||||
ENDIF
|
||||
IF hbide_pathNormalized( cNewFile ) == hbide_pathNormalized( cSource )
|
||||
lNew := .f.
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
cFileToSave := iif( lNew, cNewFile, cSource )
|
||||
qDocument := oEdit:qDocument
|
||||
|
||||
cBuffer := oEdit:qEdit:toPlainText()
|
||||
/*
|
||||
* If the burn process fails, we should change the name of the previous file.
|
||||
* 01/01/2010 - 21:24:41 - vailtom
|
||||
*/
|
||||
IF !hb_memowrit( cFileToSave, cBuffer )
|
||||
MsgBox( "Error saving the file " + oEdit:sourceFile + ".",, 'Error saving file!' )
|
||||
lCancel := .T.
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
|
||||
IF lNew
|
||||
hb_fNameSplit( cFileToSave, , @cFile, @cExt )
|
||||
|
||||
::aTabs[ nTab, TAB_SOURCEFILE ] := cFileToSave
|
||||
oEdit:sourceFile := cFileToSave
|
||||
|
||||
oEdit:oTab:Caption := cFile + cExt
|
||||
::qTabWidget:setTabText( nIndex, cFile + cExt )
|
||||
::qTabWidget:setTabTooltip( nIndex, cSource )
|
||||
ENDIF
|
||||
|
||||
IF empty( cSource )
|
||||
/* The file is not populated in editors tree. Inject */
|
||||
::addSourceInTree( oEdit:sourceFile )
|
||||
ELSEIF lNew
|
||||
/* Rename the existing nodes in tree */
|
||||
ENDIF
|
||||
|
||||
qDocument:setModified( .f. )
|
||||
::aSources := { oEdit:sourceFile }
|
||||
::createTags()
|
||||
::updateFuncList()
|
||||
nIndex := ::qTabWidget:indexOf( oEdit:oTab:oWidget )
|
||||
::qTabWidget:setTabIcon( nIndex, ::resPath + "tabunmodified.png" )
|
||||
::oSBar:getItem( SB_PNL_MODIFIED ):caption := " "
|
||||
ENDIF
|
||||
|
||||
RETURN .T.
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD HbIde:editSource( cSourceFile, nPos, nHPos, nVPos, cTheme, lAlert, lVisible )
|
||||
|
||||
DEFAULT lAlert TO .T.
|
||||
DEFAULT lVisible TO .T.
|
||||
|
||||
IF !Empty( cSourceFile )
|
||||
IF !( hbide_isValidText( cSourceFile ) )
|
||||
MsgBox( 'File type unknown or unsupported: ' + cSourceFile )
|
||||
RETURN Self
|
||||
ELSEIF !hb_FileExists( cSourceFile )
|
||||
MsgBox( 'File not found: ' + cSourceFile )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
IF ::oED:isOpen( cSourceFile )
|
||||
IF lAlert
|
||||
IF hbide_getYesNo( cSourceFile + " is already open.", ;
|
||||
"Want to re-load it again ?", "File Open Info!" )
|
||||
::oED:reLoad( cSourceFile )
|
||||
ENDIF
|
||||
ENDIF
|
||||
::oED:setSourceVisible( cSourceFile )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
DEFAULT nPos TO 0
|
||||
DEFAULT nHPos TO 0
|
||||
DEFAULT nVPos TO 0
|
||||
|
||||
::oED:buildEditor( cSourceFile, nPos, nHPos, nVPos, cTheme )
|
||||
IF lVisible
|
||||
::oED:setSourceVisible( cSourceFile )
|
||||
ENDIF
|
||||
|
||||
IF !Empty( cSourceFile ) .AND. !hbide_isSourcePPO( cSourceFile )
|
||||
hbide_mnuAddFileToMRU( Self, cSourceFile, INI_RECENTFILES )
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD HbIde:closeSource( nTab, lCanCancel, lCanceled )
|
||||
LOCAL lSave, n, oEdit
|
||||
|
||||
DEFAULT nTab TO ::getCurrentTab()
|
||||
|
||||
IF !empty( oEdit := ::oED:getEditorByTabPosition( nTab ) )
|
||||
|
||||
DEFAULT lCanCancel TO .F.
|
||||
lCanceled := .F.
|
||||
|
||||
IF !( oEdit:qDocument:isModified() )
|
||||
* File has not changed, ignore the question to User
|
||||
lSave := .F.
|
||||
|
||||
ELSEIF lCanCancel
|
||||
n := hbide_getYesNoCancel( oEdit:oTab:Caption, "Has been modified, save this source?", 'Save?' )
|
||||
IF ( lCanceled := ( n == QMessageBox_Cancel ) )
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
lSave := ( n == QMessageBox_Yes )
|
||||
|
||||
ELSE
|
||||
lSave := hbide_getYesNo( oEdit:oTab:Caption, "Has been modified, save this source?", 'Save?' )
|
||||
|
||||
ENDIF
|
||||
|
||||
IF lSave .AND. !( ::saveSource( nTab, @lCanceled ) )
|
||||
IF lCanCancel
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
oEdit:removeTabPage()
|
||||
ENDIF
|
||||
|
||||
RETURN .T.
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Close all opened files.
|
||||
* 02/01/2010 - 15:31:44
|
||||
*/
|
||||
METHOD HbIde:closeAllSources()
|
||||
LOCAL lCanceled
|
||||
LOCAL i := 0
|
||||
|
||||
DO WHILE ( ++i <= Len( ::aTabs ) )
|
||||
|
||||
IF ::closeSource( i, .T., @lCanceled )
|
||||
i --
|
||||
Loop
|
||||
ENDIF
|
||||
|
||||
IF lCanceled
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
ENDDO
|
||||
|
||||
RETURN .T.
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Close all opened files except current.
|
||||
* 02/01/2010 - 15:47:19
|
||||
*/
|
||||
METHOD HbIde:closeAllOthers( nTab )
|
||||
LOCAL lCanceled, a_
|
||||
|
||||
FOR EACH a_ IN ::aTabs
|
||||
IF a_:__enumIndex() != nTab
|
||||
::closeSource( a_:__enumIndex(), .T., @lCanceled )
|
||||
IF lCanceled
|
||||
RETURN .f.
|
||||
ENDIF
|
||||
ENDIF
|
||||
NEXT
|
||||
|
||||
RETURN .T.
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Save all opened files...
|
||||
* 01/01/2010 - 22:44:36 - vailtom
|
||||
*/
|
||||
METHOD HbIde:saveAllSources()
|
||||
LOCAL n
|
||||
|
||||
FOR n := 1 TO Len( ::aTabs )
|
||||
::saveSource( n )
|
||||
NEXT
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Save current file and exits HBIDE
|
||||
* 02/01/2010 - 18:45:06 - vailtom
|
||||
*/
|
||||
METHOD HbIde:saveAndExit()
|
||||
|
||||
IF ::saveSource()
|
||||
::execAction( "Exit" )
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Revert current file to a previous saved file.
|
||||
* 02/01/2010 - 19:45:34
|
||||
*/
|
||||
METHOD HbIde:revertSource( nTab )
|
||||
|
||||
DEFAULT nTab TO ::getCurrentTab()
|
||||
|
||||
IF nTab < 1
|
||||
RETURN .F.
|
||||
End
|
||||
|
||||
IF !::aTabs[ nTab, TAB_QDOCUMENT ]:isModified()
|
||||
* File has not changed, ignore the question to User
|
||||
ELSE
|
||||
IF !hbide_getYesNo( 'Revert ' + ::aTabs[ nTab, TAB_OTAB ]:Caption + '?', ;
|
||||
'The file ' + ::aTabs[ nTab, TAB_SOURCEFILE ] + ' has changed. '+;
|
||||
'Discard current changes and revert contents to the previously saved on disk?', 'Revert file?' )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
::aTabs[ nTab, TAB_QEDIT ]:setPlainText( hb_memoRead( ::aTabs[ nTab, TAB_SOURCEFILE ] ) )
|
||||
::aTabs[ nTab, TAB_QEDIT ]:ensureCursorVisible()
|
||||
::manageFocusInEditor()
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD HbIde:openSource()
|
||||
LOCAL aSrc, cSource
|
||||
|
||||
IF !empty( aSrc := ::selectSource( "openmany" ) )
|
||||
FOR EACH cSource IN aSrc
|
||||
::editSource( cSource )
|
||||
NEXT
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD HbIde:selectSource( cMode, cFile, cTitle )
|
||||
LOCAL oDlg, cPath
|
||||
|
||||
oDlg := XbpFileDialog():new():create( ::oDa, , { 10,10 } )
|
||||
IF cMode == "open"
|
||||
oDlg:title := "Select a Source File"
|
||||
oDlg:center := .t.
|
||||
oDlg:fileFilters := { { "All Files" , "*.*" }, { "PRG Sources", "*.prg" }, { "C Sources" , "*.c" },;
|
||||
{ "CPP Sources", "*.cpp" }, { "H Headers" , "*.h" }, { "CH Headers", "*.ch" } }
|
||||
cFile := oDlg:open( , , .f. )
|
||||
|
||||
ELSEIF cMode == "openmany"
|
||||
oDlg:title := "Select Sources"
|
||||
oDlg:center := .t.
|
||||
oDlg:defExtension:= 'prg'
|
||||
oDlg:fileFilters := { { "All Files" , "*.*" }, { "PRG Sources", "*.prg" }, { "C Sources" , "*.c" },;
|
||||
{ "CPP Sources", "*.cpp" }, { "H Headers" , "*.h" }, { "CH Headers", "*.ch" } }
|
||||
cFile := oDlg:open( , , .t. )
|
||||
|
||||
ELSEIF cMode == "save"
|
||||
oDlg:title := iif( !hb_isChar( cTitle ), "Save as...", cTitle )
|
||||
oDlg:center := .t.
|
||||
oDlg:defExtension:= 'prg'
|
||||
|
||||
IF hb_isChar( cFile ) .AND. !Empty( cFile )
|
||||
IF Right( cFile, 1 ) $ '/\'
|
||||
cPath := cFile
|
||||
ELSE
|
||||
hb_fNameSplit( cFile, @cPath )
|
||||
Endif
|
||||
Endif
|
||||
|
||||
oDlg:fileFilters := { { "PRG Sources", "*.prg" }, { "C Sources", "*.c" }, { "CPP Sources", "*.cpp" }, ;
|
||||
{ "H Headers", "*.h" }, { "CH Headers", "*.ch" } }
|
||||
cFile := oDlg:saveAs( cPath )
|
||||
|
||||
ELSE
|
||||
oDlg:title := "Save this Database"
|
||||
oDlg:fileFilters := { { "Database Files", "*.dbf" } }
|
||||
oDlg:quit := {|| MsgBox( "Quitting the Dialog" ), 1 }
|
||||
cFile := oDlg:saveAs( "myfile.dbf" )
|
||||
IF !empty( cFile )
|
||||
hbide_dbg( cFile )
|
||||
ENDIF
|
||||
|
||||
ENDIF
|
||||
|
||||
RETURN cFile
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD HbIde:getCurrentTab()
|
||||
@@ -1210,7 +870,7 @@ METHOD HbIde:manageProjectContext( mp1, mp2, oXbpTreeItem )
|
||||
aadd( aPops, { "Close" , {|| ::closeSource( n ) } } )
|
||||
aadd( aPops, { "Close Others" , {|| ::closeAllOthers( n ) } } )
|
||||
aadd( aPops, { "" } )
|
||||
aadd( aPops, { "Apply Theme", {|| ::aTabs[ n, TAB_OEDITOR ]:applyTheme() } } )
|
||||
aadd( aPops, { "Apply Theme" , {|| ::aTabs[ n, TAB_OEDITOR ]:applyTheme() } } )
|
||||
//
|
||||
hbide_ExecPopup( aPops, mp1, ::oProjTree:oWidget )
|
||||
|
||||
|
||||
@@ -380,7 +380,7 @@ STATIC FUNCTION hbide_pullHbiStruct( a_ )
|
||||
|
||||
CASE nPart == PRJ_PRP_SOURCES
|
||||
aadd( a3_0, s )
|
||||
//HB_TRACE( HB_TR_ALWAYS, s )
|
||||
|
||||
CASE nPart == PRJ_PRP_METADATA
|
||||
aadd( a4_0, s )
|
||||
IF !( "#" == left( s,1 ) )
|
||||
@@ -410,7 +410,6 @@ STATIC FUNCTION hbide_pullHbiStruct( a_ )
|
||||
/* Parse Files */
|
||||
IF !empty( a3_0 )
|
||||
FOR EACH s IN a3_0
|
||||
//HB_TRACE( HB_TR_ALWAYS, "Files ", s )
|
||||
IF !( "#" == left( s,1 ) ) .and. !empty( s )
|
||||
aadd( a3_1, hbide_parseWithMetaData( s, a4_1 ) )
|
||||
ENDIF
|
||||
|
||||
@@ -84,6 +84,7 @@ CLASS IdeObject
|
||||
ACCESS oPM INLINE ::oIde:oPM
|
||||
ACCESS oDK INLINE ::oIde:oDK
|
||||
ACCESS oAC INLINE ::oIde:oAC
|
||||
ACCESS oSM INLINE ::oIde:oSC
|
||||
|
||||
ACCESS aMeta INLINE ::oIde:aMeta
|
||||
|
||||
@@ -145,6 +146,9 @@ CLASS IdeObject
|
||||
|
||||
ERROR HANDLER OnError()
|
||||
|
||||
METHOD getCurrentTab() INLINE ::oIde:getCurrentTab()
|
||||
METHOD editSource( ... ) INLINE ::oIde:oSM:editSource( ... )
|
||||
|
||||
ENDCLASS
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -84,6 +84,67 @@
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
CLASS IdeProject
|
||||
|
||||
DATA aProjProps INIT {}
|
||||
|
||||
DATA fileName INIT ""
|
||||
DATA normalizedName INIT ""
|
||||
|
||||
DATA type INIT "Executable"
|
||||
DATA title INIT ""
|
||||
DATA location INIT hb_dirBase() + "projects"
|
||||
DATA wrkDirectory INIT hb_dirBase() + "projects"
|
||||
DATA destination INIT hb_dirBase() + "projects"
|
||||
DATA outputName INIT hb_dirBase() + "projects"
|
||||
DATA launchParams INIT ""
|
||||
DATA launchProgram INIT ""
|
||||
DATA hbpFlags INIT ""
|
||||
DATA sources INIT {}
|
||||
DATA metaData INIT {}
|
||||
DATA dotHbp INIT ""
|
||||
DATA compilers INIT ""
|
||||
|
||||
METHOD new()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeProject:new( aProps )
|
||||
LOCAL b_, a_
|
||||
|
||||
IF hb_isArray( aProps )
|
||||
::aProjProps := aProps
|
||||
|
||||
b_:= aProps[ 3 ]
|
||||
|
||||
::normalizedName := b_[ 1 ]
|
||||
::fileName := b_[ 2 ]
|
||||
|
||||
a_:= b_[ PRJ_PRP_PROPERTIES, 2 ]
|
||||
|
||||
::type := a_[ E_qPrjType ]
|
||||
::title := a_[ E_oPrjTtl ]
|
||||
::location := a_[ E_oPrjLoc ]
|
||||
::wrkDirectory := a_[ E_oPrjWrk ]
|
||||
::destination := a_[ E_oPrjDst ]
|
||||
::outputName := a_[ E_oPrjOut ]
|
||||
::launchParams := a_[ E_oPrjLau ]
|
||||
::launchProgram := a_[ E_oPrjLEx ]
|
||||
|
||||
::hbpFlags := b_[ PRJ_PRP_FLAGS , 2 ]
|
||||
::sources := b_[ PRJ_PRP_SOURCES , 2 ]
|
||||
::metaData := b_[ PRJ_PRP_METADATA, 2 ]
|
||||
::dotHbp := ""
|
||||
::compilers := ""
|
||||
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
CLASS IdeProjManager INHERIT IdeObject
|
||||
|
||||
DATA cSaveTo
|
||||
@@ -96,6 +157,7 @@ CLASS IdeProjManager INHERIT IdeObject
|
||||
DATA cProjectInProcess INIT ""
|
||||
DATA cPPO INIT ""
|
||||
DATA lPPO INIT .f.
|
||||
DATA oProject
|
||||
|
||||
METHOD new()
|
||||
METHOD create()
|
||||
@@ -114,8 +176,10 @@ CLASS IdeProjManager INHERIT IdeObject
|
||||
METHOD promptForPath()
|
||||
METHOD launchProject()
|
||||
METHOD buildProject()
|
||||
METHOD buildProjectViaQt()
|
||||
METHOD readProcessInfo()
|
||||
METHOD getProjectProperties()
|
||||
METHOD getProject()
|
||||
METHOD buildProcess()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
@@ -503,15 +567,19 @@ METHOD IdeProjManager:setCurrentProject( cProjectName )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeProjManager:getCurrentProject()
|
||||
METHOD IdeProjManager:getCurrentProject( lAlert )
|
||||
|
||||
DEFAULT lAlert TO .t.
|
||||
|
||||
IF !Empty( ::cWrkProject )
|
||||
RETURN ::cWrkProject
|
||||
ENDIF
|
||||
|
||||
IF Empty( ::aProjects )
|
||||
MsgBox( "No longer available projects!" )
|
||||
RETURN ::cWrkProject
|
||||
IF lAlert
|
||||
MsgBox( "No Projects Available" )
|
||||
ENDIF
|
||||
RETURN ""
|
||||
ENDIF
|
||||
|
||||
IF Len( ::aProjects ) == 1
|
||||
@@ -527,7 +595,7 @@ METHOD IdeProjManager:selectCurrentProject()
|
||||
LOCAL oDlg, i, p, t
|
||||
|
||||
IF Empty( ::aProjects )
|
||||
MsgBox( "No longer available projects!" )
|
||||
MsgBox( "No Projects Available" )
|
||||
RETURN ::cWrkProject
|
||||
ENDIF
|
||||
|
||||
@@ -557,11 +625,33 @@ METHOD IdeProjManager:selectCurrentProject()
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeProjManager:getProjectProperties( cProject )
|
||||
LOCAL n
|
||||
|
||||
IF ( n := ascan( ::aProjects, {|e_, x| x := e_[ 3 ], x[ 1, 2, PRJ_PRP_TITLE ] == cProject } ) ) > 0
|
||||
RETURN ::aProjects[ n, 3 ]
|
||||
ENDIF
|
||||
|
||||
RETURN {}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeProjManager:getProject( cProject )
|
||||
LOCAL n, aProj
|
||||
|
||||
IF ( n := ascan( ::aProjects, {|e_, x| x := e_[ 3 ], x[ 1, 2, PRJ_PRP_TITLE ] == cProject } ) ) > 0
|
||||
aProj := ::aProjects[ n ]
|
||||
ENDIF
|
||||
|
||||
RETURN IdeProject():new( aProj )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeProjManager:closeProject( cProject )
|
||||
LOCAL nPos
|
||||
|
||||
IF Empty( ::aProjects )
|
||||
MsgBox( "No longer available projects!" )
|
||||
MsgBox( "No Projects Available" )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
|
||||
@@ -629,17 +719,10 @@ METHOD IdeProjManager:promptForPath( cObjPathName, cTitle, cObjFileName, cObjPat
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeProjManager:buildProjectViaQt( cProject )
|
||||
|
||||
::buildProject( cProject, , , , .t. )
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
|
||||
LOCAL cOutput, cErrors, n, aPrj, cHbpPath, aHbp, qStringList, oEdit
|
||||
LOCAL cTmp, nResult, nSeconds, cTargetFN, lDelHbp
|
||||
LOCAL cOutput, cErrors, cHbpPath, qStringList, oEdit
|
||||
LOCAL cTmp, nResult, cTargetFN
|
||||
LOCAL aHbp := {}
|
||||
|
||||
DEFAULT lLaunch TO .F.
|
||||
DEFAULT lRebuild TO .F.
|
||||
@@ -650,60 +733,71 @@ METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
|
||||
::lLaunch := lLaunch
|
||||
::cProjectInProcess := cProject
|
||||
|
||||
lDelHbp := lPPO
|
||||
|
||||
IF lPPO .AND. ::getCurrentTab() == 0
|
||||
MsgBox( 'No file open issue to be compiled!' )
|
||||
RETURN Self
|
||||
End
|
||||
IF empty( cProject )
|
||||
cProject := ::getCurrentProject()
|
||||
ENDIF
|
||||
IF empty( cProject )
|
||||
IF ::lPPO .AND. ::getCurrentTab() == 0
|
||||
MsgBox( 'No source available to be compiled' )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
IF empty( cProject )
|
||||
cProject := ::getCurrentProject( .f. )
|
||||
ENDIF
|
||||
IF empty( cProject ) .AND. !( ::lPPO )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
IF ::lPPO
|
||||
lRebuild := .t.
|
||||
ENDIF
|
||||
|
||||
n := ascan( ::aProjects, {|e_, x| x := e_[ 3 ], x[ 1, 2, PRJ_PRP_TITLE ] == cProject } )
|
||||
aPrj := ::aProjects[ n, 3 ]
|
||||
aHbp := {}
|
||||
::oProject := ::getProject( cProject )
|
||||
|
||||
cTargetFN := aPrj[ PRJ_PRP_PROPERTIES, 2, PRJ_PRP_LOCATION ] + ::pathSep + aPrj[ PRJ_PRP_PROPERTIES, 2, PRJ_PRP_OUTPUT ]
|
||||
cTargetFN := hbide_pathToOSPath( cTargetFN )
|
||||
//cTargetFN := aPrj[ PRJ_PRP_PROPERTIES, 2, PRJ_PRP_LOCATION ] + ::pathSep + aPrj[ PRJ_PRP_PROPERTIES, 2, PRJ_PRP_OUTPUT ]
|
||||
cTargetFN := hbide_pathToOSPath( ::oProject:location + ::pathSep + ;
|
||||
iif( empty( ::oProject:outputName ), "_temp", ::oProject:outputName ) )
|
||||
/*
|
||||
* Creates a temporary file to avoid erase the file. Hbp correct this project.
|
||||
* 26/12/2009 - 04:17:56 - vailtom
|
||||
*/
|
||||
IF lDelHbp
|
||||
cHbpPath := cTargetFN + '.' + hb_md5( alltrim( str( seconds() ) ) ) + ".hbp"
|
||||
ELSE
|
||||
cHbpPath := cTargetFN + ".hbp"
|
||||
//cHbpPath := cTargetFN + iif( ::lPPO, '.' + hb_md5( hb_ntos( seconds() ) ), "" ) + ".hbp"
|
||||
cHbpPath := cTargetFN + iif( ::lPPO, '._tmp', "" ) + ".hbp"
|
||||
|
||||
IF !( ::lPPO )
|
||||
IF ::oProject:type == "Lib"
|
||||
aadd( aHbp, "-hblib" )
|
||||
ELSEIF ::oProject:type == "Dll"
|
||||
aadd( aHbp, "-hbdyn" )
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
DO CASE
|
||||
CASE aPrj[ PRJ_PRP_PROPERTIES, 2, E_qPrjType ] == "Lib"
|
||||
aadd( aHbp, "-hblib" )
|
||||
CASE aPrj[ PRJ_PRP_PROPERTIES, 2, E_qPrjType ] == "Dll"
|
||||
aadd( aHbp, "-hbdyn" )
|
||||
ENDCASE
|
||||
|
||||
aadd( aHbp, "-o" + cTargetFN )
|
||||
aadd( aHbp, "# User Supplied Flags" )
|
||||
aadd( aHbp, " " )
|
||||
aeval( ::oProject:hbpFlags, {|e| aadd( aHbp, e ) } )
|
||||
aadd( aHbp, " " )
|
||||
aadd( aHbp, "# hbIDE Supplied Flags" )
|
||||
aadd( aHbp, " " )
|
||||
IF !( ::lPPO )
|
||||
aadd( aHbp, "-o" + cTargetFN )
|
||||
ENDIF
|
||||
aadd( aHbp, "-q" )
|
||||
aadd( aHbp, "-trace" )
|
||||
aadd( aHbp, "-info" )
|
||||
|
||||
IF lRebuild
|
||||
aadd( aHbp, "-rebuild" )
|
||||
aadd( aHbp, "-rebuild" )
|
||||
ENDIF
|
||||
|
||||
aeval( aPrj[ PRJ_PRP_FLAGS, 2 ], {|e| aadd( aHbp, e ) } )
|
||||
aadd( aHbp, " " )
|
||||
|
||||
IF !( ::lPPO )
|
||||
aeval( hbide_filesToSources( aPrj[ PRJ_PRP_SOURCES, 2 ] ), {|e| aadd( aHbp, e ) } )
|
||||
aadd( aHbp, "# Source Files" )
|
||||
aadd( aHbp, " " )
|
||||
aeval( hbide_filesToSources( ::oProject:sources ), {|e| aadd( aHbp, e ) } )
|
||||
|
||||
ELSE
|
||||
IF !empty( oEdit := ::oED:getEditorCurrent() )
|
||||
IF hbide_isSourcePRG( oEdit:sourceFile )
|
||||
aadd( aHbp, "-hbcmp -s -p" )
|
||||
aadd( aHbp, "-hbcmp" )
|
||||
aadd( aHbp, "-s" )
|
||||
aadd( aHbp, "-p" )
|
||||
aadd( aHbp, " " )
|
||||
aadd( aHbp, "# Source File - PPO" )
|
||||
aadd( aHbp, " " )
|
||||
|
||||
// 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
|
||||
@@ -713,7 +807,7 @@ METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
|
||||
FErase( ::cPPO )
|
||||
|
||||
ELSE
|
||||
MsgBox( 'Operation not supported for this file type: "' + cTmp + '"' )
|
||||
MsgBox( 'Operation not supported for this file type: "' + oEdit:sourceFile + '"' )
|
||||
RETURN Self
|
||||
|
||||
ENDIF
|
||||
@@ -722,15 +816,15 @@ METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
::lDockBVisible := .t.
|
||||
::oDockB2:show()
|
||||
::oOutputResult:oWidget:clear()
|
||||
|
||||
IF !hbide_createTarget( cHbpPath, aHbp )
|
||||
cTmp := 'Error saving: ' + cHbpPath
|
||||
::oOutputResult:oWidget:append( 'Error saving: ' + cHbpPath )
|
||||
|
||||
ELSE
|
||||
::lDockBVisible := .t.
|
||||
::oDockB2:show()
|
||||
::oOutputResult:oWidget:clear()
|
||||
|
||||
nSeconds := seconds() // time elapsed
|
||||
::nStarted := seconds()
|
||||
|
||||
cTmp := hbide_outputLine() + CRLF + ;
|
||||
"Project [ " + cProject + " ] " + ;
|
||||
@@ -738,25 +832,10 @@ METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
|
||||
"Rebuild [ " + iif( lRebuild, 'Yes', 'No' ) + " ] " + ;
|
||||
"Started [ " + time() + " ]" + CRLF + ;
|
||||
hbide_outputLine() + CRLF
|
||||
::oOutputResult:oWidget:append( cTmp )
|
||||
|
||||
IF lViaQt
|
||||
::qProcess := QProcess():new()
|
||||
::qProcess:setReadChannel( 1 )
|
||||
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "readyRead()" , {|o,i| ::readProcessInfo( CHN_REA, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "readChannelFinished()" , {|o,i| ::readProcessInfo( CHN_RCF, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "aboutToClose()" , {|o,i| ::readProcessInfo( CHN_CLO, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "bytesWritten(int)" , {|o,i| ::readProcessInfo( CHN_BYT, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "stateChanged(int)" , {|o,i| ::readProcessInfo( CHN_STT, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "error(int)" , {|o,i| ::readProcessInfo( CHN_ERE, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "started()" , {|o,i| ::readProcessInfo( CHN_BGN, o, i ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "readyReadStandardOutput()", {|o,i| ::readProcessInfo( CHN_OUT, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "readyReadStandardError()" , {|o,i| ::readProcessInfo( CHN_ERR, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "finished(int,int)" , {|o,i,ii| ::readProcessInfo( CHN_FIN, i, ii, o ) } )
|
||||
|
||||
::oOutputResult:oWidget:clear()
|
||||
::oOutputResult:oWidget:append( cTmp )
|
||||
::nStarted := seconds()
|
||||
::buildProcess()
|
||||
|
||||
#if 0 /* Mechanism to supply environment variables to called process */
|
||||
/* I do not know nixes but assume that Qt must be issueing proper */
|
||||
@@ -777,19 +856,21 @@ METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
|
||||
qStringList := QStringList():new()
|
||||
qStringList:append( cHbpPath )
|
||||
//
|
||||
::qProcess:setWorkingDirectory( ::oProject:wrkDirectory() )
|
||||
//
|
||||
::qProcess:start( "hbmk2", qStringList )
|
||||
#endif
|
||||
ELSE
|
||||
cOutput := "" ; cErrors := ""
|
||||
nResult := hb_processRun( ( "hbmk2 " + cHbpPath ), , @cOutput, @cErrors )
|
||||
|
||||
* Show detailed status about compile process...
|
||||
cTmp += cOutput + CRLF
|
||||
cTmp := cOutput + CRLF
|
||||
cTmp += IIF( empty( cErrors ), "", cErrors ) + CRLF
|
||||
cTmp += "errorlevel: " + hb_ntos( nResult ) + CRLF
|
||||
cTmp += '-----------------------------------------------------------------' + CRLF
|
||||
cTmp += 'Finished at ' + time() + CRLF
|
||||
cTmp += "Done in " + ltrim( str( seconds() - nseconds ) ) +" seconds." + CRLF
|
||||
cTmp += hbide_outputLine() + CRLF
|
||||
cTmp += "Exit Code [ " + hb_ntos( nResult ) + " ] " + ;
|
||||
"Finished at [ " + time() + " ] " + ;
|
||||
"Done in [ " + hb_ntos( seconds() - ::nStarted ) + " Secs ]" + CRLF
|
||||
cTmp += hbide_outputLine() + CRLF
|
||||
|
||||
hbide_convertBuildStatusMsgToHtml( cTmp, ::oOutputResult:oWidget )
|
||||
|
||||
@@ -798,13 +879,13 @@ METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
|
||||
ENDIF
|
||||
|
||||
IF ::lPPO .AND. hb_FileExists( ::cPPO )
|
||||
::oIde:editSource( ::cPPO )
|
||||
::editSource( ::cPPO )
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
ENDIF
|
||||
|
||||
IF lDelHbp
|
||||
IF ::lPPO
|
||||
FErase( cHbpPath )
|
||||
ENDIF
|
||||
|
||||
@@ -812,6 +893,26 @@ METHOD IdeProjManager:buildProject( cProject, lLaunch, lRebuild, lPPO, lViaQt )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeProjManager:buildProcess()
|
||||
|
||||
::qProcess := QProcess():new()
|
||||
::qProcess:setReadChannel( 1 )
|
||||
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "readyRead()" , {|o,i| ::readProcessInfo( CHN_REA, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "readChannelFinished()" , {|o,i| ::readProcessInfo( CHN_RCF, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "aboutToClose()" , {|o,i| ::readProcessInfo( CHN_CLO, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "bytesWritten(int)" , {|o,i| ::readProcessInfo( CHN_BYT, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "stateChanged(int)" , {|o,i| ::readProcessInfo( CHN_STT, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "error(int)" , {|o,i| ::readProcessInfo( CHN_ERE, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "started()" , {|o,i| ::readProcessInfo( CHN_BGN, o, i ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "readyReadStandardOutput()", {|o,i| ::readProcessInfo( CHN_OUT, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "readyReadStandardError()" , {|o,i| ::readProcessInfo( CHN_ERR, i, o ) } )
|
||||
Qt_Slots_Connect( ::pSlots, ::qProcess, "finished(int,int)" , {|o,i,ii| ::readProcessInfo( CHN_FIN, i, ii, o ) } )
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeProjManager:readProcessInfo( nMode, i, ii )
|
||||
LOCAL cLine, cTmp, nSize
|
||||
|
||||
@@ -863,7 +964,7 @@ METHOD IdeProjManager:readProcessInfo( nMode, i, ii )
|
||||
::launchProject( ::cProjectInProcess )
|
||||
ENDIF
|
||||
IF ::lPPO .AND. hb_FileExists( ::cPPO )
|
||||
::oIde:editSource( ::cPPO )
|
||||
::editSource( ::cPPO )
|
||||
ENDIF
|
||||
ENDCASE
|
||||
|
||||
@@ -874,7 +975,7 @@ METHOD IdeProjManager:readProcessInfo( nMode, i, ii )
|
||||
* Launch selected project.
|
||||
* 03/01/2010 - 09:24:50
|
||||
*/
|
||||
METHOD IdeProjManager:LaunchProject( cProject )
|
||||
METHOD IdeProjManager:launchProject( cProject )
|
||||
LOCAL qProcess, cTargetFN, cTmp, aPrj, n
|
||||
|
||||
IF empty( cProject )
|
||||
|
||||
444
harbour/contrib/hbide/idesources.prg
Normal file
444
harbour/contrib/hbide/idesources.prg
Normal file
@@ -0,0 +1,444 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
*
|
||||
* Copyright 2010 Pritpal Bedi <pritpal@vouchcac.com>
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* EkOnkar
|
||||
* ( The LORD is ONE )
|
||||
*
|
||||
* Harbour-Qt IDE
|
||||
*
|
||||
* Pritpal Bedi <pritpal@vouchcac.com>
|
||||
* 09Jan2010
|
||||
*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#include "common.ch"
|
||||
#include "hbclass.ch"
|
||||
#include "hbqt.ch"
|
||||
#include "hbide.ch"
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
CLASS IdeSourcesManager INHERIT IdeObject
|
||||
|
||||
METHOD new()
|
||||
METHOD create()
|
||||
|
||||
METHOD loadSources()
|
||||
METHOD openSource()
|
||||
METHOD editSource()
|
||||
METHOD selectSource()
|
||||
METHOD closeSource()
|
||||
METHOD closeAllSources()
|
||||
METHOD closeAllOthers()
|
||||
METHOD saveSource()
|
||||
METHOD saveAllSources()
|
||||
METHOD saveAndExit()
|
||||
METHOD revertSource()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeSourcesManager:new( oIde )
|
||||
|
||||
::oIde := oIde
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeSourcesManager:create( oIde )
|
||||
|
||||
DEFAULT oIde TO ::oIde
|
||||
|
||||
::oIde := oIde
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeSourcesManager:loadSources()
|
||||
LOCAL a_
|
||||
|
||||
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
|
||||
::oED:setSourceVisibleByIndex( val( ::aIni[ INI_HBIDE, RecentTabIndex ] ) )
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Save selected Tab on harddisk and return .T. if successfull!
|
||||
*/
|
||||
METHOD IdeSourcesManager:saveSource( nTab, lCancel, lAs )
|
||||
LOCAL oEdit, lNew, cBuffer, qDocument, nIndex, cSource, cFile, cExt, cNewFile
|
||||
LOCAL cFileToSave
|
||||
|
||||
DEFAULT nTab TO ::getCurrentTab()
|
||||
DEFAULT lAs TO .F.
|
||||
|
||||
lCancel := .F.
|
||||
|
||||
IF !empty( oEdit := ::oED:getEditorByTabPosition( nTab ) )
|
||||
cSource := oEdit:sourceFile
|
||||
lNew := Empty( cSource ) .OR. lAs
|
||||
IF lNew
|
||||
cNewFile := ::selectSource( 'save', ;
|
||||
iif( !Empty( cSource ), cSource, hb_dirBase() + "projects\" ),;
|
||||
"Save " + oEdit:oTab:caption + " as..." )
|
||||
IF empty( cNewFile )
|
||||
// will check later what decision to take
|
||||
RETURN .f.
|
||||
ENDIF
|
||||
IF hbide_pathNormalized( cNewFile ) == hbide_pathNormalized( cSource )
|
||||
lNew := .f.
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
cFileToSave := iif( lNew, cNewFile, cSource )
|
||||
qDocument := oEdit:qDocument
|
||||
|
||||
cBuffer := oEdit:qEdit:toPlainText()
|
||||
/*
|
||||
* If the burn process fails, we should change the name of the previous file.
|
||||
* 01/01/2010 - 21:24:41 - vailtom
|
||||
*/
|
||||
IF !hb_memowrit( cFileToSave, cBuffer )
|
||||
MsgBox( "Error saving the file " + oEdit:sourceFile + ".",, 'Error saving file!' )
|
||||
lCancel := .T.
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
|
||||
IF lNew
|
||||
hb_fNameSplit( cFileToSave, , @cFile, @cExt )
|
||||
|
||||
::aTabs[ nTab, TAB_SOURCEFILE ] := cFileToSave
|
||||
oEdit:sourceFile := cFileToSave
|
||||
|
||||
oEdit:oTab:Caption := cFile + cExt
|
||||
::qTabWidget:setTabText( nIndex, cFile + cExt )
|
||||
::qTabWidget:setTabTooltip( nIndex, cSource )
|
||||
ENDIF
|
||||
|
||||
IF empty( cSource )
|
||||
/* The file is not populated in editors tree. Inject */
|
||||
::addSourceInTree( oEdit:sourceFile )
|
||||
ELSEIF lNew
|
||||
/* Rename the existing nodes in tree */
|
||||
ENDIF
|
||||
|
||||
qDocument:setModified( .f. )
|
||||
::aSources := { oEdit:sourceFile }
|
||||
::createTags()
|
||||
::updateFuncList()
|
||||
nIndex := ::qTabWidget:indexOf( oEdit:oTab:oWidget )
|
||||
::qTabWidget:setTabIcon( nIndex, ::resPath + "tabunmodified.png" )
|
||||
::oSBar:getItem( SB_PNL_MODIFIED ):caption := " "
|
||||
ENDIF
|
||||
|
||||
RETURN .T.
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeSourcesManager:editSource( cSourceFile, nPos, nHPos, nVPos, cTheme, lAlert, lVisible )
|
||||
|
||||
DEFAULT lAlert TO .T.
|
||||
DEFAULT lVisible TO .T.
|
||||
|
||||
IF !Empty( cSourceFile )
|
||||
IF !( hbide_isValidText( cSourceFile ) )
|
||||
MsgBox( 'File type unknown or unsupported: ' + cSourceFile )
|
||||
RETURN Self
|
||||
ELSEIF !hb_FileExists( cSourceFile )
|
||||
MsgBox( 'File not found: ' + cSourceFile )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
IF ::oED:isOpen( cSourceFile )
|
||||
IF lAlert
|
||||
IF hbide_getYesNo( cSourceFile + " is already open.", ;
|
||||
"Want to re-load it again ?", "File Open Info!" )
|
||||
::oED:reLoad( cSourceFile )
|
||||
ENDIF
|
||||
ENDIF
|
||||
::oED:setSourceVisible( cSourceFile )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
DEFAULT nPos TO 0
|
||||
DEFAULT nHPos TO 0
|
||||
DEFAULT nVPos TO 0
|
||||
|
||||
::oED:buildEditor( cSourceFile, nPos, nHPos, nVPos, cTheme )
|
||||
IF lVisible
|
||||
::oED:setSourceVisible( cSourceFile )
|
||||
ENDIF
|
||||
|
||||
IF !Empty( cSourceFile ) .AND. !hbide_isSourcePPO( cSourceFile )
|
||||
hbide_mnuAddFileToMRU( Self, cSourceFile, INI_RECENTFILES )
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeSourcesManager:closeSource( nTab, lCanCancel, lCanceled )
|
||||
LOCAL lSave, n, oEdit
|
||||
|
||||
DEFAULT nTab TO ::getCurrentTab()
|
||||
|
||||
IF !empty( oEdit := ::oED:getEditorByTabPosition( nTab ) )
|
||||
|
||||
DEFAULT lCanCancel TO .F.
|
||||
lCanceled := .F.
|
||||
|
||||
IF !( oEdit:qDocument:isModified() )
|
||||
* File has not changed, ignore the question to User
|
||||
lSave := .F.
|
||||
|
||||
ELSEIF lCanCancel
|
||||
n := hbide_getYesNoCancel( oEdit:oTab:Caption, "Has been modified, save this source?", 'Save?' )
|
||||
IF ( lCanceled := ( n == QMessageBox_Cancel ) )
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
lSave := ( n == QMessageBox_Yes )
|
||||
|
||||
ELSE
|
||||
lSave := hbide_getYesNo( oEdit:oTab:Caption, "Has been modified, save this source?", 'Save?' )
|
||||
|
||||
ENDIF
|
||||
|
||||
IF lSave .AND. !( ::saveSource( nTab, @lCanceled ) )
|
||||
IF lCanCancel
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
oEdit:removeTabPage()
|
||||
ENDIF
|
||||
|
||||
RETURN .T.
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Close all opened files.
|
||||
* 02/01/2010 - 15:31:44
|
||||
*/
|
||||
METHOD IdeSourcesManager:closeAllSources()
|
||||
LOCAL lCanceled
|
||||
LOCAL i := 0
|
||||
|
||||
DO WHILE ( ++i <= Len( ::aTabs ) )
|
||||
|
||||
IF ::closeSource( i, .T., @lCanceled )
|
||||
i --
|
||||
Loop
|
||||
ENDIF
|
||||
|
||||
IF lCanceled
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
ENDDO
|
||||
|
||||
RETURN .T.
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Close all opened files except current.
|
||||
* 02/01/2010 - 15:47:19
|
||||
*/
|
||||
METHOD IdeSourcesManager:closeAllOthers( nTab )
|
||||
LOCAL lCanceled, a_
|
||||
|
||||
FOR EACH a_ IN ::aTabs
|
||||
IF a_:__enumIndex() != nTab
|
||||
::closeSource( a_:__enumIndex(), .T., @lCanceled )
|
||||
IF lCanceled
|
||||
RETURN .f.
|
||||
ENDIF
|
||||
ENDIF
|
||||
NEXT
|
||||
|
||||
RETURN .T.
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Save all opened files...
|
||||
* 01/01/2010 - 22:44:36 - vailtom
|
||||
*/
|
||||
METHOD IdeSourcesManager:saveAllSources()
|
||||
LOCAL n
|
||||
|
||||
FOR n := 1 TO Len( ::aTabs )
|
||||
::saveSource( n )
|
||||
NEXT
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Save current file and exits HBIDE
|
||||
* 02/01/2010 - 18:45:06 - vailtom
|
||||
*/
|
||||
METHOD IdeSourcesManager:saveAndExit()
|
||||
|
||||
IF ::saveSource()
|
||||
::execAction( "Exit" )
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/*
|
||||
* Revert current file to a previous saved file.
|
||||
* 02/01/2010 - 19:45:34
|
||||
*/
|
||||
METHOD IdeSourcesManager:revertSource( nTab )
|
||||
|
||||
DEFAULT nTab TO ::getCurrentTab()
|
||||
|
||||
IF nTab < 1
|
||||
RETURN .F.
|
||||
End
|
||||
|
||||
IF !::aTabs[ nTab, TAB_QDOCUMENT ]:isModified()
|
||||
* File has not changed, ignore the question to User
|
||||
ELSE
|
||||
IF !hbide_getYesNo( 'Revert ' + ::aTabs[ nTab, TAB_OTAB ]:Caption + '?', ;
|
||||
'The file ' + ::aTabs[ nTab, TAB_SOURCEFILE ] + ' has changed. '+;
|
||||
'Discard current changes and revert contents to the previously saved on disk?', 'Revert file?' )
|
||||
RETURN Self
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
::aTabs[ nTab, TAB_QEDIT ]:setPlainText( hb_memoRead( ::aTabs[ nTab, TAB_SOURCEFILE ] ) )
|
||||
::aTabs[ nTab, TAB_QEDIT ]:ensureCursorVisible()
|
||||
::manageFocusInEditor()
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeSourcesManager:openSource()
|
||||
LOCAL aSrc, cSource
|
||||
|
||||
IF !empty( aSrc := ::selectSource( "openmany" ) )
|
||||
FOR EACH cSource IN aSrc
|
||||
::editSource( cSource )
|
||||
NEXT
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeSourcesManager:selectSource( cMode, cFile, cTitle )
|
||||
LOCAL oDlg, cPath
|
||||
|
||||
oDlg := XbpFileDialog():new():create( ::oDa, , { 10,10 } )
|
||||
|
||||
IF cMode == "open"
|
||||
oDlg:title := "Select a Source File"
|
||||
oDlg:center := .t.
|
||||
oDlg:fileFilters := { { "All Files" , "*.*" }, { "PRG Sources", "*.prg" }, { "C Sources" , "*.c" },;
|
||||
{ "CPP Sources", "*.cpp" }, { "H Headers" , "*.h" }, { "CH Headers", "*.ch" } }
|
||||
cFile := oDlg:open( , , .f. )
|
||||
|
||||
ELSEIF cMode == "openmany"
|
||||
oDlg:title := "Select Sources"
|
||||
oDlg:center := .t.
|
||||
oDlg:defExtension:= 'prg'
|
||||
oDlg:fileFilters := { { "All Files" , "*.*" }, { "PRG Sources", "*.prg" }, { "C Sources" , "*.c" },;
|
||||
{ "CPP Sources", "*.cpp" }, { "H Headers" , "*.h" }, { "CH Headers", "*.ch" } }
|
||||
cFile := oDlg:open( , , .t. )
|
||||
|
||||
ELSEIF cMode == "save"
|
||||
oDlg:title := iif( !hb_isChar( cTitle ), "Save as...", cTitle )
|
||||
oDlg:center := .t.
|
||||
oDlg:defExtension:= 'prg'
|
||||
|
||||
IF hb_isChar( cFile ) .AND. !Empty( cFile )
|
||||
IF Right( cFile, 1 ) $ '/\'
|
||||
cPath := cFile
|
||||
ELSE
|
||||
hb_fNameSplit( cFile, @cPath )
|
||||
Endif
|
||||
Endif
|
||||
|
||||
oDlg:fileFilters := { { "PRG Sources", "*.prg" }, { "C Sources", "*.c" }, { "CPP Sources", "*.cpp" }, ;
|
||||
{ "H Headers", "*.h" }, { "CH Headers", "*.ch" } }
|
||||
cFile := oDlg:saveAs( cPath )
|
||||
|
||||
ELSE
|
||||
oDlg:title := "Save this Database"
|
||||
oDlg:fileFilters := { { "Database Files", "*.dbf" } }
|
||||
oDlg:quit := {|| MsgBox( "Quitting the Dialog" ), 1 }
|
||||
cFile := oDlg:saveAs( "myfile.dbf" )
|
||||
IF !empty( cFile )
|
||||
hbide_dbg( cFile )
|
||||
ENDIF
|
||||
|
||||
ENDIF
|
||||
|
||||
RETURN cFile
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[ PROPERTIES ]
|
||||
Type = Executable
|
||||
Title = Harbour-Qt IDE
|
||||
Location = E:/harbour/contrib/hbide/projects
|
||||
WorkingFolder = E:/harbour/contrib/hbide/projects
|
||||
DestinationFolder = E:/harbour/contrib/hbide/projects
|
||||
Location = <IdeSrc>projects
|
||||
WorkingFolder = <IdeSrc>projects
|
||||
DestinationFolder = <IdeSrc>projects
|
||||
Output = hbide
|
||||
LaunchParams =
|
||||
LaunchProgram =
|
||||
@@ -30,6 +30,7 @@ LaunchProgram =
|
||||
<IdeSrc>iderequests.prg
|
||||
<IdeSrc>idethemes.prg
|
||||
<IdeSrc>ideprojmanager.prg
|
||||
<IdeSrc>idesources.prg
|
||||
#
|
||||
<IdeSrc>ideparseexpr.c
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user