summaryrefslogtreecommitdiffstats
path: root/basctl
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-26 13:57:29 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-09-02 18:16:50 +0200
commit412e91d33dfc392f15858614369f956e531785b9 (patch)
tree29e016ad704aa6e3288963f4a6792dde137859aa /basctl
parentGSOC work, fix runtime crash (diff)
downloadcore-412e91d33dfc392f15858614369f956e531785b9.tar.gz
core-412e91d33dfc392f15858614369f956e531785b9.zip
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
Diffstat (limited to 'basctl')
-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
4 files changed, 21 insertions, 6 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 7578f85241b2..d39f06139a8e 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -522,6 +522,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>