From acfe21fc504954564d89af9d459724909732f247 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Thu, 22 Apr 2010 00:33:44 +0000 Subject: [PATCH] 2010-04-21 17:28 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbide/ideeditor.prg * contrib/hbide/idemisc.prg * contrib/hbide/idesaveload.prg * contrib/hbide/idesources.prg + Implemented: save/restrore of bookmarks. Now editing instances will be opened containing bookmarks which were placed in previous successful exit. This is valid for bookmarks in primarary window of editing instance, i.e., no split window is taken account of. --- harbour/ChangeLog | 11 +++++++++ harbour/contrib/hbide/ideeditor.prg | 23 ++++++++++++------- harbour/contrib/hbide/idemisc.prg | 33 ++++++++++++++++++++++++++- harbour/contrib/hbide/idesaveload.prg | 7 ++++-- harbour/contrib/hbide/idesources.prg | 10 ++++---- 5 files changed, 68 insertions(+), 16 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e09e8a91a4..e69c30a517 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,17 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-04-21 17:28 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbide/ideeditor.prg + * contrib/hbide/idemisc.prg + * contrib/hbide/idesaveload.prg + * contrib/hbide/idesources.prg + + Implemented: save/restrore of bookmarks. + Now editing instances will be opened containing bookmarks + which were placed in previous successful exit. This is + valid for bookmarks in primarary window of editing instance, i.e., + no split window is taken account of. + 2010-04-22 02:14 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * harbour-win-spec * harbour-wce-spec diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index b76bc0430b..557fe05d27 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -103,7 +103,7 @@ CLASS IdeEditsManager INHERIT IdeObject METHOD removeSourceInTree( cSourceFile ) METHOD addSourceInTree( cSourceFile, cView ) METHOD execEvent( nMode, p ) - METHOD buildEditor( cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) + METHOD buildEditor( cSourceFile, nPos, nHPos, nVPos, cTheme, cView, aBookMarks ) METHOD getTabBySource( cSource ) METHOD getTabCurrent() METHOD getDocumentCurrent() @@ -301,9 +301,9 @@ METHOD IdeEditsManager:execEvent( nMode, p ) /*----------------------------------------------------------------------*/ -METHOD IdeEditsManager:buildEditor( cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) +METHOD IdeEditsManager:buildEditor( cSourceFile, nPos, nHPos, nVPos, cTheme, cView, aBookMarks ) - IdeEditor():new():create( ::oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) + IdeEditor():new():create( ::oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView, aBookMarks ) RETURN Self @@ -982,10 +982,9 @@ CLASS IdeEditor INHERIT IdeObject DATA nnRow INIT -99 DATA qEvents -// DATA qSlots METHOD new( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) - METHOD create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) + METHOD create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView, aBookMarks ) METHOD split( nOrient, oEditP ) METHOD relay( oEdit ) METHOD destroy() @@ -1025,7 +1024,7 @@ METHOD IdeEditor:new( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) /*----------------------------------------------------------------------*/ -METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) +METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView, aBookMarks ) LOCAL cFileTemp //::qSlots := HBSlots():new() @@ -1037,6 +1036,7 @@ METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) DEFAULT nVPos TO ::nVPos DEFAULT cTheme TO ::cTheme DEFAULT cView TO ::cView + DEFAULT aBookMarks TO {} ::oIde := oIde ::SourceFile := hbide_pathNormalized( cSourceFile, .F. ) @@ -1074,12 +1074,14 @@ METHOD IdeEditor:create( oIde, cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) // ::oTab:oWidget:setLayout( ::qLayout ) - ::oEdit := IdeEdit():new( Self, 0 ):create() + ::oEdit := IdeEdit():new( Self, 0 ) + ::oEdit:aBookMarks := aBookMarks + ::oEdit:create() ::qEdit := ::oEdit:qEdit ::qCqEdit := ::oEdit:qEdit ::qCoEdit := ::oEdit - ::qDocument := QTextDocument():configure( ::qEdit:document() ) + ::qDocument := QTextDocument():configure( ::qEdit:document() ) ::qDocLayout := QPlainTextDocumentLayout():new( ::qDocument ) ::qDocument:setDocumentLayout( ::qDocLayout ) @@ -1478,6 +1480,7 @@ METHOD IdeEdit:new( oEditor, nMode ) /*----------------------------------------------------------------------*/ METHOD IdeEdit:create( oEditor, nMode ) + LOCAL nBlock DEFAULT oEditor TO ::oEditor DEFAULT nMode TO ::nMode @@ -1501,6 +1504,10 @@ METHOD IdeEdit:create( oEditor, nMode ) ::toggleLineNumbers() + FOR EACH nBlock IN ::aBookMarks + ::qEdit:hbBookMarks( nBlock ) + NEXT + ::qHLayout := QHBoxLayout():new() ::qHLayout:setSpacing( 0 ) diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index a5793f83d5..7931f428a0 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -2014,17 +2014,47 @@ FUNCTION FN_DirExtSet( cFileName, cDirNew, cExtNew ) /*----------------------------------------------------------------------*/ +FUNCTION hbide_nArray2string( a_ ) + LOCAL cString := "" + LOCAL n + + FOR EACH n IN a_ + cString += hb_ntos( n ) + cString += " " + NEXT + + RETURN cString + +/*----------------------------------------------------------------------*/ + +FUNCTION hbide_string2nArray( s ) + LOCAL b_, a_:= {} + + b_:= hb_atokens( s, " " ) + FOR EACH s IN b_ + s := alltrim( s ) + IF val( s ) > 0 + aadd( a_, val( s ) ) + ENDIF + NEXT + + RETURN a_ + +/*----------------------------------------------------------------------*/ + FUNCTION hbide_parseSourceComponents( cCompositeSource ) LOCAL a_ a_:= hb_atokens( cCompositeSource, "," ) - asize( a_, 6 ) + asize( a_, 7 ) DEFAULT a_[ 1 ] TO "" DEFAULT a_[ 2 ] TO "" DEFAULT a_[ 3 ] TO "" DEFAULT a_[ 4 ] TO "" DEFAULT a_[ 5 ] TO "" DEFAULT a_[ 6 ] TO "Main" + DEFAULT a_[ 7 ] TO "" + // a_[ 1 ] := alltrim( a_[ 1 ] ) a_[ 2 ] := val( alltrim( a_[ 2 ] ) ) @@ -2032,6 +2062,7 @@ FUNCTION hbide_parseSourceComponents( cCompositeSource ) a_[ 4 ] := val( alltrim( a_[ 4 ] ) ) a_[ 5 ] := alltrim( a_[ 5 ] ) a_[ 6 ] := alltrim( a_[ 6 ] ) + a_[ 7 ] := hbide_string2nArray( a_[ 7 ] ) RETURN a_ diff --git a/harbour/contrib/hbide/idesaveload.prg b/harbour/contrib/hbide/idesaveload.prg index fa1c51fea8..505f8f28bf 100644 --- a/harbour/contrib/hbide/idesaveload.prg +++ b/harbour/contrib/hbide/idesaveload.prg @@ -90,13 +90,15 @@ FUNCTION hbide_getEditInfoAsString( oEdit ) LOCAL qHScr := QScrollBar():configure( oEdit:qEdit:horizontalScrollBar() ) LOCAL qVScr := QScrollBar():configure( oEdit:qEdit:verticalScrollBar() ) LOCAL qCursor := QTextCursor():configure( oEdit:qEdit:textCursor() ) + LOCAL cBMarks := hbide_nArray2string( oEdit:oEdit:aBookMarks ) RETURN hbide_pathNormalized( oEdit:sourceFile, .f. ) + "," + ; hb_ntos( qCursor:position() ) + "," + ; hb_ntos( qHScr:value() ) + "," + ; hb_ntos( qVScr:value() ) + "," + ; oEdit:cTheme + "," + ; - oEdit:cView + "," + oEdit:cView + "," + ; + cBMarks + "," /*----------------------------------------------------------------------*/ @@ -165,7 +167,8 @@ HB_TRACE( HB_TR_ALWAYS, "hbide_saveINI( oIde )", 0, oIde:nRunMode, oIde:cProjIni hb_ntos( oEdit:nHPos ) + "," + ; hb_ntos( oEdit:nVPos ) + "," + ; oEdit:cTheme + "," + ; - oEdit:cView + "," ) + oEdit:cView + "," + ; + hbide_nArray2string( oEdit:oEdit:aBookMarks ) + "," ) ENDIF ENDIF NEXT diff --git a/harbour/contrib/hbide/idesources.prg b/harbour/contrib/hbide/idesources.prg index dc4a8f69cd..3207352dae 100644 --- a/harbour/contrib/hbide/idesources.prg +++ b/harbour/contrib/hbide/idesources.prg @@ -78,7 +78,7 @@ CLASS IdeSourcesManager INHERIT IdeObject METHOD loadSources() METHOD saveSource( nTab, lCancel, lAs ) METHOD saveNamedSource( cSource ) - METHOD editSource( cSourceFile, nPos, nHPos, nVPos, cTheme, cView, lAlert, lVisible ) + METHOD editSource( cSourceFile, nPos, nHPos, nVPos, cTheme, cView, lAlert, lVisible, aBookMarks ) METHOD closeSource( nTab, lCanCancel, lCanceled ) METHOD closeAllSources() METHOD closeAllOthers( nTab ) @@ -115,8 +115,8 @@ METHOD IdeSourcesManager:loadSources() IF !empty( ::aIni[ INI_FILES ] ) FOR EACH a_ IN ::aIni[ INI_FILES ] - /* File nPos nVPos nHPos cTheme cView lAlert lVisible */ - ::editSource( a_[ 1 ], a_[ 2 ], a_[ 3 ], a_[ 4 ], a_[ 5 ], a_[ 6 ], .t., .f. ) + /* File nPos nVPos nHPos cTheme cView lAlert lVisible, aBookMarks */ + ::editSource( a_[ 1 ], a_[ 2 ], a_[ 3 ], a_[ 4 ], a_[ 5 ], a_[ 6 ], .t., .f., a_[ 7 ] ) NEXT ::oDK:setView( ::cWrkView ) ::oEM:setSourceVisibleByIndex( max( 0, val( ::aIni[ INI_HBIDE, RecentTabIndex ] ) ) ) @@ -231,7 +231,7 @@ METHOD IdeSourcesManager:saveSource( nTab, lCancel, lAs ) /*----------------------------------------------------------------------*/ -METHOD IdeSourcesManager:editSource( cSourceFile, nPos, nHPos, nVPos, cTheme, cView, lAlert, lVisible ) +METHOD IdeSourcesManager:editSource( cSourceFile, nPos, nHPos, nVPos, cTheme, cView, lAlert, lVisible, aBookMarks ) DEFAULT lAlert TO .T. DEFAULT lVisible TO .T. @@ -260,7 +260,7 @@ METHOD IdeSourcesManager:editSource( cSourceFile, nPos, nHPos, nVPos, cTheme, cV DEFAULT nHPos TO 0 DEFAULT nVPos TO 0 - ::oEM:buildEditor( cSourceFile, nPos, nHPos, nVPos, cTheme, cView ) + ::oEM:buildEditor( cSourceFile, nPos, nHPos, nVPos, cTheme, cView, aBookMarks ) IF lVisible ::oEM:setSourceVisible( cSourceFile ) ENDIF