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

Gergo Mocsi gmocsi91 at gmail.com
Fri Jul 26 05:05:33 PDT 2013


 basctl/source/basicide/baside2b.cxx                   |   15 +++++++++++++++
 basctl/source/basicide/codecompleteoptionsdlg.cxx     |    6 +++---
 basctl/source/basicide/codecompleteoptionsdlg.hxx     |    2 +-
 basctl/uiconfig/basicide/ui/codecompleteoptionsdlg.ui |    4 ++--
 basic/source/classes/codecompletecache.cxx            |   13 ++++++++++++-
 include/basic/codecompletecache.hxx                   |    4 ++++
 6 files changed, 37 insertions(+), 7 deletions(-)

New commits:
commit 59418489effa864fddba8ba5432e066e1c089976
Author: Gergo Mocsi <gmocsi91 at gmail.com>
Date:   Fri Jul 26 13:57:29 2013 +0200

    GSOC work, implement "Autoclose parenthesis" function
    
    Autoclosing parenthesis function is working. Implementation is similar to autoclosing double quotes, except that this one does not need the HighlighPortion struct to use.
    Renamed the checkbox title to "Autoclose parenthesis".
    
    Change-Id: I4311cd8020f0dc0b62a2d8707e0eccbf57e0d2c2

diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index c533ebc..0cb09c0 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -516,6 +516,21 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
         }
     }
 
+    if( rKEvt.GetCharCode() == '(' && CodeCompleteOptions::IsAutoCloseParenthesisOn() )
+    {//autoclose parenthesis
+        TextSelection aSel = GetEditView()->GetSelection();
+        sal_uLong nLine =  aSel.GetStart().GetPara();
+        OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified
+
+        if( aLine.getLength() > 0 && aLine[aSel.GetEnd().GetIndex()-1] != '(' )
+        {
+            GetEditView()->InsertText(OUString(")"));
+            //leave the cursor on it's place: inside the parenthesis
+            TextPaM aEnd(nLine, aSel.GetEnd().GetIndex());
+            GetEditView()->SetSelection( TextSelection( aEnd, aEnd ) );
+        }
+    }
+
     if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN && CodeCompleteOptions::IsProcedureAutoCompleteOn() )
     {//autoclose implementation
         TextSelection aSel = GetEditView()->GetSelection();
diff --git a/basctl/source/basicide/codecompleteoptionsdlg.cxx b/basctl/source/basicide/codecompleteoptionsdlg.cxx
index ac2793f..ff4398b 100644
--- a/basctl/source/basicide/codecompleteoptionsdlg.cxx
+++ b/basctl/source/basicide/codecompleteoptionsdlg.cxx
@@ -34,7 +34,7 @@ CodeCompleteOptionsDlg::CodeCompleteOptionsDlg( Window* pWindow )
 
     get(pCodeCompleteChk, "codecomplete_enable");
     get(pAutocloseProcChk, "autoclose_proc");
-    get(pAutocloseBracesChk, "autoclose_braces");
+    get(pAutocloseParenChk, "autoclose_paren");
     get(pAutocloseQuotesChk, "autoclose_quotes");
 
     pOkBtn->SetClickHdl( LINK( this, CodeCompleteOptionsDlg, OkHdl ) );
@@ -43,8 +43,7 @@ CodeCompleteOptionsDlg::CodeCompleteOptionsDlg( Window* pWindow )
     pCodeCompleteChk->Check( CodeCompleteOptions::IsCodeCompleteOn() );
     pAutocloseProcChk->Check( CodeCompleteOptions::IsProcedureAutoCompleteOn() );
     pAutocloseQuotesChk->Check( CodeCompleteOptions::IsAutoCloseQuotesOn() );
-
-    pAutocloseBracesChk->Enable( false );
+    pAutocloseParenChk->Check( CodeCompleteOptions::IsAutoCloseParenthesisOn() );
 }
 
 CodeCompleteOptionsDlg::~CodeCompleteOptionsDlg()
