diff options
author | Gergo Mocsi <gmocsi91@gmail.com> | 2013-08-13 18:11:26 +0200 |
---|---|---|
committer | Gergo Mocsi <gmocsi91@gmail.com> | 2013-08-13 18:11:26 +0200 |
commit | 2795bc817f1e783570c28428cec8e07b35cce7bb (patch) | |
tree | 161262af3343f2cd50a1970a2c4210946c5f3594 /basctl/source/basicide/baside2b.cxx | |
parent | 12de061bcbc4af45403099dd0a0c855c20cba1d8 (diff) |
GSOC work, behavior fixes
Code completition: left/right arrow keys handled. Left arrow dismisses the dialog when reaches the dot. Right arrow dismissed the dialog when reaches the next line.
ListBox appearance fixed.
TAB key can insert the first matching entry.
Autocorrect:
"Autocorrect Keywords" has been renamed to "Autcorrect" (in the UI, and the config file, after this patch a make dev-install is needed). Keyword case correction is not just capitalizing the first letter ( eg. Elseif -> ElseIf ).
Autoclose procedures:
cursor is being placed inside the preocedure.
Change-Id: Ie7e9ae96b49bd94562db83f96e1c4ad63ab3f3d6
Diffstat (limited to 'basctl/source/basicide/baside2b.cxx')
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 49f9058ad883..c0c404645cf9 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -530,8 +530,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) HandleProcedureCompletition(); } - if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && - (CodeCompleteOptions::IsCodeCompleteOn() || CodeCompleteOptions::IsExtendedTypeDeclaration()) ) + if( rKEvt.GetKeyCode().GetCode() == KEY_POINT && CodeCompleteOptions::IsCodeCompleteOn() ) { HandleCodeCompletition(); } @@ -596,9 +595,13 @@ void EditorWindow::HandleAutoCorrect() OUString sStr = aLine.copy(r.nBegin, r.nEnd - r.nBegin); if( !sStr.isEmpty() ) { - //capitalize first letter and replace sStr = sStr.toAsciiLowerCase(); - sStr = sStr.replaceAt( 0, 1, OUString(sStr[0]).toAsciiUpperCase() ); + if( !rModulWindow.GetSbModule()->GetKeywordCase(sStr).isEmpty() ) + // if it is a keyword, get its correct case + sStr = rModulWindow.GetSbModule()->GetKeywordCase(sStr); + else + // else capitalize first letter/select the correct one, and replace + sStr = sStr.replaceAt( 0, 1, OUString(sStr[0]).toAsciiUpperCase() ); TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() ); TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex())); @@ -684,13 +687,17 @@ void EditorWindow::HandleProcedureCompletition() return;// no sub/function keyword or there is no identifier OUString sText("\nEnd "); + aSel = GetEditView()->GetSelection(); if( sProcType.equalsIgnoreAsciiCase("function") ) sText += OUString( "Function\n" ); if( sProcType.equalsIgnoreAsciiCase("sub") ) sText += OUString( "Sub\n" ); if( nLine+1 == pEditEngine->GetParagraphCount() ) + { pEditView->InsertText( sText );//append to the end + GetEditView()->SetSelection(aSel); + } else { for( sal_uLong i = nLine+1; i < pEditEngine->GetParagraphCount(); ++i ) @@ -708,7 +715,8 @@ void EditorWindow::HandleProcedureCompletition() { if( sStr.equalsIgnoreAsciiCase("sub") || sStr.equalsIgnoreAsciiCase("function") ) { - pEditView->InsertText( sText ); + pEditView->InsertText( sText );//append to the end + GetEditView()->SetSelection(aSel); break; } if( sStr.equalsIgnoreAsciiCase("end") ) @@ -729,15 +737,16 @@ void EditorWindow::HandleCodeCompletition() std::vector< OUString > aVect; //vector to hold the base variable+methods for the nested reflection HighlightPortions aPortions; + aLine = aLine.copy(0, aSel.GetEnd().GetIndex()); aHighlighter.getHighlightPortions( nLine, aLine, aPortions ); if( aPortions.size() > 0 ) {//use the syntax highlighter to grab out nested reflection calls, eg. aVar.aMethod("aa").aOtherMethod .. - for( auto aIt = aPortions.crbegin(); aIt != aPortions.crend(); ++aIt ) + for( HighlightPortions::reverse_iterator aIt = aPortions.rbegin(); aIt != aPortions.rend(); ++aIt ) { HighlightPortion r = *aIt; - if( r.tokenType == 2 ) // a whitespace: stop; if there is no ws, it goes to the beginning of the line + if( r.tokenType == TT_WHITESPACE ) // a whitespace: stop; if there is no ws, it goes to the beginning of the line break; - if( r.tokenType == 1 || r.tokenType == 9 ) // extract the identifers(methods, base variable) + if( r.tokenType == TT_IDENTIFIER || r.tokenType == TT_KEYWORDS ) // extract the identifers(methods, base variable) /* an example: Dim aLocVar2 as com.sun.star.beans.PropertyValue * here, aLocVar2.Name, and PropertyValue's Name field is treated as a keyword(?!) * */ @@ -2603,19 +2612,43 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt ) case KEY_ESCAPE: // hide, do nothing HideAndRestoreFocus(); break; + case KEY_RIGHT: + { + TextSelection aTextSelection( GetParentEditView()->GetSelection() ); + if( aTextSelection.GetEnd().GetPara() != pCodeCompleteWindow->GetTextSelection().GetEnd().GetPara() ) + { + HideAndRestoreFocus(); + } + break; + } + case KEY_LEFT: + { + TextSelection aTextSelection( GetParentEditView()->GetSelection() ); + if( aTextSelection.GetStart().GetIndex()-1 < pCodeCompleteWindow->GetTextSelection().GetStart().GetIndex() ) + {//leave the cursor where it is + pCodeCompleteWindow->Hide(); + pCodeCompleteWindow->pParent->GrabFocus(); + } + break; + } case KEY_TAB: + { + TextPaM aTextEnd( GetParentEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetEnd()) ); + TextSelection aTextSelection( pCodeCompleteWindow->GetTextSelection().GetStart(), aTextEnd ); + OUString sTypedText = pCodeCompleteWindow->pParent->GetEditEngine()->GetText(aTextSelection); if( !aFuncBuffer.isEmpty() ) { sal_uInt16 nInd = GetSelectEntryPos(); - if( nInd+1 != LISTBOX_ENTRY_NOTFOUND ) + if( nInd != LISTBOX_ENTRY_NOTFOUND ) {//if there is something selected bool bFound = false; if( nInd == GetEntryCount() ) nInd = 0; - for( sal_uInt16 i = nInd+1; i != GetEntryCount(); ++i ) + for( sal_uInt16 i = nInd; i != GetEntryCount(); ++i ) { OUString sEntry = (OUString) GetEntry(i); - if( sEntry.startsWithIgnoreAsciiCase( aFuncBuffer.toString() ) ) + if( sEntry.startsWithIgnoreAsciiCase( aFuncBuffer.toString() ) + && (aFuncBuffer.toString() != sTypedText) && (i != nInd) ) { SelectEntry( sEntry ); bFound = true; @@ -2632,6 +2665,7 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt ) } } break; + } case KEY_SPACE: HideAndRestoreFocus(); break; |