[Libreoffice-commits] core.git: Branch 'feature/gsoc-basic-ide-completion-and-other-bits' - basctl/source

Gergo Mocsi gmocsi91 at gmail.com
Sun Jul 21 10:46:52 PDT 2013


 basctl/source/basicide/baside2.hxx  |    5 +++++
 basctl/source/basicide/baside2b.cxx |   34 +++++++++++++++++++++++++++-------
 2 files changed, 32 insertions(+), 7 deletions(-)

New commits:
commit 5692833cb94cbfe8a456007d8674f87c24c4efa0
Author: Gergo Mocsi <gmocsi91 at gmail.com>
Date:   Sun Jul 21 19:36:56 2013 +0200

    GSOC work window hide when clicking out
    
    CodeCompleteWindow is hidden when clicking out: thi is implemented in
    EditorWindow::MouseButtonDown: if CodeCompleteWindow is visible and
    the actual TextSelection of the window and the parent's TextView is
    different, hide the window (I assume the user changed selection, eg.
    clicked on other line, etc.).
    
    Change-Id: Icb6bcffa837b2f7e1ccef288b9d762e27649410b

diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index eaf700b..8737091 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -518,6 +518,11 @@ public:
     const TextSelection& GetTextSelection() const;
     void ResizeListBox();
     void SelectFirstEntry(); //selects first entry in ListBox
+    void ClearAndHide();
+    /*
+     * clears if typed anything, then hides
+     * the window, clear internal variables
+     * */
 
 };
 
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index c21be94..bfa8285 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -443,6 +443,13 @@ void EditorWindow::MouseButtonDown( const MouseEvent &rEvt )
     GrabFocus();
     if ( pEditView )
         pEditView->MouseButtonDown( rEvt );
+    if( pCodeCompleteWnd->IsVisible() )
+    {
+        if( pEditView->GetSelection() != pCodeCompleteWnd->GetTextSelection() )
+        {//selection changed, code complete window should be hidden
+            pCodeCompleteWnd->ClearAndHide();
+        }
+    }
 }
 
 void EditorWindow::Command( const CommandEvent& rCEvt )
@@ -2367,8 +2374,8 @@ void CodeCompleteListBox::InsertSelectedEntry()
     if( aFuncBuffer.toString() != OUString("") )
     {
         // if the user typed in something: remove, and insert
-        TextPaM aEnd(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->aTextSelection.GetEnd().GetIndex() + aFuncBuffer.getLength());
-        TextPaM aStart(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->aTextSelection.GetEnd().GetIndex() );
+        TextPaM aEnd(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->GetTextSelection().GetEnd().GetIndex() + aFuncBuffer.getLength());
+        TextPaM aStart(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->GetTextSelection().GetEnd().GetIndex() );
         pCodeCompleteWindow->pParent->GetEditView()->SetSelection(TextSelection(aStart, aEnd));
         pCodeCompleteWindow->pParent->GetEditView()->DeleteSelected();
 
@@ -2416,9 +2423,10 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
             switch( aChar )
             {
                 case KEY_ESCAPE: // hide, do nothing
-                    pCodeCompleteWindow->Hide();
+                    pCodeCompleteWindow->ClearAndHide();
+                    /*pCodeCompleteWindow->Hide();
                     pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
-                    //pCodeCompleteWindow->pParent->GrabFocus();
+                    //pCodeCompleteWindow->pParent->GrabFocus();*/
                     return 0;
                 case KEY_TAB: case KEY_SPACE:
                 /* space, tab the user probably have typed in the whole
@@ -2432,8 +2440,8 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
                 case KEY_BACKSPACE: case KEY_DELETE:
                     if( aFuncBuffer.toString() != OUString("") )
                     {
-                        TextPaM aEnd(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->aTextSelection.GetEnd().GetIndex() + aFuncBuffer.getLength());
-                        TextPaM aStart(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->aTextSelection.GetEnd().GetIndex() + aFuncBuffer.getLength()-1);
+                        TextPaM aEnd(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->GetTextSelection().GetEnd().GetIndex() + aFuncBuffer.getLength());
+                        TextPaM aStart(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->GetTextSelection().GetEnd().GetIndex() + aFuncBuffer.getLength()-1);
                         aFuncBuffer.stripEnd(aFuncBuffer[aFuncBuffer.getLength()-1]);
                         pCodeCompleteWindow->pParent->GetEditView()->SetSelection(TextSelection(aStart, aEnd));
                         pCodeCompleteWindow->pParent->GetEditView()->DeleteSelected();
@@ -2515,12 +2523,13 @@ void CodeCompleteWindow::ResizeListBox()
         const Font& aFont = pListBox->GetUnzoomedControlPointFont();
 
         aSize.setHeight( aFont.GetSize().getHeight() * 16 );
-        aSize.setWidth( pListBox->CalcSize(aLongestEntry.getLength(),pListBox->GetEntryCount()).getWidth() );
+        aSize.setWidth( pListBox->CalcSize(aLongestEntry.getLength(), pListBox->GetEntryCount()).getWidth() );
 
         pListBox->SetSizePixel( aSize );
         aSize.setWidth( aSize.getWidth() + 1 );
         aSize.setHeight( aSize.getHeight() + 1 );
         SetSizePixel( aSize );
+        pListBox->GrabFocus();
     }
 }
 
@@ -2532,6 +2541,17 @@ void CodeCompleteWindow::SelectFirstEntry()
     }
 }
 
+void CodeCompleteWindow::ClearAndHide()
+{
+    TextPaM aEnd(aTextSelection.GetEnd().GetPara(), GetTextSelection().GetEnd().GetIndex() + pListBox->aFuncBuffer.getLength());
+    TextPaM aStart(aTextSelection.GetEnd().GetPara(), GetTextSelection().GetEnd().GetIndex() );
+    pParent->GetEditView()->SetSelection(TextSelection(aStart, aEnd));
+    pParent->GetEditView()->DeleteSelected();
+    Hide();
+    ClearListBox();
+    pParent->GrabFocus();
+}
+
 } // namespace basctl
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list