2010-07-25 14:42 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)

* contrib/hbqt/hbqt_hbqplaintextedit.cpp
  * contrib/hbqt/hbqt_hbqplaintextedit.h
    + Added: more class methods.

  * contrib/hbide/ideedit.prg
    % Refined: alias->fieldsList protocol. 

    + Implemented: abbreviated code completion usage.
      Here is how it works:
        1. Create {hbide_resources_path}/hbide_protos_shorthand.txt
        2. Include entries ( one for every separate line ) similar to:
             zSDB-   SET DATE BRITISH
             zSAT-   SET ALTERNATE TO "myfile"
             zCmdD-  DEFINE WINDOW oWnd BLAH-BLAH-BLAH
        3. Execute hbIDE. Remember that any file prefixed as "hbide_protos_"
           will be populated in the code completion lists.
        4. In some editing instance, type "z" and you will see 
           above entries inside completion popup.
        5. As usual, select one, say zSAT, and you will see 
           'SET ALTERNATE TO "myfile"' inserted removing keyword characters.

      NOTE: shorthand keyword is case insensitive. So you can use
            this feature to the best of visualization.

            Keywords demonstrated as above are prefixed with "z",
            just because all shorthand(S) will be clubbed together,
            but you may use any characters you like.          

            Keyword must ever be followed by "-" (hyphen) character without 
            any spaces in between. This tells hbIDE that it is a shorthand word.
            Anyhow you can format the value as you like best.

            On basis of above theory, we can implement more constructs.
            I am looking forward what else you preceive which can be done.
This commit is contained in:
Pritpal Bedi
2010-07-25 22:05:08 +00:00
parent 5eca19bb93
commit 69befd642c
4 changed files with 88 additions and 40 deletions

View File

@@ -16,6 +16,42 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-07-25 14:42 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbqt/hbqt_hbqplaintextedit.cpp
* contrib/hbqt/hbqt_hbqplaintextedit.h
+ Added: more class methods.
* contrib/hbide/ideedit.prg
% Refined: alias->fieldsList protocol.
+ Implemented: abbreviated code completion usage.
Here is how it works:
1. Create {hbide_resources_path}/hbide_protos_shorthand.txt
2. Include entries ( one for every separate line ) similar to:
zSDB- SET DATE BRITISH
zSAT- SET ALTERNATE TO "myfile"
zCmdD- DEFINE WINDOW oWnd BLAH-BLAH-BLAH
3. Execute hbIDE. Remember that any file prefixed as "hbide_protos_"
will be populated in the code completion lists.
4. In some editing instance, type "z" and you will see
above entries inside completion popup.
5. As usual, select one, say zSAT, and you will see
'SET ALTERNATE TO "myfile"' inserted removing keyword characters.
NOTE: shorthand keyword is case insensitive. So you can use
this feature to the best of visualization.
Keywords demonstrated as above are prefixed with "z",
just because all shorthand(S) will be clubbed together,
but you may use any characters you like.
Keyword must ever be followed by "-" (hyphen) character without
any spaces in between. This tells hbIDE that it is a shorthand word.
Anyhow you can format the value as you like best.
On basis of above theory, we can implement more constructs.
I am looking forward what else you preceive which can be done.
2010-07-25 17:42 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* ChangeLog
! Fixed missing changelog entry for hbmk2.prg. See it right

View File

