summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-25 20:15:45 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-09-02 18:16:49 +0200
commit40433e2ca977173ae6909fc5c47601e11ef003e4 (patch)
tree132896643e277be1d0ba14f8aaa7f7971c293a90 /basctl
parent9a7b942a0a3bb113cf356f2642766f7a9f909bd6 (diff)
GSOC work, implemented "Autoclose Double Quotes" option
Feature autoclosing double quotes (strings) implemented. When the user presses the '"' key, it's pair is also being inserted (only when the previous character is also a '"'), and the cursor is being placed inside the two quotes. Also, if the there was a string (like: "aaa""), the second one is not inserted. Change-Id: I3e4a5e426d2d4bdbf56899fe3e36359ae161b52a
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2b.cxx19
-rw-r--r--basctl/source/basicide/codecompleteoptionsdlg.cxx3
2 files changed, 20 insertions, 2 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index a6acaea0f1ea..cf2530f6e47d 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -505,10 +505,27 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
// see if there is an accelerator to be processed first
bool bDone = SfxViewShell::Current()->KeyInput( rKEvt );
+ if( rKEvt.GetCharCode() == '"' && CodeCompleteOptions::IsAutoCloseQuotesOn() )
+ {//autoclose double quotes
+ TextSelection aSel = GetEditView()->GetSelection();
+ sal_uLong nLine = aSel.GetStart().GetPara();
+ OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified
+
+ HighlightPortions aPortions;
+ aHighlighter.getHighlightPortions( nLine, aLine, aPortions );
+ if( aLine[aLine.getLength()-1] != '"' && (aPortions[aPortions.size()-1].tokenType != 4) )
+ {
+ GetEditView()->InsertText(OUString("\""));
+ //leave the cursor on it's place: inside the two double quotes
+ 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();
- sal_uLong nLine = aSel.GetStart().GetPara();
+ sal_uLong nLine = aSel.GetStart().GetPara();
OUString sActSub = GetActualSubName( nLine );
IncompleteProcedures aProcData = rModulWindow.GetSbModule()->GetIncompleteProcedures();
for( unsigned int i = 0; i < aProcData.size(); ++i )
diff --git a/basctl/source/basicide/codecompleteoptionsdlg.cxx b/basctl/source/basicide/codecompleteoptionsdlg.cxx
index 0f4ab3a8cac8..ac2793f767e4 100644
--- a/basctl/source/basicide/codecompleteoptionsdlg.cxx
+++ b/basctl/source/basicide/codecompleteoptionsdlg.cxx
@@ -42,9 +42,9 @@ CodeCompleteOptionsDlg::CodeCompleteOptionsDlg( Window* pWindow )
pCodeCompleteChk->Check( CodeCompleteOptions::IsCodeCompleteOn() );
pAutocloseProcChk->Check( CodeCompleteOptions::IsProcedureAutoCompleteOn() );
+ pAutocloseQuotesChk->Check( CodeCompleteOptions::IsAutoCloseQuotesOn() );
pAutocloseBracesChk->Enable( false );
- pAutocloseQuotesChk->Enable( false );
}
CodeCompleteOptionsDlg::~CodeCompleteOptionsDlg()
@@ -55,6 +55,7 @@ IMPL_LINK_NOARG(CodeCompleteOptionsDlg, OkHdl)
{
CodeCompleteOptions::SetCodeCompleteOn( pCodeCompleteChk->IsChecked() );
CodeCompleteOptions::SetProcedureAutoCompleteOn( pAutocloseProcChk->IsChecked() );
+ CodeCompleteOptions::SetAutoCloseQuotesOn( pAutocloseQuotesChk->IsChecked() );
Close();
return 0;
}