summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2.hxx7
-rw-r--r--basctl/source/basicide/baside2b.cxx54
2 files changed, 29 insertions, 32 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index c0d93aa2db16..51a130cdac18 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -116,9 +116,7 @@ private:
GetComponentInterface(sal_Bool bCreate = true);
std::vector< CodeCompleteData > aCodeCompleteCache;
CodeCompleteWindow* pCodeCompleteWnd;
- //CodeCompleteListBox* aListBox;
OUString GetActualSubName( sal_uLong nLine ); // gets the actual subroutine name according to line number
- std::vector< OUString > Split( const OUString& sStr, const sal_Unicode& aChar );
protected:
virtual void Paint( const Rectangle& );
@@ -482,7 +480,6 @@ private:
CodeCompleteListBox* pListBox;
void InitListBox(); // initialize the ListBox
- //DECL_LINK(ImplDoubleClickHdl, void*);
public:
CodeCompleteWindow( EditorWindow* pPar );
@@ -493,6 +490,7 @@ public:
void SetTextSelection( const TextSelection& aSel );
const TextSelection& GetTextSelection() const;
void ResizeListBox();
+ void SelectFirstEntry(); //selects first entry in ListBox
protected:
virtual void KeyInput( const KeyEvent& rKeyEvt );
@@ -506,7 +504,8 @@ private:
public:
CodeCompleteListBox(CodeCompleteWindow* pPar);
virtual ~CodeCompleteListBox();
- //DECL_LINK(ImplSelectHdl, void*);
+ void InsertSelectedEntry(); //insert the selected entry
+
DECL_LINK(ImplDoubleClickHdl, void*);
virtual long PreNotify( NotifyEvent& rNEvt );
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 847dd41b1958..79b42f7dea28 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -275,7 +275,6 @@ EditorWindow::~EditorWindow()
pEditEngine->RemoveView(pEditView.get());
}
- //delete aListBox;
delete pCodeCompleteWnd;
}
@@ -438,8 +437,8 @@ void EditorWindow::MouseButtonUp( const MouseEvent &rEvt )
pEditView->MouseButtonUp( rEvt );
if (SfxBindings* pBindings = GetBindingsPtr())
{
- pBindings->Invalidate( SID_COPY );
- pBindings->Invalidate( SID_CUT );
+ /*pBindings->Invalidate( SID_COPY );
+ pBindings->Invalidate( SID_CUT );*/
pBindings->Invalidate( SID_BASICIDE_STAT_POS );
}
}
@@ -490,25 +489,6 @@ bool EditorWindow::ImpCanModify()
return bCanModify;
}
-std::vector< OUString > EditorWindow::Split( const OUString& sStr, const sal_Unicode& aChar )
-{
- std::vector< OUString > aRet;
- OUString sTmp;
- for( sal_Int32 i = 0; i < sStr.getLength(); ++i )
- {
- if( sStr[i] != aChar)
- sTmp += OUString(sStr[i]);
- else
- {
- aRet.push_back(sTmp);
- sTmp = OUString("");
- }
- }
- if(sTmp != OUString(""))
- aRet.push_back(sTmp);
- return aRet;
-}
-
void EditorWindow::KeyInput( const KeyEvent& rKEvt )
{
SvtMiscOptions aMiscOptions;
@@ -534,7 +514,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified
OUString aStr = aLine.copy( std::max(aLine.lastIndexOf(" "), aLine.lastIndexOf("\t"))+1 ); // variable name
OUString sActSub = GetActualSubName( nLine );
- std::vector< OUString > aVect; //= Split( aStr, '.' );
+ std::vector< OUString > aVect;
HighlightPortions aPortions;
aHighlighter.getHighlightPortions( nLine, aLine, aPortions );
@@ -595,7 +575,8 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
}
pCodeCompleteWnd->ResizeListBox();
pCodeCompleteWnd->Show();
- pCodeCompleteWnd->GrabFocus();
+ //pCodeCompleteWnd->GrabFocus();
+ pCodeCompleteWnd->SelectFirstEntry();
}
}
}
@@ -2399,6 +2380,12 @@ CodeCompleteListBox::~CodeCompleteListBox()
IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl)
{
+ InsertSelectedEntry();
+ return 0;
+}
+
+void CodeCompleteListBox::InsertSelectedEntry()
+{
if( GetEntry( GetSelectEntryPos() ) != OUString("") )
{
pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->GetTextSelection() );
@@ -2407,7 +2394,6 @@ IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl)
pCodeCompleteWindow->LoseFocus();
pCodeCompleteWindow->Hide();
}
- return 0;
}
long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
@@ -2419,12 +2405,15 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
{
case KEY_ESCAPE:
pCodeCompleteWindow->pParent->GetEditView()->EnableCursor( true );
+ pCodeCompleteWindow->LoseFocus();
pCodeCompleteWindow->Hide();
return 0;
- default:
- return ListBox::PreNotify( rNEvt );
+ case KEY_RETURN:
+ InsertSelectedEntry();
+ return 0;
}
}
+ return ListBox::PreNotify( rNEvt );
}
CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar )
@@ -2432,7 +2421,7 @@ CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar )
pParent(pPar)
{
InitListBox();
- SetSizePixel( Size(150,150) );
+ SetSizePixel( Size(150,150) ); //default, later it changes
}
void CodeCompleteWindow::InitListBox()
@@ -2500,6 +2489,15 @@ void CodeCompleteWindow::ResizeListBox()
}
}
+void CodeCompleteWindow::SelectFirstEntry()
+{
+ if( pListBox->GetEntryCount() > 0 )
+ {
+ pListBox->SelectEntryPos( 0 );
+ pListBox->GrabFocus();
+ }
+}
+
} // namespace basctl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */