2010-04-22 10:47 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)

* contrib/hbqt/hbqt_hbqplaintextedit.cpp

  * contrib/hbide/ideeditor.prg
  * contrib/hbide/ideshortcuts.prg
    ! Fixed few artifacts belonging to function prototype display 
      as tooltip and code completion behavior.
This commit is contained in:
Pritpal Bedi
2010-04-23 05:52:55 +00:00
parent 1f9802082d
commit d73eb1aeb4
4 changed files with 67 additions and 33 deletions

View File

@@ -17,6 +17,14 @@
past entries belonging to author(s): Viktor Szakats.
*/
2010-04-22 10:47 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbqt/hbqt_hbqplaintextedit.cpp
* contrib/hbide/ideeditor.prg
* contrib/hbide/ideshortcuts.prg
! Fixed few artifacts belonging to function prototype display
as tooltip and code completion behavior.
2010-04-23 02:36 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* utils/hbmk2/hbmk2.prg
* Minor adjustment to watcom -warn=max mapping.

View File

@@ -261,7 +261,7 @@ METHOD IdeEditsManager:addSourceInTree( cSourceFile, cView )
#if 0
cPathA := hbide_pathNormalized( cPath )
array2table(
IF ( n := ascan( ::aEditorPath, {|e_| e_[ 2 ] == cPathA } ) ) == 0
oParent := oGrand:addItem( cPath )
aadd( ::aProjData, { oParent, "Editor Path", oGrand, cPathA, cSourceFile } )
@@ -1806,11 +1806,13 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 )
::moveLine( -1 )
RETURN .t.
ENDIF
EXIT
CASE Qt_Key_Down
IF lCtrl .AND. lShift
::moveLine( 1 )
RETURN .t.
ENDIF
EXIT
CASE Qt_Key_ParenLeft
IF ! lCtrl .AND. ! lAlt
::loadFuncHelp() // Also invokes prototype display
@@ -1833,10 +1835,12 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 )
EXIT
CASE QEvent_Enter
CASE QEvent_FocusIn
::resumePrototype()
EXIT
CASE QEvent_Leave
CASE QEvent_FocusOut
::suspendPrototype()
EXIT
@@ -2145,8 +2149,9 @@ METHOD IdeEdit:getLineNo()
METHOD IdeEdit:insertSeparator( cSep )
LOCAL qCursor := QTextCursor():configure( ::qEdit:textCursor() )
DEFAULT cSep TO ::cSeparator
IF empty( cSep )
cSep := ::cSeparator
ENDIF
qCursor:beginEditBlock()
qCursor:movePosition( QTextCursor_StartOfBlock )
qCursor:insertBlock()
@@ -2327,11 +2332,37 @@ METHOD IdeEdit:clickFuncHelp()
/*----------------------------------------------------------------------*/
METHOD IdeEdit:loadFuncHelp()
LOCAL qEdit, qCursor, qTextBlock, cText, cWord, nCol, cPro
qEdit := ::qEdit
qCursor := QTextCursor():configure( qEdit:textCursor() )
qTextBlock := QTextBlock():configure( qCursor:block() )
cText := qTextBlock:text()
nCol := qCursor:columnNumber()
cWord := hbide_getPreviousWord( cText, nCol )
IF !empty( cWord )
IF ! empty( ::oHL )
::oHL:jumpToFunction( cWord )
ENDIF
IF !empty( cPro := ::oFN:positionToFunction( cWord, .t. ) )
IF empty( ::cProto )
::showPrototype( ::cProto := hbide_formatProto( cPro ) )
ENDIF
ENDIF
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeEdit:resumePrototype()
::isSuspended := .f.
IF !empty( ::qEdit )
::qEdit:hbShowPrototype( ::cProto )
IF ::getLineNo() == ::nProtoLine .AND. ::getColumnNo() >= ::nProtoCol
::qEdit:hbShowPrototype( ::cProto )
ENDIF
ENDIF
RETURN Self
@@ -2394,30 +2425,6 @@ METHOD IdeEdit:completeCode( p )
/*----------------------------------------------------------------------*/
METHOD IdeEdit:loadFuncHelp()
LOCAL qEdit, qCursor, qTextBlock, cText, cWord, nCol, cPro
qEdit := ::qEdit
qCursor := QTextCursor():configure( qEdit:textCursor() )
qTextBlock := QTextBlock():configure( qCursor:block() )
cText := qTextBlock:text()
nCol := qCursor:columnNumber()
cWord := hbide_getPreviousWord( cText, nCol )
IF !empty( cWord )
IF ! empty( ::oHL )
::oHL:jumpToFunction( cWord )
ENDIF
IF !empty( cPro := ::oFN:positionToFunction( cWord, .t. ) )
IF empty( ::cProto )
::showPrototype( ::cProto := hbide_formatProto( cPro ) )
ENDIF
ENDIF
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
FUNCTION hbide_getPreviousWord( cText, nPos )
LOCAL cWord, n
@@ -2542,6 +2549,7 @@ FUNCTION hbide_isHarbourKeyword( cWord )
'var' => NIL,;
'destructor' => NIL,;
'inline' => NIL,;
'setget' => NIL,;
'assign' => NIL,;
'access' => NIL,;
'inherit' => NIL,;

View File

@@ -1098,7 +1098,7 @@ METHOD IdeShortcuts:loadMethods()
'insert( "" )', ;
'Insert <cText> at current cursor position.' } )
aadd( ::aMethods, { 'separator( cSep )', ;
'separator( "" )', ;
'separator( ' + '/*' + replicate( "-", 68 ) + '*/' + ' )', ;
'Inserts separator line <cSep> immediately before current line. <cSep> defaults to "/*---*/"' } )
aadd( ::aMethods, { 'getWord( lSelect )', ;
'getWord( .f. )' , ;

View File

@@ -197,16 +197,27 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event )
QPlainTextEdit::keyPressEvent( event );
if( ! c )
return;
if( ( event->modifiers() & ( Qt::ControlModifier | Qt::AltModifier ) ) )
{
c->popup()->hide();
return;
}
const bool ctrlOrShift = event->modifiers() & ( Qt::ControlModifier | Qt::ShiftModifier );
if( !c || ( ctrlOrShift && event->text().isEmpty() ) )
if( ( ctrlOrShift && event->text().isEmpty() ) )
return;
static QString eow( "~!@#$%^&*()+{}|:\"<>?,./;'[]\\-=" ); /* end of word */
bool hasModifier = ( event->modifiers() != Qt::NoModifier ) && !ctrlOrShift;
QString completionPrefix = hbTextUnderCursor();
if( ( hasModifier || event->text().isEmpty() || completionPrefix.length() < 3
|| eow.contains( event->text().right( 1 ) ) ) )
if( ( hasModifier ||
event->text().isEmpty() ||
completionPrefix.length() < 3 ||
eow.contains( event->text().right( 1 ) ) ) )
{
c->popup()->hide();
return;
@@ -221,7 +232,14 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event )
cr.setWidth( c->popup()->sizeHintForColumn( 0 ) + c->popup()->verticalScrollBar()->sizeHint().width() );
c->complete( cr ); // popup it up!
}
#if 0
QString HBQPlainTextEdit::hbTextForPrefix()
{
QTextCursor tc = textCursor();
tc.select( QTextCursor::WordUnderCursor );
return tc.selectedText();
}
#endif
QString HBQPlainTextEdit::hbTextUnderCursor()
{
QTextCursor tc = textCursor();