2011-08-12 15:49 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)

* contrib/hbide/ideactions.prg
  * contrib/hbide/ideedit.prg
  * contrib/hbide/ideeditor.prg
  * contrib/hbide/idemain.prg
  * contrib/hbide/idethemes.prg
    + Added: <Edit><Format><Upper Case Harbour Keywords> option.
      When applied to an editing instance, Harbour keywords are 
      capitalized. It is a useful utility for old sources where 
      we were lazy on readable importance of our sources.
This commit is contained in:
Pritpal Bedi
2011-08-12 22:54:18 +00:00
parent 16c5674221
commit bfa7f4b450
6 changed files with 80 additions and 3 deletions

View File

@@ -16,6 +16,17 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-08-12 15:49 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbide/ideactions.prg
* contrib/hbide/ideedit.prg
* contrib/hbide/ideeditor.prg
* contrib/hbide/idemain.prg
* contrib/hbide/idethemes.prg
+ Added: <Edit><Format><Upper Case Harbour Keywords> option.
When applied to an editing instance, Harbour keywords are
capitalized. It is a useful utility for old sources where
we were lazy on readable importance of our sources.
2011-08-12 17:53 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbtip/sendmail.prg
* contrib/hbtip/httpcli.prg

View File

@@ -289,6 +289,7 @@ METHOD IdeActions:loadActions()
aadd( aAct, { "Spaces2Tabs" , "Replace Spaces with Tabs" , "" , "" , "No", "Yes" } )
aadd( aAct, { "RemoveTrailingSpaces" , "Remove Trailing Spaces" , "removetrailingspaces", "", "No", "Yes" } )
aadd( aAct, { "FormatBraces" , "Format Braces" , "ormatbraces" , "" , "No", "Yes" } )
aadd( aAct, { "UpperCaseKeywords" , "UpperCase Harbour Keywords" , "ormatbraces" , "" , "No", "Yes" } )
aadd( aAct, { "StreamComment" , "Stream Comment" , "streamcomment" , "" , "No", "Yes" } )
aadd( aAct, { "BlockComment" , "Block Comment" , "blockcomment" , "" , "No", "Yes" } )
@@ -496,6 +497,7 @@ METHOD IdeActions:buildMainMenu()
hbide_menuAddSep( oSubMenu )
oSubMenu2:addItem( { ::getAction( "RemoveTrailingSpaces"), {|| oIde:execAction( "RemoveTrailingSpaces" ) } } )
oSubMenu2:addItem( { ::getAction( "FormatBraces" ), {|| oIde:execAction( "FormatBraces" ) } } )
oSubMenu2:addItem( { ::getAction( "UpperCaseKeywords" ), {|| oIde:execAction( "UpperCaseKeywords" ) } } )
oMenuBar:addItem( { oSubMenu2, _T( "~Format" ) } )
hbide_menuAddSep( oSubMenu )

View File

