From f148efd20f119f81f9d4603c33a1e128d8fdb780 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Sun, 26 Aug 2012 23:42:35 +0000 Subject: [PATCH] 2012-08-26 16:32 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/docks.prg * contrib/hbide/edit.prg * contrib/hbide/editor.prg * contrib/hbide/hbide.qrc + contrib/hbide/resources/align_at.png * contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp + Implemented: aligning a selected-text fragment (column-selection mode) to a contained string. The activation is selected-text toolbar icon . This activation presents a input dialog to provide string to align-at. The following illustration will make it clear: abc := 212 bcdefg := 323 a := 413 xyzab := 33 => Select above lines with column-selection mode Clock on icon Type ":=" in the input dialog => abc := 212 bcdefg := 323 a := 413 xyzab := 33 --- harbour/ChangeLog | 26 ++++++++++++ harbour/contrib/hbide/docks.prg | 8 +++- harbour/contrib/hbide/edit.prg | 39 ++++++++++++++++++ harbour/contrib/hbide/editor.prg | 19 +++++++++ harbour/contrib/hbide/hbide.qrc | 1 + harbour/contrib/hbide/resources/align_at.png | Bin 0 -> 1052 bytes .../hbqt/qtgui/hbqt_hbqplaintextedit.cpp | 10 ++++- 7 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 harbour/contrib/hbide/resources/align_at.png diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4950528939..396410fc7f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,32 @@ The license applies to all entries newer than 2009-04-28. */ +2012-08-26 16:32 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbide/docks.prg + * contrib/hbide/edit.prg + * contrib/hbide/editor.prg + * contrib/hbide/hbide.qrc + + contrib/hbide/resources/align_at.png + * contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp + + Implemented: aligning a selected-text fragment (column-selection mode) + to a contained string. The activation is selected-text toolbar icon + . This activation presents a input dialog to provide + string to align-at. The following illustration will make it clear: + + abc := 212 + bcdefg := 323 + a := 413 + xyzab := 33 + => + Select above lines with column-selection mode + Clock on icon + Type ":=" in the input dialog + => + abc := 212 + bcdefg := 323 + a := 413 + xyzab := 33 + 2012-08-25 23:02 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtgui/hbqt_hbqplaintextedit.cpp + Pair-matching of DO CASE/ENDCASE and DO WHILE/ENDDO. diff --git a/harbour/contrib/hbide/docks.prg b/harbour/contrib/hbide/docks.prg index 0c52af8f7a..d0a9bccd76 100644 --- a/harbour/contrib/hbide/docks.prg +++ b/harbour/contrib/hbide/docks.prg @@ -1276,6 +1276,8 @@ METHOD IdeDocks:buildMdiToolbar() qTBar:addSeparator() qTBar:addToolButton( "Sgl2Dbl" , "Single to Double Quotes" , hbide_image( "sgl2dblquote" ), {|| ::oEM:convertDQuotes() }, .f. ) qTBar:addToolButton( "Dbl2Sgl" , "Double to Single Quotes" , hbide_image( "dbl2sglquote" ), {|| ::oEM:convertQuotes() }, .f. ) + qTBar:addSeparator() + qTBar:addToolButton( "AlignAt" , "Align At..." , hbide_image( "align_at" ), {|| ::oEM:alignAt() }, .f. ) IF ! ::oINI:lShowEditsTopToolbar ::qMdiToolbar:hide() @@ -1820,8 +1822,8 @@ METHOD IdeDocks:getMarkWidget( nIndex ) ::oIde:aMarkTBtns[ nIndex ]:setMaximumWidth( 12 ) ::oIde:aMarkTBtns[ nIndex ]:setStyleSheet( "background-color: " + aColors[ nIndex ] + ";" ) ::oIde:aMarkTBtns[ nIndex ]:hide() - ::oIde:aMarkTBtns[ nIndex ]:connect( "clicked()" , {|| ::oEM:gotoMark( nIndex ) } ) - ::oIde:aMarkTBtns[ nIndex ]:connect( QEvent_Enter, {|| ::oEM:setTooltipMark( nIndex ) } ) + ::oIde:aMarkTBtns[ nIndex ]:connect( "clicked()" , {|| ::oEM:gotoMark( nIndex ) } ) + ::oIde:aMarkTBtns[ nIndex ]:connect( QEvent_Enter, {|| ::oEM:setTooltipMark( nIndex ) } ) RETURN ::oIde:aMarkTBtns[ nIndex ] @@ -2118,6 +2120,7 @@ METHOD IdeDocks:buildSelectedTextToolbar() qTBar:addToolButton( "Redo" , "Redo" , hbide_image( "redo" ), {|| ::oEM:redo() }, .f. ) qTBar:addToolButton( "Cut" , "Cut" , hbide_image( "cut" ), {|| ::oEM:cut() }, .f. ) qTBar:addToolButton( "Copy" , "Copy" , hbide_image( "copy" ), {|| ::oEM:copy() }, .f. ) + qTBar:addToolButton( "SelMode" , "Selection Mode" , hbide_image( "stream" ), {|| ::oEM:toggleSelectionMode(), ::oIDE:manageFocusInEditor() }, .t. ) qTBar:addToolButton( "ToUpper" , "To Upper" , hbide_image( "toupper" ), {|| ::oEM:convertSelection( "ToUpper" ) }, .f. ) qTBar:addToolButton( "ToLower" , "To Lower" , hbide_image( "tolower" ), {|| ::oEM:convertSelection( "ToLower" ) }, .f. ) qTBar:addToolButton( "InvertCase", "Invert Case" , hbide_image( "invertcase" ), {|| ::oEM:convertSelection( "Invert" ) }, .f. ) @@ -2127,6 +2130,7 @@ METHOD IdeDocks:buildSelectedTextToolbar() qTBar:addToolButton( "IndentL" , "Indent Left" , hbide_image( "blockindentl" ), {|| ::oEM:indent( -1 ) }, .f. ) qTBar:addToolButton( "Sgl2Dbl" , "Single to Double Quotes" , hbide_image( "sgl2dblquote" ), {|| ::oEM:convertDQuotes() }, .f. ) qTBar:addToolButton( "Dbl2Sgl" , "Double to Single Quotes" , hbide_image( "dbl2sglquote" ), {|| ::oEM:convertQuotes() }, .f. ) + qTBar:addToolButton( "AlignAt" , "Align At..." , hbide_image( "align_at" ), {|| ::oEM:alignAt() }, .f. ) RETURN Self diff --git a/harbour/contrib/hbide/edit.prg b/harbour/contrib/hbide/edit.prg index 9b48a1b81c..02c621a6f0 100644 --- a/harbour/contrib/hbide/edit.prg +++ b/harbour/contrib/hbide/edit.prg @@ -255,6 +255,7 @@ CLASS IdeEdit INHERIT IdeObject METHOD handleTab( key ) METHOD matchPair( x, y ) METHOD unmatchPair() + METHOD alignAt( cAt ) ENDCLASS @@ -1287,6 +1288,44 @@ METHOD IdeEdit:blockIndent( nDirctn ) /*----------------------------------------------------------------------*/ +METHOD IdeEdit:alignAt( cAt ) + LOCAL nT, nL, nB, nR, nW, i, cLine, qCursor, aCord, a_, nMax, n, c1st, c2nd + + IF ::lReadOnly + RETURN Self + ENDIF + + nMax := 0 + aCord := ::aSelectionInfo + hbide_normalizeRect( aCord, @nT, @nL, @nB, @nR ) + nW := nR - nL + a_:= hbide_setQCursor( ::qEdit ) ; qCursor := a_[ 1 ] + IF nW >= 0 + FOR i := nT TO nB + cLine := ::getLine( i + 1 ) + IF ( n := At( cAt, SubStr( cLine, nL, nR - nL + 1 ) ) ) > 0 + nMax := Max( nMax, n ) + ENDIF + NEXT + ENDIF + IF nMax > 0 + nMax += nL - 2 + FOR i := nT TO nB + cLine := ::getLine( i + 1 ) + IF ( n := At( cAt, cLine ) ) > 0 + c1st := SubStr( cLine, 1, n - 1 ) + c2nd := SubStr( cLine, n ) + cLine := PadR( c1st, nMax ) + c2nd + ENDIF + hbide_qReplaceLine( qCursor, i, cLine ) + NEXT + ENDIF + hbide_setQCursor( ::qEdit, a_ ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeEdit:blockConvert( cMode ) LOCAL nT, nL, nB, nR, nW, i, cLine, qCursor, aCord, a_, nMode diff --git a/harbour/contrib/hbide/editor.prg b/harbour/contrib/hbide/editor.prg index 319c18918a..7871c9d514 100644 --- a/harbour/contrib/hbide/editor.prg +++ b/harbour/contrib/hbide/editor.prg @@ -82,6 +82,11 @@ #define __qTimeSave_timeout__ 2005 #define __qTab_contextMenu__ 2006 + +#define __selectionMode_stream__ 1 +#define __selectionMode_column__ 2 +#define __selectionMode_line__ 3 + /*----------------------------------------------------------------------*/ CLASS IdeEditsManager INHERIT IdeObject @@ -189,6 +194,7 @@ CLASS IdeEditsManager INHERIT IdeObject METHOD updateCompleter() METHOD updateFieldsList( cAlias ) METHOD getProto( cWord ) + METHOD alignAt() ENDCLASS @@ -882,6 +888,19 @@ METHOD IdeEditsManager:convertDQuotes() /*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:alignAt() + LOCAL oEdit, cWord + IF !empty( oEdit := ::getEditObjectCurrent() ) + IF oEdit:aSelectionInfo[ 5 ] == __selectionMode_column__ + IF ! Empty( cWord := hbide_fetchAString( ::oDlg:oWidget, "", "Align At ?", "Selected-Text Alignment Proto" ) ) + oEdit:alignAt( cWord ) + ENDIF + ENDIF + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeEditsManager:switchToReadOnly() LOCAL oEdit IF !empty( oEdit := ::getEditObjectCurrent() ) diff --git a/harbour/contrib/hbide/hbide.qrc b/harbour/contrib/hbide/hbide.qrc index cbf13dc242..c8dfceb059 100644 --- a/harbour/contrib/hbide/hbide.qrc +++ b/harbour/contrib/hbide/hbide.qrc @@ -320,6 +320,7 @@ resources/split_close.png resources/split_h.png resources/split_v.png + resources/align_at.png docs/faq.htm diff --git a/harbour/contrib/hbide/resources/align_at.png b/harbour/contrib/hbide/resources/align_at.png new file mode 100644 index 0000000000000000000000000000000000000000..ecca8eeac99a0fc835483da8a049815fece2b24b GIT binary patch literal 1052 zcmV+%1mpXOP)p#d| z3M+|jmV{Ah7)H5f*oAHq2#R#Ekc`#~6h3r$5Fdi*MiEiSCP{%wL{W5kkV2@J?7fGA z>_KP0k^=)j9nK2{=b*lwna0R0 z3qXj$J@I%AeoVV@W1eyI9mgrGt*L?8YW>M%HFopR{9c-O9og7_fuuy za{ni}3;c})c)E5STma1(C`7(fi7Y=Sxx0&E+B#TV~{b2CZ zt!iR2ogV|1u3mJ=bl-ao1-5N0wG_Pj{u^VdPB{*o+gAoQXOY*t@NK9W=s3I?z;u}4 zF)L69i9_X~{#3pUs6s^Z+R%0PmCmuh(s2a01^q8W{pSyqqXr<)Qml2|ab#=wKE_pc z9N89n9dlA?1uW-nC|4w8-+6mjYQS{bQSh!i!^YE+G>|}slmb|;l~A2vB*xC86_Gg% zXFxF|H)uXrGW`!EZVo{#W(6xD=D6!vC3M^xQl;2m3Gp)0-B6La*yIdAXfC@ODkB*n z5K#<3PIp2*kgnvyy>n0NO-5IHk;Q1B=45@atY8|Z`!4j%