@@ -199,8 +199,6 @@ CLASS IdeEdit INHERIT IdeObject
METHOD showPrototype( cProto )
METHOD hidePrototype()
METHOD completeCode( p )
METHOD completeFieldName( p )
// METHOD updateFieldsList( cAlias )
METHOD setLineNumbersBkColor( nR, nG, nB )
METHOD setCurrentLineColor( nR, nG, nB )
@@ -2219,19 +2217,28 @@ METHOD IdeEdit:hidePrototype()
/*----------------------------------------------------------------------*/
METHOD IdeEdit:parseCodeCompletion( cSyntax )
LOCAL cText, n
LOCAL cText, n, nFun, nAbr, nSpc
nAbr := at( "-", cSyntax )
nSpc := at( " ", cSyntax )
nFun := at( "(", cSyntax )
IF nAbr > 0 .AND. iif( nSpc == 0, .t., nAbr < nSpc ).AND. iif( nFun == 0, .t., nAbr < nFun )
cText := alltrim( substr( cSyntax, nAbr + 1 ) )
IF ::oINI:lCompleteArgumented
IF ( n := rat( ")", cSyntax ) ) > 0
cText := trim( substr( cSyntax, 1, n ) )
ELSE
cText := trim( cSyntax )
ENDIF
ELSE
IF ( n := at( "(", cSyntax ) ) > 0
cText := trim( substr( cSyntax, 1, n - 1 ) )
IF ::oINI:lCompleteArgumented
IF ( n := rat( ")", cSyntax ) ) > 0
cText := trim( substr( cSyntax, 1, n ) )
ELSE
cText := trim( cSyntax )
ENDIF
ELSE
cText := trim( cSyntax )
IF nFun > 0 .AND. nFun < nSpc
cText := trim( substr( cSyntax, 1, nFun - 1 ) )
ELSE
cText := trim( cSyntax )
ENDIF
ENDIF
ENDIF
@@ -2241,33 +2248,25 @@ METHOD IdeEdit:parseCodeCompletion( cSyntax )
METHOD IdeEdit:completeCode( p )
LOCAL qCursor := QTextCursor():from( ::qEdit:textCursor() )
LOCAL cWord
qCursor:movePosition( QTextCursor_Left )
qCursor:movePosition( QTextCursor_StartOfWord )
qCursor:movePosition( QTextCursor_EndOfWord, QTextCursor_KeepAnchor )
cWord := qCursor:selectedText()
IF cWord == "->"
qCursor:clearSelection()
ENDIF
qCursor:insertText( ::parseCodeCompletion( p ) )
qCursor:movePosition( QTextCursor_Left )
qCursor:movePosition( QTextCursor_Right )
::qEdit:setTextCursor( qCursor )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEdit:completeFieldName( p )
LOCAL qCursor := QTextCursor():from( ::qEdit:textCursor() )
qCursor:movePosition( QTextCursor_Left )
qCursor:movePosition( QTextCursor_StartOfWord )
qCursor:movePosition( QTextCursor_EndOfWord, QTextCursor_KeepAnchor )
qCursor:insertText( ::parseCodeCompletion( p ) )
qCursor:movePosition( QTextCursor_Left )
qCursor:movePosition( QTextCursor_Right )
::qEdit:setTextCursor( qCursor )
::qEdit:hbSetFieldsListActive( ::oEM:updateFieldsList() )
RETURN Self

View File

@@ -1350,6 +1350,8 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event )
PHB_ITEM p1 = hb_itemPutNI( NULL, 21001 );
hb_vmEvalBlockV( block, 1, p1 );
hb_itemRelease( p1 );
hbRefreshCompleter();
}
break;
case Qt::Key_ParenLeft:
@@ -1378,16 +1380,7 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event )
}
if( ! isAliasCompleter ){
QString alias = hbTextAlias();
if( ! alias.isEmpty() ){
if( block ){
PHB_ITEM p1 = hb_itemPutNI( NULL, 21041 );
PHB_ITEM p2 = hb_itemPutC( NULL, alias.toLatin1().data() );
hb_vmEvalBlockV( block, 2, p1, p2 );
hb_itemRelease( p1 );
hb_itemRelease( p2 );
}
}
hbRefreshCompleter( hbTextAlias() );
}
if( ( event->modifiers() & ( Qt::ControlModifier | Qt::AltModifier ) ) ){
@@ -1401,6 +1394,7 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event )
static QString eow( " ~!@#$%^&*()+{}|:\"<>?,./;'[]\\-=" ); /* end of word */
bool hasModifier = ( event->modifiers() != Qt::NoModifier ) && !ctrlOrShift;
QString completionPrefix = hbTextUnderCursor( true );
//QString completionPrefix = hbTextUnderCursor( false );
if( hasModifier ||
event->text().isEmpty() ||
@@ -1408,6 +1402,10 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event )
eow.contains( event->text().right( 1 ) ) )
{
c->popup()->hide();
#if 0
if( isAliasCompleter )
hbRefreshCompleter( "" );
#endif
return;
}
@@ -1424,17 +1422,31 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event )
c->complete( cr ); // pop it up!
if( c->popup()->isHidden() && isAliasCompleter ){
#if 0
if( block ){
PHB_ITEM p1 = hb_itemPutNI( NULL, 21042 );
PHB_ITEM p1 = hb_itemPutNI( NULL, 21041 );
hb_vmEvalBlockV( block, 1, p1 );
hb_itemRelease( p1 );
isAliasCompleter = false;
}
#endif
}
}
/*----------------------------------------------------------------------*/
void HBQPlainTextEdit::hbRefreshCompleter( const QString & alias )
{
if( block ){
PHB_ITEM p1 = hb_itemPutNI( NULL, 21041 );
PHB_ITEM p2 = hb_itemPutC( NULL, alias.toLatin1().data() );
hb_vmEvalBlockV( block, 2, p1, p2 );
hb_itemRelease( p1 );
hb_itemRelease( p2 );
}
}
/*------------------------------------------------------------------------*/
QString HBQPlainTextEdit::hbTextUnderCursor( bool bCodeComplete )
{
QTextCursor tc( textCursor() );

View File

@@ -219,6 +219,7 @@ public slots:
void hbSetProtoStyle( const QString & css = "" );
void hbSelectAll();
void hbSetFieldsListActive( bool active ) { isAliasCompleter = active; };
void hbRefreshCompleter( const QString & alias = "" );
private slots:
void hbSlotCursorPositionChanged();