@@ -56,6 +55,7 @@ IMPL_LINK_NOARG(CodeCompleteOptionsDlg, OkHdl)
     CodeCompleteOptions::SetCodeCompleteOn( pCodeCompleteChk->IsChecked() );
     CodeCompleteOptions::SetProcedureAutoCompleteOn( pAutocloseProcChk->IsChecked() );
     CodeCompleteOptions::SetAutoCloseQuotesOn( pAutocloseQuotesChk->IsChecked() );
+    CodeCompleteOptions::SetAutoCloseParenthesisOn( pAutocloseParenChk->IsChecked() );
     Close();
     return 0;
 }
diff --git a/basctl/source/basicide/codecompleteoptionsdlg.hxx b/basctl/source/basicide/codecompleteoptionsdlg.hxx
index 9549b99..2154c8a 100644
--- a/basctl/source/basicide/codecompleteoptionsdlg.hxx
+++ b/basctl/source/basicide/codecompleteoptionsdlg.hxx
@@ -34,7 +34,7 @@ private:
 
     CheckBox* pCodeCompleteChk;
     CheckBox* pAutocloseProcChk;
-    CheckBox* pAutocloseBracesChk;
+    CheckBox* pAutocloseParenChk;
     CheckBox* pAutocloseQuotesChk;
 
     DECL_LINK(OkHdl, void*);
diff --git a/basctl/uiconfig/basicide/ui/codecompleteoptionsdlg.ui b/basctl/uiconfig/basicide/ui/codecompleteoptionsdlg.ui
index 83256b5..1c0d86c 100644
--- a/basctl/uiconfig/basicide/ui/codecompleteoptionsdlg.ui
+++ b/basctl/uiconfig/basicide/ui/codecompleteoptionsdlg.ui
@@ -145,8 +145,8 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkCheckButton" id="autoclose_braces">
-                            <property name="label" translatable="yes">Autoclose Braces</property>
+                          <object class="GtkCheckButton" id="autoclose_paren">
+                            <property name="label" translatable="yes">Autoclose Parenthesis</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">False</property>
diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx
index 3e327c6..728dcb4 100644
--- a/basic/source/classes/codecompletecache.cxx
+++ b/basic/source/classes/codecompletecache.cxx
@@ -29,7 +29,8 @@ namespace
 CodeCompleteOptions::CodeCompleteOptions()
 : bIsCodeCompleteOn( false ),
 bIsProcedureAutoCompleteOn( false ),
-bIsAutoCloseQuotesOn( false )
+bIsAutoCloseQuotesOn( false ),
+bIsAutoCloseParenthesisOn( false )
 {
 }
 
@@ -68,6 +69,16 @@ void CodeCompleteOptions::SetAutoCloseQuotesOn( const bool& b )
     theCodeCompleteOptions::get().bIsAutoCloseQuotesOn = b;
 }
 
+bool CodeCompleteOptions::IsAutoCloseParenthesisOn()
+{
+    return theCodeCompleteOptions::get().aMiscOptions.IsExperimentalMode() && theCodeCompleteOptions::get().bIsAutoCloseParenthesisOn;
+}
+
+void CodeCompleteOptions::SetAutoCloseParenthesisOn( const bool& b )
+{
+    theCodeCompleteOptions::get().bIsAutoCloseParenthesisOn = b;
+}
+
 std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache)
 {
     aStream << "Global variables" << std::endl;
diff --git a/include/basic/codecompletecache.hxx b/include/basic/codecompletecache.hxx
index 7280030..5206299 100644
--- a/include/basic/codecompletecache.hxx
+++ b/include/basic/codecompletecache.hxx
@@ -58,6 +58,7 @@ private:
     bool bIsCodeCompleteOn;
     bool bIsProcedureAutoCompleteOn;
     bool bIsAutoCloseQuotesOn;
+    bool bIsAutoCloseParenthesisOn;
     SvtMiscOptions aMiscOptions;
 
 public:
@@ -72,6 +73,9 @@ public:
 
     static bool IsAutoCloseQuotesOn();
     static void SetAutoCloseQuotesOn( const bool& b );
+
+    static bool IsAutoCloseParenthesisOn();
+    static void SetAutoCloseParenthesisOn( const bool& b );
 };
 
 class BASIC_DLLPUBLIC CodeCompleteDataCache


More information about the Libreoffice-commits mailing list