@@ -241,6 +241,7 @@ CLASS IdeEdit INHERIT IdeObject
METHOD spaces2tabs()
METHOD removeTrailingSpaces()
METHOD formatBraces()
METHOD upperCaseKeywords()
METHOD findEx( cText, nFlags, nStart )
METHOD highlightAll( cText )
METHOD unHighlight()
@@ -1883,6 +1884,49 @@ METHOD IdeEdit:paintRequested( qPrinter )
/*----------------------------------------------------------------------*/
METHOD IdeEdit:upperCaseKeywords()
LOCAL qDoc, cText, cRegEx, aMatches, aMatch, b_
qDoc := ::qEdit:document()
IF !( qDoc:isEmpty() )
qDoc:setUndoRedoEnabled( .f. )
cText := qDoc:toPlainText()
b_:= { 'function','procedure','thread','return','static','local','default', ;
'if','else','elseif','endif','end', ;
'docase','case','endcase','otherwise', ;
'switch','endswitch', ;
'do','while','exit','enddo','loop',;
'for','each','next','step','to','in',;
'with','replace','object','endwith','request',;
'nil','and','or','in','not','self',;
'class','endclass','method','data','var','destructor','inline','assign','access',;
'inherit','init','create','virtual','message', 'from', 'setget',;
'begin','sequence','try','catch','always','recover','hb_symbol_unused', ;
'error','handler','private','public' }
cRegEx := ""
aeval( b_, {|e| cRegEx += iif( empty( cRegEx ), "", "|" ) + "\b" + e + "\b" } )
aMatches := hb_regExAll( cRegEx, cText, .f., .f., 0, 1, .f. )
IF ! empty( aMatches )
FOR EACH aMatch IN aMatches
cText := stuff( cText, aMatch[ 2 ], aMatch[ 3 ] - aMatch[ 2 ] + 1, upper( aMatch[ 1 ] ) )
NEXT
ENDIF
qDoc:clear()
qDoc:setPlainText( cText )
qDoc:setUndoRedoEnabled( .t. )
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEdit:formatBraces()
LOCAL qDoc, cText
@@ -2537,7 +2581,7 @@ FUNCTION hbide_isIndentableKeyword( cWord, oIde )
/*----------------------------------------------------------------------*/
FUNCTION hbide_isHarbourKeyword( cWord, oIde )
FUNCTION hbide_harbourKeywords()
STATIC s_b_ := { ;
'function' => NIL,;
'procedure' => NIL,;
@@ -2600,9 +2644,15 @@ FUNCTION hbide_isHarbourKeyword( cWord, oIde )
'not' => NIL,;
'and' => NIL }
RETURN s_b_
/*----------------------------------------------------------------------*/
FUNCTION hbide_isHarbourKeyword( cWord, oIde )
HB_SYMBOL_UNUSED( oIde )
RETURN Lower( cWord ) $ s_b_
RETURN Lower( cWord ) $ hbide_harbourKeywords()
/*----------------------------------------------------------------------*/

View File

@@ -126,6 +126,7 @@ CLASS IdeEditsManager INHERIT IdeObject
METHOD gotoMark( nIndex )
METHOD goto( nLine )
METHOD formatBraces()
METHOD upperCaseKeywords()
METHOD removeTabs()
METHOD RemoveTrailingSpaces()
METHOD getSelectedText()
@@ -979,6 +980,15 @@ METHOD IdeEditsManager:insertText( cKey )
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:upperCaseKeywords()
LOCAL oEdit
IF !empty( oEdit := ::getEditObjectCurrent() )
oEdit:upperCaseKeywords()
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEditsManager:formatBraces()
LOCAL oEdit
IF !empty( oEdit := ::getEditObjectCurrent() )

View File

@@ -947,6 +947,7 @@ METHOD HbIde:execAction( cKey )
CASE "InsertExternalFile"
CASE "ZoomIn"
CASE "ZoomOut"
CASE "UpperCaseKeywords"
CASE "FormatBraces"
CASE "RemoveTabs"
CASE "Spaces2Tabs"
@@ -1078,6 +1079,9 @@ METHOD HbIde:execEditorAction( cKey )
CASE "ZoomOut"
::oEM:zoom( -1 )
EXIT
CASE "UpperCaseKeywords"
::oEM:upperCaseKeywords()
EXIT
CASE "FormatBraces"
::oEM:formatBraces()
EXIT

View File

@@ -226,7 +226,7 @@ METHOD IdeThemes:create( oIde, cThemesFile )
'class','endclass','method','data','var','destructor','inline','assign','access',;
'inherit','init','create','virtual','message', 'from', 'setget',;
'begin','sequence','try','catch','always','recover','hb_symbol_unused', ;
'error','handler' }
'error','handler','private','public' }
s := ""; aeval( b_, {|e| s += iif( empty( s ), "", "|" ) + "\b" + e + "\b" } )
aadd( ::aPatterns, { "HarbourKeywords" , s, .f. } )