summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-26 13:57:29 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-07-26 13:57:29 +0200
commit59418489effa864fddba8ba5432e066e1c089976 (patch)
tree8662c2296de3c04e011518f9aee6759d5f004bef
parente9d2993bd7a5e5dd354b2d6e8f1ac7d5fc9c7a33 (diff)
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
-rw-r--r--basctl/source/basicide/baside2b.cxx15
-rw-r--r--basctl/source/basicide/codecompleteoptionsdlg.cxx6
-rw-r--r--basctl/source/basicide/codecompleteoptionsdlg.hxx2
-rw-r--r--basctl/uiconfig/basicide/ui/codecompleteoptionsdlg.ui4
-rw-r--r--basic/source/classes/codecompletecache.cxx13
-rw-r--r--include/basic/codecompletecache.hxx4
6 files changed, 37 insertions, 7 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index c533ebcf575a..0cb09c0bbfcf 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 ac2793f767e4..ff4398b1e816 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 9549b99a09f3..2154c8a00347 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 83256b52ebae..1c0d86ccb2df 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 3e327c65ff7c..728dcb4a1d81 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 7280030e39dc..520629926681 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