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

Gergo Mocsi gmocsi91 at gmail.com
Fri Aug 2 03:40:52 PDT 2013


 basctl/source/basicide/baside2.hxx  |    8 +++
 basctl/source/basicide/baside2b.cxx |   73 ++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+)

New commits:
commit 287b5c42b7fcf035a0a52c241c0a5f53c151ea4e
Author: Gergo Mocsi <gmocsi91 at gmail.com>
Date:   Fri Aug 2 12:32:13 2013 +0200

    GSOC work, show the cursor when typing 2
    
    There are two cases:
    a) TextView in focus: cursor is visible, typing works, except the arrow keys are not working for the ListBox
    b) ListBox in focus: no cursor, everything works
    
    Change-Id: Iaaec69c04370e4d05e226abeecd420bf4d4f52cd

diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 42904b2..5618f76 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -76,6 +76,7 @@ void setTextEngineText (ExtTextEngine&, OUString const&);
 
 class EditorWindow : public Window, public SfxListener
 {
+friend class CodeCompleteListBox;
 private:
     class ChangesListener;
 
@@ -475,6 +476,7 @@ private:
 class CodeCompleteListBox: public ListBox
 {
 friend class CodeCompleteWindow;
+friend class EditorWindow;
 private:
     OUStringBuffer aFuncBuffer;
     /* a buffer to build up function name when typing
@@ -489,9 +491,12 @@ public:
     void InsertSelectedEntry(); //insert the selected entry
 
     DECL_LINK(ImplDoubleClickHdl, void*);
+    //DECL_LINK(ImplSelectionChangeHdl, void*);
 
     virtual long PreNotify( NotifyEvent& rNEvt );
 
+protected:
+    virtual void KeyInput( const KeyEvent& rKeyEvt );
 };
 
 class CodeCompleteWindow: public Window
@@ -519,6 +524,9 @@ public:
      * clears if typed anything, then hides
      * the window, clear internal variables
      * */
+    OUStringBuffer& GetListBoxBuffer();
+    void SetVisibleEntries(); // sets the visible entries based on aFuncBuffer variable
+    CodeCompleteListBox* GetListBox(){return pListBox;}
 
 };
 
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index a18e475..fe9da85 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -502,6 +502,13 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
     // see if there is an accelerator to be processed first
     bool bDone = SfxViewShell::Current()->KeyInput( rKEvt );
 
+    //sal_Unicode aChar = rKEvt.GetKeyCode().GetCode();
+    if( pCodeCompleteWnd->IsVisible() )
+    {
+        std::cerr << "EditorWindow::KeyInput" << std::endl;
+        pCodeCompleteWnd->GetListBox()->KeyInput(rKEvt);
+    }
+
     if( (rKEvt.GetKeyCode().GetCode() == KEY_SPACE ||
         rKEvt.GetKeyCode().GetCode() == KEY_TAB ||
         rKEvt.GetKeyCode().GetCode() == KEY_RETURN ) && CodeCompleteOptions::IsAutoCorrectKeywordsOn() )
@@ -757,6 +764,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
                             pCodeCompleteWnd->ResizeListBox();
                             pCodeCompleteWnd->SelectFirstEntry();
                             pEditView->GetWindow()->GrabFocus();
+                            //pEditView->EnableCursor( true );
                         }
                     }
                 }
@@ -2538,6 +2546,7 @@ CodeCompleteListBox::CodeCompleteListBox( CodeCompleteWindow* pPar )
 pCodeCompleteWindow( pPar )
 {
     SetDoubleClickHdl(LINK(this, CodeCompleteListBox, ImplDoubleClickHdl));
+    //SetSelectHdl(LINK(this, CodeCompleteListBox, ImplSelectionChangeHdl));
 }
 
 IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl)
@@ -2546,6 +2555,12 @@ IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl)
     return 0;
 }
 
+/*IMPL_LINK_NOARG(CodeCompleteListBox, ImplSelectionChangeHdl)
+{
+    pCodeCompleteWindow->pParent->GrabFocus();
+    return 0;
+}*/
+
 void CodeCompleteListBox::InsertSelectedEntry()
 {
     if( !aFuncBuffer.toString().isEmpty() )
@@ -2586,6 +2601,7 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
 {
     if( rNEvt.GetType() == EVENT_KEYINPUT )
     {
+        std::cerr << "CodeCompleteListBox::PreNotify" << std::endl;
         KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
         sal_Unicode aChar = aKeyEvt.GetKeyCode().GetCode();
         if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) )
@@ -2593,6 +2609,7 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
             pCodeCompleteWindow->pParent->GetEditView()->InsertText( OUString(aKeyEvt.GetCharCode()) );
             aFuncBuffer.append(aKeyEvt.GetCharCode());
             SetVisibleEntries();
+            //pCodeCompleteWindow->pParent->GetEditView()->GetWindow()->GrabFocus();
             return 0;
         }
         else
@@ -2629,9 +2646,13 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
                 case KEY_RETURN:
                     InsertSelectedEntry();
                     return 0;
+                /*case KEY_UP: case KEY_DOWN:
+                std::cerr << "up/down ke in PreNotify" << std::endl;
+                break;*/
             }
         }
     }
+    //pCodeCompleteWindow->pParent->GrabFocus();
     return ListBox::PreNotify( rNEvt );
 }
 
@@ -2648,6 +2669,48 @@ void CodeCompleteListBox::SetVisibleEntries()
     }
 }
 
+void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
+{
+    std::cerr << "CodeCompleteListBox::KeyInput" << std::endl;
+    //pCodeCompleteWindow->pParent->GetEditView()->KeyInput( rKeyEvt );
+    sal_Unicode aChar = rKeyEvt.GetKeyCode().GetCode();
+    if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) )
+    {
+        //pCodeCompleteWindow->pParent->GetEditView()->InsertText( OUString(rKeyEvt.GetCharCode()) );
+        aFuncBuffer.append(rKeyEvt.GetCharCode());
+        SetVisibleEntries();
+    }
+    else
+    {
+        switch( aChar )
+        {
+            case KEY_ESCAPE: // hide, do nothing
+                pCodeCompleteWindow->ClearAndHide();
+                break;
+            case KEY_TAB: case KEY_SPACE:
+                pCodeCompleteWindow->Hide();
+                pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
+                pCodeCompleteWindow->pParent->GrabFocus();
+                break;
+            case KEY_BACKSPACE: case KEY_DELETE:
+                if( aFuncBuffer.toString() != OUString("") )
+                {
+                    aFuncBuffer = aFuncBuffer.remove(aFuncBuffer.getLength()-1, 1);
+                    SetVisibleEntries();
+                }
+                else
+                {
+                    pCodeCompleteWindow->ClearAndHide();
+                }
+                break;
+            case KEY_RETURN:
+                InsertSelectedEntry();
+                break;
+        }
+    }
+    ListBox::KeyInput(rKeyEvt);
+}
+
 CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar )
 : Window( pPar ),
 pParent( pPar ),
@@ -2657,6 +2720,11 @@ pListBox( new CodeCompleteListBox(this) )
     InitListBox();
 }
 
+OUStringBuffer& CodeCompleteWindow::GetListBoxBuffer()
+{
+    return pListBox->aFuncBuffer;
+}
+
 void CodeCompleteWindow::InitListBox()
 {
     pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length
@@ -2748,6 +2816,11 @@ void CodeCompleteWindow::ClearAndHide()
     pParent->GrabFocus();
 }
 
+void CodeCompleteWindow::SetVisibleEntries()
+{
+    pListBox->SetVisibleEntries();
+}
+
 } // namespace basctl
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list