2010-01-20 18:33 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)

* contrib/hbide/hbide.prg
  * contrib/hbide/ideactions.prg
  * contrib/hbide/ideeditor.prg
    + Implemented: Formatting - <Format Braces>
   
    ; These formatting actions are initiated from the fact that
      code examples scattered on the net about Qt examples are
      written in such a way that I was unable to grasp the contents.
      I found it usual to include such functionality into hbIDE.
      Hopefully it will be useful to all.
This commit is contained in:
Pritpal Bedi
2010-01-21 02:34:31 +00:00
parent c1542c45f3
commit 00e5973632
4 changed files with 69 additions and 0 deletions

View File

@@ -17,6 +17,18 @@
past entries belonging to author(s): Viktor Szakats.
*/
2010-01-20 18:33 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbide/hbide.prg
* contrib/hbide/ideactions.prg
* contrib/hbide/ideeditor.prg
+ Implemented: Formatting - <Format Braces>
; These formatting actions are initiated from the fact that
code examples scattered on the net about Qt examples are
written in such a way that I was unable to grasp the contents.
I found it usual to include such functionality into hbIDE.
Hopefully it will be useful to all.
2010-01-20 17:16 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbide/hbide.prg
* contrib/hbide/ideactions.prg

View File

@@ -515,6 +515,8 @@ METHOD HbIde:execAction( cKey )
CASE cKey == "ZoomOut"
::oEM:zoom( 0 )
CASE cKey == "FormatBraces"
::oEM:formatBraces()
CASE cKey == "RemoveTabs"
::oEM:removeTabs()
CASE cKey == "RemoveTrailingSpaces"

View File

@@ -288,6 +288,7 @@ METHOD IdeActions:loadActions()
aadd( aAct, { "RemoveTabs" , "Replace Tabs with Spaces" , "RemoveTabs" , "" , "No", "Yes" } )
aadd( aAct, { "RemoveTrailingSpaces" , "Remove Trailing Spaces" , "RemoveTrailingSpaces", "" , "No", "Yes" } )
aadd( aAct, { "FormatBraces" , "Format Braces" , "FormatBraces" , "" , "No", "Yes" } )
RETURN aAct
@@ -461,6 +462,7 @@ METHOD IdeActions:buildMainMenu()
oSubMenu2:addItem( { ::getAction( "RemoveTabs" ), {|| oIde:execAction( "RemoveTabs" ) } } )
hbide_menuAddSep( oSubMenu )
oSubMenu2:addItem( { ::getAction( "RemoveTrailingSpaces"), {|| oIde:execAction( "RemoveTrailingSpaces" ) } } )
oSubMenu2:addItem( { ::getAction( "FormatBraces" ), {|| oIde:execAction( "FormatBraces" ) } } )
oMenuBar:addItem( { oSubMenu2, _T( "~Format" ) } )
hbide_menuAddSep( oSubMenu )

View File

@@ -130,6 +130,7 @@ CLASS IdeEditsManager INHERIT IdeObject
METHOD setMark()
METHOD gotoMark()
METHOD goto()
METHOD formatBraces()
METHOD removeTabs()
METHOD RemoveTrailingSpaces()
METHOD getSelectedText()
@@ -604,6 +605,58 @@ METHOD IdeEditsManager:insertText( cKey )
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:formatBraces()
LOCAL qEdit, qDoc, cText
IF empty( qEdit := ::getEditCurrent() )
RETURN Self
ENDIF
qDoc := QTextDocument():configure( qedit:document() )
IF !( qDoc:isEmpty() )
qDoc:setUndoRedoEnabled( .f. )
cText := qDoc:toPlainText()
cText := strtran( cText, "( ", "(" )
cText := strtran( cText, "( ", "(" )
cText := strtran( cText, "( ", "(" )
cText := strtran( cText, "( ", "(" )
cText := strtran( cText, "( ", "(" )
cText := strtran( cText, "( ", "(" )
cText := strtran( cText, " (", "(" )
cText := strtran( cText, " (", "(" )
cText := strtran( cText, " (", "(" )
cText := strtran( cText, " (", "(" )
cText := strtran( cText, " (", "(" )
cText := strtran( cText, " )", ")" )
cText := strtran( cText, " )", ")" )
cText := strtran( cText, " )", ")" )
cText := strtran( cText, " )", ")" )
cText := strtran( cText, " )", ")" )
cText := strtran( cText, " )", ")" )
cText := strtran( cText, "(", "( " )
cText := strtran( cText, ")", " )" )
cText := strtran( cText, "( )", "()" )
cText := strtran( cText, "( )", "()" )
cText := strtran( cText, "( )", "()" )
cText := strtran( cText, "( )", "()" )
cText := strtran( cText, "( )", "()" )
qDoc:clear()
qDoc:setPlainText( cText )
qDoc:setUndoRedoEnabled( .t. )
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:RemoveTabs()
LOCAL qEdit, qDoc, cText, cSpaces