2010-02-13 03:07 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbqt/hbqt_hbqplaintextedit.cpp
* contrib/hbqt/hbqt_hbqplaintextedit.h
* contrib/hbqt/qtgui/HBQPlainTextEdit.cpp
* contrib/hbqt/qtgui/THBQPlainTextEdit.prg
* contrib/hbqt/qth/HBQPlainTextEdit.qth
* contrib/hbide/resources/skeletons.ui
* contrib/hbide/resources/skeletons.uic
* contrib/hbide/hbide.prg
* contrib/hbide/ideactions.prg
* contrib/hbide/idedocks.prg
* contrib/hbide/ideeditor.prg
* contrib/hbide/ideobject.prg
* contrib/hbide/idesaveload.prg
+ Implemented "Invert Case" feature.
% All operations applied on selected text do not remove selections.
However "undo/redo" does not respect selections.
+ Added <Docks> main-menu option which presents toggling feature
for all implemented docked windows. It facilitates clubbing
all toggle actions at one convenient place.
+ Implemented "Code Skeletons".
How to write
============
* Click <Docks> main-menu option and select <Code Skeletons>.
* "Code Skeletons" window will open at the right-docking area.
* Close other docks if open to make room for its components.
* Click <Add New> button, a dialog will appear requesting a "Name".
* Enter recognizable name for this skeleton, i.e., "DO CASE 3",
where "3" will represent that this case statement contains 3
iterations of CASE statement. It is just an example, follow
your way of recognitions.
* After you click <ok> the name will appear in "Identity" list-box.
* Start writing in "Code Snippet" editor, like:
DO CASE
CASE x ==
CASE x ==
CASE x ==
ENDCASE
* After you are done with it, click <Update>.
* Repeat the process for some other skeletons.
* Do not forget to click <Update> even after slightest modification.
This will ensure that your skeleton is always in order.
* If you wish to change the name, click on that "Name" in
"Identity" list-box and click <Rename>, follow next process.
Click <Update> to save permanently.
* <Delete> is not working yet.
* Navigate the skeletons by clicking on the prompts; you will
find the attached code in the editor below.
How to Call
===========
* While in the editor tab, position your editing cursor at
desired column.
* Press Ctrl+K, a context menu will appear near left-upper part
of the editing tab containing all skeletons you wrote.
* Use arrow-up/down keys to desired skeleton and press <Enter>.
* The code skeleton will be inserted in the source aligned
to the column you started with. The cursor will be anchored
on the same place.
* Alternativly you can use mouse, but keyboard navigation is
simple in this context.
* Note that alignment and indent of inserted code skeleton is
perfect to starting column.
Note: Your suggessions are welcome to enhance this feature.
This commit is contained in:
@@ -17,6 +17,78 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-02-13 03:43 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* contrib/hbqt/hbqt_hbqplaintextedit.cpp
|
||||
* contrib/hbqt/hbqt_hbqplaintextedit.h
|
||||
* contrib/hbqt/qtgui/HBQPlainTextEdit.cpp
|
||||
* contrib/hbqt/qtgui/THBQPlainTextEdit.prg
|
||||
* contrib/hbqt/qth/HBQPlainTextEdit.qth
|
||||
|
||||
* contrib/hbide/resources/skeletons.ui
|
||||
* contrib/hbide/resources/skeletons.uic
|
||||
|
||||
* contrib/hbide/hbide.prg
|
||||
* contrib/hbide/ideactions.prg
|
||||
* contrib/hbide/idedocks.prg
|
||||
* contrib/hbide/ideeditor.prg
|
||||
* contrib/hbide/ideobject.prg
|
||||
* contrib/hbide/idesaveload.prg
|
||||
|
||||
+ Implemented "Invert Case" feature.
|
||||
|
||||
% All operations applied on selected text do not remove selections.
|
||||
However "undo/redo" does not respect selections.
|
||||
|
||||
+ Added <Docks> main-menu option which presents toggling feature
|
||||
for all implemented docked windows. It facilitates clubbing
|
||||
all toggle actions at one convenient place.
|
||||
|
||||
+ Implemented "Code Skeletons".
|
||||
How to write
|
||||
============
|
||||
* Click <Docks> main-menu option and select <Code Skeletons>.
|
||||
* "Code Skeletons" window will open at the right-docking area.
|
||||
* Close other docks if open to make room for its components.
|
||||
* Click <Add New> button, a dialog will appear requesting a "Name".
|
||||
* Enter recognizable name for this skeleton, i.e., "DO CASE 3",
|
||||
where "3" will represent that this case statement contains 3
|
||||
iterations of CASE statement. It is just an example, follow
|
||||
your way of recognitions.
|
||||
* After you click <ok> the name will appear in "Identity" list-box.
|
||||
* Start writing in "Code Snippet" editor, like:
|
||||
DO CASE
|
||||
CASE x ==
|
||||
CASE x ==
|
||||
CASE x ==
|
||||
ENDCASE
|
||||
* After you are done with it, click <Update>.
|
||||
* Repeat the process for some other skeletons.
|
||||
* Do not forget to click <Update> even after slightest modification.
|
||||
This will ensure that your skeleton is always in order.
|
||||
* If you wish to change the name, click on that "Name" in
|
||||
"Identity" list-box and click <Rename>, follow next process.
|
||||
Click <Update> to save permanently.
|
||||
* <Delete> is not working yet.
|
||||
* Navigate the skeletons by clicking on the prompts; you will
|
||||
find the attached code in the editor below.
|
||||
|
||||
How to Call
|
||||
===========
|
||||
* While in the editor tab, position your editing cursor at
|
||||
desired column.
|
||||
* Press Ctrl+K, a context menu will appear near left-upper part
|
||||
of the editing tab containing all skeletons you wrote.
|
||||
* Use arrow-up/down keys to desired skeleton and press <Enter>.
|
||||
* The code skeleton will be inserted in the source aligned
|
||||
to the column you started with. The cursor will be anchored
|
||||
on the same place.
|
||||
* Alternativly you can use mouse, but keyboard navigation is
|
||||
simple in this context.
|
||||
* Note that alignment and indent of inserted code skeleton is
|
||||
perfect to starting column.
|
||||
|
||||
Note: Your suggessions are welcome to enhance this feature.
|
||||
|
||||
2010-02-13 12:36 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/src/vm/strapi.c
|
||||
! fixed hb_[w]strunshare() functions to always clone writable
|
||||
|
||||
@@ -91,6 +91,14 @@ STATIC s_pathSep
|
||||
PROCEDURE Main( cProjIni )
|
||||
LOCAL oIde
|
||||
|
||||
/* Testing paths */
|
||||
#ifdef __TESTING_PATHS__
|
||||
hbide_dbg( hbmk2_PathMakeRelative( "C:\dev_projects", "C:\dev_sources\vouch\myfile.prg", .f. ) )
|
||||
hbide_dbg( hbmk2_PathMakeRelative( "C:\dev_projects", "C:\dev_sources\vouch\myfile.prg", .t. ) )
|
||||
hbide_dbg( hbmk2_PathMakeRelative( "C:/dev_projects", "C:/dev_sources/vouch/myfile.prg", .t. ) )
|
||||
hbide_dbg( hbmk2_PathMakeRelative( "C:\dev_projects", "C:/dev_sources/vouch/myfile.prg", .t. ) )
|
||||
#endif
|
||||
|
||||
SET CENTURY ON
|
||||
SET EPOCH TO 1970
|
||||
|
||||
@@ -210,6 +218,7 @@ CLASS HbIde
|
||||
|
||||
DATA oEnvironment
|
||||
|
||||
DATA cPathSkltns INIT ""
|
||||
DATA cSaveTo INIT ""
|
||||
DATA oOpenedSources
|
||||
DATA resPath INIT hb_DirBase() + "resources" + hb_OsPathSeparator()
|
||||
@@ -224,6 +233,7 @@ CLASS HbIde
|
||||
|
||||
DATA aTags INIT {}
|
||||
DATA aText INIT {}
|
||||
DATA aSkltns INIT {}
|
||||
DATA aSources INIT {}
|
||||
DATA aFuncList INIT {}
|
||||
DATA aLines INIT {}
|
||||
@@ -301,6 +311,10 @@ METHOD HbIde:create( cProjIni )
|
||||
::cWrkFolderFind := ::aINI[ INI_HBIDE, CurrentFolderFind ]
|
||||
::cWrkReplace := ::aINI[ INI_HBIDE, CurrentReplace ]
|
||||
::cWrkView := ::aINI[ INI_HBIDE, CurrentView ]
|
||||
|
||||
/* Load Code Skeletons */
|
||||
hbide_loadSkltns( Self )
|
||||
|
||||
/* Set Codec at the Begining */
|
||||
HbXbp_SetCodec( ::cWrkCodec )
|
||||
|
||||
@@ -310,14 +324,13 @@ METHOD HbIde:create( cProjIni )
|
||||
::oDK:buildDialog()
|
||||
/* Actions */
|
||||
::oAC := IdeActions():new( Self ):create()
|
||||
/* Docking Widgets */
|
||||
::oDK:buildDockWidgets()
|
||||
/* Toolbar */
|
||||
::oAC:buildToolBar()
|
||||
/* Main Menu */
|
||||
::oAC:buildMainMenu()
|
||||
|
||||
/* Docking Widgets */
|
||||
::oDK:buildDockWidgets()
|
||||
|
||||
/* Once create Find/Replace dialog */
|
||||
::oFR := IdeFindReplace():new( Self ):create()
|
||||
|
||||
@@ -434,6 +447,8 @@ METHOD HbIde:create( cProjIni )
|
||||
|
||||
::oFR:destroy()
|
||||
::oEM:destroy()
|
||||
::oDK:destroy()
|
||||
* ::oAC:destroy() /* GPF */
|
||||
::oDlg:destroy()
|
||||
::oAC:destroy()
|
||||
|
||||
|
||||
@@ -574,7 +574,27 @@ METHOD IdeActions:buildMainMenu()
|
||||
oSubMenu2 := hbide_buildCodecMenu( oIde, oSubMenu )
|
||||
oSubMenu2:title := "~Codecs"
|
||||
oSubMenu:addItem( { oSubMenu2, NIL } )
|
||||
hbide_menuAddSep( oSubMenu )
|
||||
oMenuBar:addItem( { oSubMenu, NIL } )
|
||||
oSubMenu:oWidget:addAction_4( ::oSkeltn:oWidget:toggleViewAction() )
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Docks */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
oSubMenu := XbpMenu():new( oMenuBar ):create()
|
||||
oSubMenu:title := "~Docks"
|
||||
oMenuBar:addItem( { oSubMenu, NIL } )
|
||||
|
||||
oSubMenu:oWidget:addAction_4( ::oDockED:oWidget:toggleViewAction() )
|
||||
oSubMenu:oWidget:addAction_4( ::oDockPT:oWidget:toggleViewAction() )
|
||||
|
||||
oSubMenu:oWidget:addAction_4( ::oDockR:oWidget:toggleViewAction() )
|
||||
oSubMenu:oWidget:addAction_4( ::oHelp:oWidget:toggleViewAction() )
|
||||
oSubMenu:oWidget:addAction_4( ::oSkeltn:oWidget:toggleViewAction() )
|
||||
|
||||
oSubMenu:oWidget:addAction_4( ::oDockB2:oWidget:toggleViewAction() )
|
||||
oSubMenu:oWidget:addAction_4( ::oDockB1:oWidget:toggleViewAction() )
|
||||
oSubMenu:oWidget:addAction_4( ::oDockB:oWidget:toggleViewAction() )
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Help */
|
||||
|
||||
@@ -127,6 +127,19 @@ METHOD IdeDocks:create( oIde )
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeDocks:destroy()
|
||||
LOCAL oUI := ::oIde:oSkeltnUI
|
||||
|
||||
::disconnect( oUI:q_buttonNew , "clicked()" )
|
||||
::disconnect( oUI:q_buttonRename, "clicked()" )
|
||||
::disconnect( oUI:q_buttonDelete, "clicked()" )
|
||||
::disconnect( oUI:q_buttonClear , "clicked()" )
|
||||
::disconnect( oUI:q_buttonGetSel, "clicked()" )
|
||||
::disconnect( oUI:q_buttonUpdate, "clicked()" )
|
||||
::disconnect( oUI:q_listNames , "itemSelectionChanged()" )
|
||||
|
||||
oUI:destroy()
|
||||
|
||||
/* Initiate more destructors */
|
||||
|
||||
RETURN Self
|
||||
|
||||
@@ -796,13 +809,14 @@ METHOD IdeDocks:buildSkeletonWidget()
|
||||
//::oSkeltnUI:q_editCode:setFontPointSize( 10 )
|
||||
|
||||
//::oSkeltnUI:q_editCode:setFont( ::oFont:oWidget )
|
||||
aeval( ::aSkltns, {|e_| ::oSkeltnUI:q_listNames:addItem( e_[ 1 ] ) } )
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeDocks:execSkeleton( nMode, p )
|
||||
LOCAL cName, qItem, cCode
|
||||
LOCAL cName, cNewName, qItem, cCode, n
|
||||
|
||||
HB_SYMBOL_UNUSED( p )
|
||||
|
||||
@@ -811,13 +825,17 @@ METHOD IdeDocks:execSkeleton( nMode, p )
|
||||
CASE 1
|
||||
IF !empty( cName := hbide_fetchAString( ::oSkeltnUI:q_listNames, "", "Name", "New Skeleton" ) )
|
||||
::oSkeltnUI:q_listNames:addItem( cName )
|
||||
aadd( ::oIde:aSkltns, { cName, "" } )
|
||||
::oSkeltnUI:q_listNames:setCurrentRow( len( ::aSkltns ) - 1 )
|
||||
ENDIF
|
||||
EXIT
|
||||
CASE 2
|
||||
qItem := QListWidgetItem():configure( ::oSkeltnUI:q_listNames:currentItem() )
|
||||
cName := qItem:text()
|
||||
IF !empty( cName := hbide_fetchAString( ::oSkeltnUI:q_listNames, cName, "Name", "New Skeleton" ) )
|
||||
qItem:setText( cName )
|
||||
IF !empty( cNewName := hbide_fetchAString( ::oSkeltnUI:q_listNames, cName, "Name", "Change Skeleton's Name" ) )
|
||||
qItem:setText( cNewName )
|
||||
n := ascan( ::aSkltns, {|e_| e_[ 1 ] == cName } )
|
||||
::aSkltns[ n, 1 ] := cNewName
|
||||
ENDIF
|
||||
EXIT
|
||||
CASE 3
|
||||
@@ -830,15 +848,26 @@ METHOD IdeDocks:execSkeleton( nMode, p )
|
||||
CASE 5
|
||||
IF !empty( cCode := ::oEM:getSelectedText() )
|
||||
// TODO: Format cCode
|
||||
cCode := strtran( cCode, chr( 0x2029 ), chr( 10 ) )
|
||||
::oSkeltnUI:q_editCode:setPlainText( cCode )
|
||||
ENDIF
|
||||
EXIT
|
||||
CASE 6
|
||||
// Update the skeleton code and save the skeleton's buffer | file
|
||||
qItem := QListWidgetItem():configure( ::oSkeltnUI:q_listNames:currentItem() )
|
||||
cName := qItem:text()
|
||||
IF !empty( cName )
|
||||
n := ascan( ::aSkltns, {|e_| e_[ 1 ] == cName } )
|
||||
::aSkltns[ n,2 ] := ::oSkeltnUI:q_editCode:toPlainText()
|
||||
|
||||
hbide_saveSkltns( ::oIde )
|
||||
ENDIF
|
||||
EXIT
|
||||
CASE 7
|
||||
|
||||
qItem := QListWidgetItem():configure( ::oSkeltnUI:q_listNames:currentItem() )
|
||||
cName := qItem:text()
|
||||
n := ascan( ::aSkltns, {|e_| e_[ 1 ] == cName } )
|
||||
::oSkeltnUI:q_editCode:setPlainText( ::aSkltns[ n,2 ] )
|
||||
EXIT
|
||||
ENDSWITCH
|
||||
|
||||
|
||||
@@ -835,7 +835,7 @@ METHOD IdeEditsManager:getSelectedText()
|
||||
LOCAL qEdit
|
||||
|
||||
IF !empty( qEdit := ::oEM:getEditCurrent() )
|
||||
RETURN QTextCursor():configure( qEdit:textCursor() ):selectedText()
|
||||
RETURN qEdit:getSelectedText()
|
||||
ENDIF
|
||||
|
||||
RETURN ""
|
||||
@@ -1135,7 +1135,6 @@ METHOD IdeEditor:setDocumentProperties()
|
||||
qCursor := QTextCursor():configure( ::qEdit:textCursor() )
|
||||
|
||||
IF !( ::lLoaded ) /* First Time */
|
||||
// ::qEdit:clear()
|
||||
::qEdit:setPlainText( hb_memoRead( ::sourceFile ) )
|
||||
qCursor:setPosition( ::nPos )
|
||||
::qEdit:setTextCursor( qCursor )
|
||||
@@ -1376,6 +1375,7 @@ CLASS IdeEdit INHERIT IdeObject
|
||||
METHOD caseInvert()
|
||||
METHOD findLastIndent()
|
||||
METHOD reLayMarkButtons()
|
||||
METHOD presentSkeletons()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
@@ -1530,7 +1530,7 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 )
|
||||
::relayMarkButtons()
|
||||
|
||||
/* An experimental move but seems a lot is required to achieve column selection */
|
||||
* qEdit:highlightSelectedColumns( ::isColumnSelectionEnabled )
|
||||
qEdit:highlightSelectedColumns( ::isColumnSelectionEnabled )
|
||||
|
||||
::oDK:setStatusText( SB_PNL_SELECTEDCHARS, len( qCursor:selectedText() ) )
|
||||
|
||||
@@ -1636,6 +1636,11 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p )
|
||||
::duplicateLine()
|
||||
ENDIF
|
||||
EXIT
|
||||
CASE Qt_Key_K
|
||||
IF lCtrl
|
||||
::presentSkeletons()
|
||||
ENDIF
|
||||
EXIT
|
||||
CASE Qt_Key_Backspace
|
||||
hbide_justACall( txt, lAlt, lShift, lCtrl, qEvent, nMode )
|
||||
EXIT
|
||||
@@ -1667,6 +1672,43 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeEdit:presentSkeletons()
|
||||
LOCAL qCrs, qMenu, pAct, cAct, n, a_, qAct, nPos, nCol, s
|
||||
|
||||
IF !empty( ::aSkltns )
|
||||
qCrs := QTextCursor():configure( ::qEdit:textCursor() )
|
||||
|
||||
//qRc := QRect():configure( ::qEdit:cursorRect() )
|
||||
|
||||
qMenu := QMenu():new( ::qEdit )
|
||||
FOR EACH a_ IN ::aSkltns
|
||||
qMenu:addAction( a_[ 1 ] )
|
||||
NEXT
|
||||
|
||||
pAct := qMenu:exec_1( ::qEdit:mapToGlobal( QPoint():new( 100,100 ) ) )
|
||||
IF !hbqt_isEmptyQtPointer( pAct )
|
||||
qAct := QAction():configure( pAct )
|
||||
cAct := qAct:text()
|
||||
IF ( n := ascan( ::aSkltns, {|e_| e_[ 1 ] == cAct } ) ) > 0
|
||||
nPos := qCrs:position()
|
||||
nCol := qCrs:columnNumber()
|
||||
a_:= hbide_memoToArray( ::aSkltns[ n,2 ] )
|
||||
FOR EACH s IN a_
|
||||
IF s:__enumIndex() > 1
|
||||
s := space( nCol ) + s
|
||||
ENDIF
|
||||
NEXT
|
||||
qCrs:insertText( hbide_arrayToMemo( a_ ) )
|
||||
qCrs:setPosition( nPos )
|
||||
::qEdit:setTextCursor( qCrs )
|
||||
ENDIF
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
RETURN Self
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeEdit:gotoMark( nIndex )
|
||||
IF len( ::aBookMarks ) >= nIndex
|
||||
::qEdit:gotoBookmark( ::aBookMarks[ nIndex ] )
|
||||
@@ -1760,23 +1802,21 @@ METHOD IdeEdit:caseLower()
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD IdeEdit:caseInvert()
|
||||
LOCAL qCursor, i, c, s, cBuffer, nLen // qDoc, nBlock
|
||||
LOCAL i, c, s, cBuffer, nLen
|
||||
|
||||
qCursor := QTextCursor():configure( ::qCurEdit:textCursor() )
|
||||
IF qCursor:hasSelection() .AND. ! empty( cBuffer := qCursor:selectedText() )
|
||||
//qDoc := QTextDocument()configure( ::qEdit:document() )
|
||||
IF !empty( cBuffer := ::oEM:getSelectedText() )
|
||||
s := ""
|
||||
nLen := len( cBuffer )
|
||||
//nStart := qCursor:startSelection()
|
||||
|
||||
FOR i := 1 TO nLen
|
||||
c := substr( cBuffer, i, 1 )
|
||||
IF isAlpha( c ) //!( c $ CRLF ) .AND.
|
||||
IF isAlpha( c )
|
||||
s += iif( isUpper( c ), lower( c ), upper( c ) )
|
||||
ELSE
|
||||
s += c
|
||||
ENDIF
|
||||
NEXT
|
||||
hbide_dbg( s )
|
||||
|
||||
::qEdit:replaceSelection( s )
|
||||
ENDIF
|
||||
|
||||
|
||||
@@ -135,11 +135,13 @@ CLASS IdeObject
|
||||
ACCESS aProjData INLINE ::oIde:aProjData
|
||||
ACCESS aTabs INLINE ::oIde:aTabs
|
||||
ACCESS aViews INLINE ::oIde:aViews
|
||||
ACCESS aSkltns INLINE ::oIde:aSkltns
|
||||
|
||||
ACCESS nCurView INLINE ::oIde:nCurView
|
||||
ACCESS nTabSpaces INLINE ::oIde:nTabSpaces
|
||||
ACCESS cTabSpaces INLINE ::oIde:cTabSpaces
|
||||
ACCESS cSeparator INLINE ::oIde:cSeparator
|
||||
ACCESS cPathSkltns INLINE ::oIde:cPathSkltns
|
||||
|
||||
ACCESS oDockPT INLINE ::oIde:oDockPT
|
||||
ACCESS oProjTree INLINE ::oIde:oProjTree
|
||||
|
||||
@@ -214,7 +214,7 @@ FUNCTION hbide_loadINI( oIde, cHbideIni )
|
||||
NEXT
|
||||
|
||||
IF empty( cHbideIni )
|
||||
IF file( "hbide.ini" )
|
||||
IF hb_fileExists( "hbide.ini" )
|
||||
cHbideIni := "hbide.ini"
|
||||
ELSE
|
||||
cHbideIni := hb_dirBase() + "hbide.ini"
|
||||
@@ -360,3 +360,74 @@ FUNCTION hbide_restSettings( oIde )
|
||||
RETURN nil
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
FUNCTION hbide_loadSkltns( oIde, cPathSkltns )
|
||||
LOCAL cPath, s, n, cSkltn, cCode
|
||||
|
||||
IF empty( cPathSkltns )
|
||||
hb_fNameSplit( oIde:cProjIni, @cPath )
|
||||
cPath += "hbide.skl"
|
||||
|
||||
IF hb_fileExists( cPath )
|
||||
cPathSkltns := cPath
|
||||
ELSE
|
||||
cPathSkltns := hb_dirBase() + "hbide.skl"
|
||||
ENDIF
|
||||
ENDIF
|
||||
oIde:cPathSkltns := cPathSkltns
|
||||
|
||||
IF hb_fileExists( cPathSkltns )
|
||||
s := hb_memoread( cPathSkltns )
|
||||
|
||||
DO WHILE .t.
|
||||
IF ( n := at( "<", s ) ) == 0
|
||||
EXIT
|
||||
ENDIF
|
||||
s := substr( s, n + 1 )
|
||||
IF ( n := at( ">", s ) ) == 0
|
||||
EXIT
|
||||
ENDIF
|
||||
cSkltn := substr( s, 1, n - 1 )
|
||||
s := substr( s, n + 1 )
|
||||
IF ( n := at( "</" + cSkltn + ">", s ) ) > 0
|
||||
cCode := substr( s, 1, n - 1 )
|
||||
cCode := alltrim( cCode )
|
||||
IF left( cCode, 1 ) $ chr( 13 ) + chr( 10 )
|
||||
cCode := substr( cCode, 2 )
|
||||
ENDIF
|
||||
IF left( cCode, 1 ) $ chr( 13 ) + chr( 10 )
|
||||
cCode := substr( cCode, 2 )
|
||||
ENDIF
|
||||
IF right( cCode, 1 ) $ chr( 13 ) + chr( 10 )
|
||||
cCode := substr( cCode, 1, len( cCode ) - 1 )
|
||||
ENDIF
|
||||
IF right( cCode, 1 ) $ chr( 13 ) + chr( 10 )
|
||||
cCode := substr( cCode, 1, len( cCode ) - 1 )
|
||||
ENDIF
|
||||
|
||||
aadd( oIde:aSkltns, { cSkltn, cCode } )
|
||||
s := substr( s, n + len( "</" + cSkltn + ">" ) )
|
||||
ELSE
|
||||
EXIT
|
||||
ENDIF
|
||||
ENDDO
|
||||
ENDIF
|
||||
|
||||
RETURN NIL
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
FUNCTION hbide_saveSkltns( oIde )
|
||||
LOCAL a_, txt_:= {}
|
||||
|
||||
FOR EACH a_ IN oIde:aSkltns
|
||||
aadd( txt_, "<" + a_[ 1 ] + ">" )
|
||||
aeval( hbide_memoToArray( a_[ 2 ] ), {|e| aadd( txt_, e ) } )
|
||||
aadd( txt_, "</" + a_[ 1 ] + ">" )
|
||||
aadd( txt_, "" )
|
||||
NEXT
|
||||
|
||||
RETURN hbide_createTarget( oIde:cPathSkltns, txt_ )
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -40,6 +40,29 @@
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<widget class="QPlainTextEdit" name="editCode">
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Code Skeletons in hbIDE are implemented in unique way. </span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">It is assumed that, while writing the source, any control structure</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">must be aligned to the column editing cursor is resting. So the</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">&quot;skeleton&quot; is inserted aligned to this column spanning multiple lines.</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Hence it is desired that you write code snippets aligned left without</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">any spaces for the left-most edge:</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">IF x == </span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> y := 12</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">ELSE</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;"> y := 32</span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">ENDIF</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Then, suppose edit cursor is resting on column 10, </span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">all these lines will align to column 10. Inner indents will </span></p>
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">be respected.</span></p>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html></string>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/********************************************************************************
|
||||
** Form generated from reading ui file 'skeletons.ui'
|
||||
**
|
||||
** Created: Fri Feb 12 18:01:10 2010
|
||||
** by: Qt User Interface Compiler version 4.5.3
|
||||
** Created: Sat Feb 13 03:04:34 2010
|
||||
** by: Qt User Interface Compiler version 4.5.0
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
||||
********************************************************************************/
|
||||
@@ -109,6 +109,32 @@ public:
|
||||
labelIdentity->setText(QApplication::translate("Form", "Identity", 0, QApplication::UnicodeUTF8));
|
||||
buttonDelete->setText(QApplication::translate("Form", "Delete", 0, QApplication::UnicodeUTF8));
|
||||
buttonRename->setText(QApplication::translate("Form", "Rename", 0, QApplication::UnicodeUTF8));
|
||||
#ifndef QT_NO_TOOLTIP
|
||||
editCode->setToolTip(QApplication::translate("Form", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Code Skeletons in hbIDE are implemented in unique way. </span></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">It is assumed that, while writing the source, any control structure</span></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">must be aligned to the column editing cursor is resting. So the</spa"
|
||||
"n></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">"skeleton" is inserted aligned to this column spanning multiple lines.</span></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">Hence it is desired that you write code snippets aligned left without</span></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">any spaces for the left-most edge:</span></p>\n"
|
||||
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">I"
|
||||
"F x == </span></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> y := 12</span></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">ELSE</span></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\"> y := 32</span></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">ENDIF</span></p>\n"
|
||||
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span "
|
||||
"style=\" font-size:8pt;\">Then, suppose edit cursor is resting on column 10, </span></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">all these lines will align to column 10. Inner indents will </span></p>\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:8pt;\">be respected.</span></p>\n"
|
||||
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"></p></body></html>", 0, QApplication::UnicodeUTF8));
|
||||
#endif // QT_NO_TOOLTIP
|
||||
buttonClear->setText(QApplication::translate("Form", "Clear", 0, QApplication::UnicodeUTF8));
|
||||
labelSnippets->setText(QApplication::translate("Form", "Code Snippet", 0, QApplication::UnicodeUTF8));
|
||||
buttonGetSel->setText(QApplication::translate("Form", "Get Selection", 0, QApplication::UnicodeUTF8));
|
||||
|
||||
@@ -429,44 +429,6 @@ void HBQPlainTextEdit::showHighlighter( const QString &style, bool b )
|
||||
styleHightlighter = style;
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::caseUpper()
|
||||
{
|
||||
QTextCursor cursor( textCursor() );
|
||||
QString selTxt( cursor.selectedText() );
|
||||
if( selTxt.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString txt = selTxt.toUpper();
|
||||
insertPlainText( txt );
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::caseLower()
|
||||
{
|
||||
QTextCursor cursor( textCursor() );
|
||||
QString selTxt( cursor.selectedText() );
|
||||
if( selTxt.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString txt = selTxt.toLower();
|
||||
insertPlainText( txt );
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::replaceSelection( const QString & txt )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( txt );
|
||||
|
||||
QTextCursor cursor( textCursor() );
|
||||
QString selTxt( cursor.selectedText() );
|
||||
if( selTxt.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString text = selTxt.toCaseFolded();
|
||||
insertPlainText( text );
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::escapeQuotes()
|
||||
{
|
||||
QTextCursor cursor( textCursor() );
|
||||
@@ -515,30 +477,136 @@ void HBQPlainTextEdit::unescapeDQuotes()
|
||||
insertPlainText( txt );
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::convertQuotes()
|
||||
void HBQPlainTextEdit::caseUpper()
|
||||
{
|
||||
QTextCursor cursor( textCursor() );
|
||||
QTextCursor cursor = textCursor();
|
||||
QString selTxt( cursor.selectedText() );
|
||||
if( selTxt.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString txt = selTxt.replace( QString( "\"" ), QString( "\'" ) );
|
||||
insertPlainText( txt );
|
||||
int b = cursor.selectionStart();
|
||||
int e = cursor.selectionEnd();
|
||||
cursor.beginEditBlock();
|
||||
|
||||
insertPlainText( selTxt.toUpper() );
|
||||
|
||||
cursor.setPosition( b );
|
||||
cursor.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, e-b );
|
||||
cursor.endEditBlock();
|
||||
setTextCursor( cursor );
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::caseLower()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
QString selTxt( cursor.selectedText() );
|
||||
if( selTxt.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
int b = cursor.selectionStart();
|
||||
int e = cursor.selectionEnd();
|
||||
cursor.beginEditBlock();
|
||||
|
||||
insertPlainText( selTxt.toLower() );
|
||||
|
||||
cursor.setPosition( b );
|
||||
cursor.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, e-b );
|
||||
cursor.endEditBlock();
|
||||
setTextCursor( cursor );
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::convertQuotes()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
QString selTxt( cursor.selectedText() );
|
||||
if( selTxt.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
int b = cursor.selectionStart();
|
||||
int e = cursor.selectionEnd();
|
||||
cursor.beginEditBlock();
|
||||
|
||||
insertPlainText( selTxt.replace( QString( "\"" ), QString( "\'" ) ) );
|
||||
|
||||
cursor.setPosition( b );
|
||||
cursor.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, e-b );
|
||||
cursor.endEditBlock();
|
||||
setTextCursor( cursor );
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::convertDQuotes()
|
||||
{
|
||||
QTextCursor cursor( textCursor() );
|
||||
QTextCursor cursor = textCursor();
|
||||
QString selTxt( cursor.selectedText() );
|
||||
if( selTxt.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString txt = selTxt.replace( QString( "\'" ), QString( "\"" ) );
|
||||
insertPlainText( txt );
|
||||
int b = cursor.selectionStart();
|
||||
int e = cursor.selectionEnd();
|
||||
cursor.beginEditBlock();
|
||||
|
||||
insertPlainText( selTxt.replace( QString( "\'" ), QString( "\"" ) ) );
|
||||
|
||||
cursor.setPosition( b );
|
||||
cursor.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, e-b );
|
||||
cursor.endEditBlock();
|
||||
setTextCursor( cursor );
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::replaceSelection( const QString & txt )
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
QString selTxt( cursor.selectedText() );
|
||||
if( selTxt.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
int b = cursor.selectionStart();
|
||||
cursor.beginEditBlock();
|
||||
|
||||
insertPlainText( txt );
|
||||
|
||||
cursor.setPosition( b );
|
||||
cursor.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, txt.length() );
|
||||
cursor.endEditBlock();
|
||||
setTextCursor( cursor );
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::streamComment()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
QString selTxt( cursor.selectedText() );
|
||||
if( selTxt.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
int b = cursor.selectionStart();
|
||||
int e = cursor.selectionEnd();
|
||||
cursor.beginEditBlock();
|
||||
|
||||
insertPlainText( "/*" + selTxt + "*/" );
|
||||
|
||||
cursor.setPosition( b );
|
||||
cursor.movePosition( QTextCursor::NextCharacter, QTextCursor::KeepAnchor, e-b+4 );
|
||||
cursor.endEditBlock();
|
||||
setTextCursor( cursor );
|
||||
}
|
||||
|
||||
QString HBQPlainTextEdit::getSelectedText()
|
||||
{
|
||||
QTextCursor cursor( textCursor() );
|
||||
QString selTxt( cursor.selectedText() );
|
||||
if( selTxt.isEmpty() )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
QString txt = selTxt.replace( 0x2029, QString( "\n" ) );
|
||||
return txt;
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::paintColumnSelection( QPaintEvent *event )
|
||||
{
|
||||
@@ -769,15 +837,6 @@ void HBQPlainTextEdit::blockComment()
|
||||
setTextCursor( c );
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::streamComment()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
QString textUnderCursor = cursor.selectedText();
|
||||
if( textUnderCursor.isEmpty() )
|
||||
return;
|
||||
insertPlainText( "/*" + textUnderCursor + "*/" );
|
||||
}
|
||||
|
||||
void HBQPlainTextEdit::duplicateLine()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
|
||||
@@ -149,6 +149,7 @@ public slots:
|
||||
void replaceSelection( const QString & txt );
|
||||
void insertTab( int mode );
|
||||
void highlightSelectedColumns( bool yes );
|
||||
QString getSelectedText();
|
||||
|
||||
private slots:
|
||||
void slotCursorPositionChanged();
|
||||
|
||||
@@ -395,6 +395,14 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HIGHLIGHTSELECTEDCOLUMNS )
|
||||
hbqt_par_HBQPlainTextEdit( 1 )->highlightSelectedColumns( hb_parl( 2 ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* QString getSelectedText()
|
||||
*/
|
||||
HB_FUNC( QT_HBQPLAINTEXTEDIT_GETSELECTEDTEXT )
|
||||
{
|
||||
hb_retc( hbqt_par_HBQPlainTextEdit( 1 )->getSelectedText().toAscii().data() );
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
#endif /* #if QT_VERSION >= 0x040500 */
|
||||
|
||||
@@ -97,6 +97,7 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit
|
||||
METHOD deleteLine()
|
||||
METHOD moveLine( nIDirection )
|
||||
METHOD highlightSelectedColumns( lYes )
|
||||
METHOD getSelectedText()
|
||||
|
||||
ENDCLASS
|
||||
|
||||
@@ -229,3 +230,7 @@ METHOD HBQPlainTextEdit:moveLine( nIDirection )
|
||||
METHOD HBQPlainTextEdit:highlightSelectedColumns( lYes )
|
||||
RETURN Qt_HBQPlainTextEdit_highlightSelectedColumns( ::pPtr, lYes )
|
||||
|
||||
|
||||
METHOD HBQPlainTextEdit:getSelectedText()
|
||||
RETURN Qt_HBQPlainTextEdit_getSelectedText( ::pPtr )
|
||||
|
||||
|
||||
@@ -128,6 +128,7 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT )
|
||||
void deleteLine()
|
||||
void moveLine( int iDirection )
|
||||
void highlightSelectedColumns( bool yes )
|
||||
QString getSelectedText()
|
||||
</SLOTS>
|
||||
|
||||
<SIGNALS>
|
||||
|
||||
Reference in New Issue
Block a user