Kaydet (Commit) d8a9c74f authored tarafından Laurent Godard's avatar Laurent Godard Kaydeden (comit) Caolán McNamara

BASIC IDE : add the current procedure name in the status bar

Change-Id: Icecef1748bcc964670b0b95263314d9d8a4555f0
Reviewed-on: https://gerrit.libreoffice.org/14367Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 0ed14401
...@@ -1118,6 +1118,35 @@ void ModulWindow::GetState( SfxItemSet &rSet ) ...@@ -1118,6 +1118,35 @@ void ModulWindow::GetState( SfxItemSet &rSet )
} }
} }
break; break;
case SID_BASICIDE_STAT_TITLE:
{
// search for current procedure name (Sub or Function)
TextView* pView = GetEditView();
if ( pView )
{
OUString sProcName;
bool bFound = false;
TextSelection aSel = pView->GetSelection();
long nLine = aSel.GetStart().GetPara();
for (long i = nLine; i >= 0 && !bFound; --i)
{
OUString aCurrLine = GetEditEngine()->GetText( i );
OUString sProcType;
bFound = GetEditorWindow().GetProcedureName(aCurrLine, sProcType, sProcName);
}
OUString aTitle = CreateQualifiedName();
if (!sProcName.isEmpty())
aTitle += "." + sProcName;
SfxStringItem aTitleItem( SID_BASICIDE_STAT_TITLE, aTitle );
rSet.Put( aTitleItem );
}
}
break;
case SID_ATTR_INSERT: case SID_ATTR_INSERT:
{ {
TextView* pView = GetEditView(); TextView* pView = GetEditView();
......
...@@ -156,6 +156,8 @@ public: ...@@ -156,6 +156,8 @@ public:
bool CanModify() { return ImpCanModify(); } bool CanModify() { return ImpCanModify(); }
void UpdateSyntaxHighlighting (); void UpdateSyntaxHighlighting ();
bool GetProcedureName(OUString& rLine, OUString& rProcType, OUString& rProcName);
}; };
......
...@@ -428,6 +428,7 @@ void EditorWindow::MouseButtonUp( const MouseEvent &rEvt ) ...@@ -428,6 +428,7 @@ void EditorWindow::MouseButtonUp( const MouseEvent &rEvt )
if (SfxBindings* pBindings = GetBindingsPtr()) if (SfxBindings* pBindings = GetBindingsPtr())
{ {
pBindings->Invalidate( SID_BASICIDE_STAT_POS ); pBindings->Invalidate( SID_BASICIDE_STAT_POS );
pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
} }
} }
} }
...@@ -567,8 +568,12 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt ) ...@@ -567,8 +568,12 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
if (SfxBindings* pBindings = GetBindingsPtr()) if (SfxBindings* pBindings = GetBindingsPtr())
{ {
pBindings->Invalidate( SID_BASICIDE_STAT_POS ); pBindings->Invalidate( SID_BASICIDE_STAT_POS );
pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR ) if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR )
{
pBindings->Update( SID_BASICIDE_STAT_POS ); pBindings->Update( SID_BASICIDE_STAT_POS );
pBindings->Update( SID_BASICIDE_STAT_TITLE );
}
if ( !bWasModified && pEditEngine->IsModified() ) if ( !bWasModified && pEditEngine->IsModified() )
{ {
pBindings->Invalidate( SID_SAVEDOC ); pBindings->Invalidate( SID_SAVEDOC );
...@@ -729,42 +734,19 @@ void EditorWindow::HandleAutoCloseDoubleQuotes() ...@@ -729,42 +734,19 @@ void EditorWindow::HandleAutoCloseDoubleQuotes()
void EditorWindow::HandleProcedureCompletion() void EditorWindow::HandleProcedureCompletion()
{ {
TextSelection aSel = GetEditView()->GetSelection(); TextSelection aSel = GetEditView()->GetSelection();
sal_uLong nLine = aSel.GetStart().GetPara(); sal_uLong nLine = aSel.GetStart().GetPara();
OUString aLine( pEditEngine->GetText( nLine ) ); OUString aLine( pEditEngine->GetText( nLine ) );
std::vector<HighlightPortion> aPortions; bool bFoundName = false;
aHighlighter.getHighlightPortions( aLine, aPortions );
if( aPortions.empty() )
return;
OUString sProcType; OUString sProcType;
OUString sProcName; OUString sProcName;
bool bFoundType = false;
bool bFoundName = false;
for (std::vector<HighlightPortion>::iterator i(aPortions.begin());
i != aPortions.end(); ++i)
{
OUString sTokStr = aLine.copy(i->nBegin, i->nEnd - i->nBegin);
if( i->tokenType == 9 && ( sTokStr.equalsIgnoreAsciiCase("sub") bFoundName = GetProcedureName(aLine, sProcType, sProcName);
|| sTokStr.equalsIgnoreAsciiCase("function")) )
{
sProcType = sTokStr;
bFoundType = true;
}
if( i->tokenType == 1 && bFoundType )
{
sProcName = sTokStr;
bFoundName = true;
break;
}
}
if( !bFoundType || !bFoundName ) if (!bFoundName)
return;// no sub/function keyword or there is no identifier return;
OUString sText("\nEnd "); OUString sText("\nEnd ");
aSel = GetEditView()->GetSelection(); aSel = GetEditView()->GetSelection();
...@@ -807,6 +789,43 @@ void EditorWindow::HandleProcedureCompletion() ...@@ -807,6 +789,43 @@ void EditorWindow::HandleProcedureCompletion()
} }
} }
bool EditorWindow::GetProcedureName(OUString& rLine, OUString& rProcType, OUString& rProcName)
{
std::vector<HighlightPortion> aPortions;
aHighlighter.getHighlightPortions(rLine, aPortions);
if( aPortions.empty() )
return false;
bool bFoundType = false;
bool bFoundName = false;
for (std::vector<HighlightPortion>::iterator i(aPortions.begin());
i != aPortions.end(); ++i)
{
OUString sTokStr = rLine.copy(i->nBegin, i->nEnd - i->nBegin);
if( i->tokenType == 9 && ( sTokStr.equalsIgnoreAsciiCase("sub")
|| sTokStr.equalsIgnoreAsciiCase("function")) )
{
rProcType = sTokStr;
bFoundType = true;
}
if( i->tokenType == 1 && bFoundType )
{
rProcName = sTokStr;
bFoundName = true;
break;
}
}
if( !bFoundType || !bFoundName )
return false;// no sub/function keyword or there is no identifier
return true;
}
void EditorWindow::HandleCodeCompletion() void EditorWindow::HandleCodeCompletion()
{ {
rModulWindow.UpdateModule(); rModulWindow.UpdateModule();
...@@ -1003,7 +1022,10 @@ void EditorWindow::CreateEditEngine() ...@@ -1003,7 +1022,10 @@ void EditorWindow::CreateEditEngine()
InitScrollBars(); InitScrollBars();
if (SfxBindings* pBindings = GetBindingsPtr()) if (SfxBindings* pBindings = GetBindingsPtr())
{
pBindings->Invalidate( SID_BASICIDE_STAT_POS ); pBindings->Invalidate( SID_BASICIDE_STAT_POS );
pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
}
DBG_ASSERT( rModulWindow.GetBreakPointWindow().GetCurYOffset() == 0, "CreateEditEngine: Brechpunkte verschoben?" ); DBG_ASSERT( rModulWindow.GetBreakPointWindow().GetCurYOffset() == 0, "CreateEditEngine: Brechpunkte verschoben?" );
......
...@@ -362,6 +362,8 @@ void InvalidateDebuggerSlots() ...@@ -362,6 +362,8 @@ void InvalidateDebuggerSlots()
pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT ); pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT );
pBindings->Invalidate( SID_BASICIDE_STAT_POS ); pBindings->Invalidate( SID_BASICIDE_STAT_POS );
pBindings->Update( SID_BASICIDE_STAT_POS ); pBindings->Update( SID_BASICIDE_STAT_POS );
pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
pBindings->Update( SID_BASICIDE_STAT_TITLE );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment