From 412e91d33dfc392f15858614369f956e531785b9 Mon Sep 17 00:00:00 2001 From: Gergo Mocsi Date: Fri, 26 Jul 2013 13:57:29 +0200 Subject: 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 --- 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 ++-- 4 files changed, 21 insertions(+), 6 deletions(-) (limited to 'basctl') 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 @@ - - Autoclose Braces + + Autoclose Parenthesis True True False -- cgit