GSOC work, arrow navigation+TextSelection problems fixed
I've added a new function called EditorWindow::GetLastHighlightPortionTextSelection, which gets the last edited word (from the highlight portion), and creates a TextSelection from it. Later, this is used to remove/replace text in the listbox when pressing the tab key. The proble was, that is cleared the whole line, but now, it just clears the newly edited word. Change-Id: I61b6721696e89002705c9980579023b42ad1faaa
This commit is contained in:
@@ -130,6 +130,7 @@ private:
|
|||||||
void HandleAutoCloseDoubleQuotes();
|
void HandleAutoCloseDoubleQuotes();
|
||||||
void HandleCodeCompletition();
|
void HandleCodeCompletition();
|
||||||
void HandleProcedureCompletition();
|
void HandleProcedureCompletition();
|
||||||
|
TextSelection GetLastHighlightPortionTextSelection();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Paint( const Rectangle& );
|
virtual void Paint( const Rectangle& );
|
||||||
@@ -490,7 +491,6 @@ friend class CodeCompleteWindow;
|
|||||||
friend class EditorWindow;
|
friend class EditorWindow;
|
||||||
private:
|
private:
|
||||||
OUStringBuffer aFuncBuffer;
|
OUStringBuffer aFuncBuffer;
|
||||||
OUString aPrevStr;
|
|
||||||
/* a buffer to build up function name when typing
|
/* a buffer to build up function name when typing
|
||||||
* a function name, used for showing/hiding listbox values
|
* a function name, used for showing/hiding listbox values
|
||||||
* */
|
* */
|
||||||
|
@@ -619,7 +619,7 @@ void EditorWindow::HandleAutoCorrect()
|
|||||||
//create the appropriate TextSelection, and update the cache
|
//create the appropriate TextSelection, and update the cache
|
||||||
TextPaM aStart( nLine, r.nBegin );
|
TextPaM aStart( nLine, r.nBegin );
|
||||||
TextPaM aEnd( nLine, r.nBegin + sStr.getLength() );
|
TextPaM aEnd( nLine, r.nBegin + sStr.getLength() );
|
||||||
TextSelection sTextSelection(aStart, aEnd );
|
TextSelection sTextSelection( aStart, aEnd );
|
||||||
rModulWindow.UpdateModule();
|
rModulWindow.UpdateModule();
|
||||||
rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse( aCodeCompleteCache );
|
rModulWindow.GetSbModule()->GetCodeCompleteDataFromParse( aCodeCompleteCache );
|
||||||
// correct the last entered keyword
|
// correct the last entered keyword
|
||||||
@@ -662,6 +662,36 @@ void EditorWindow::HandleAutoCorrect()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextSelection EditorWindow::GetLastHighlightPortionTextSelection()
|
||||||
|
{//creates a text selection from the highlight portion on the cursor
|
||||||
|
sal_uLong nLine = GetEditView()->GetSelection().GetStart().GetPara();
|
||||||
|
sal_uLong nIndex = GetEditView()->GetSelection().GetStart().GetIndex();
|
||||||
|
OUString aLine( pEditEngine->GetText( nLine ) ); // the line being modified
|
||||||
|
HighlightPortions aPortions;
|
||||||
|
aHighlighter.getHighlightPortions( nLine, aLine, aPortions );
|
||||||
|
|
||||||
|
HighlightPortion& r = aPortions[aPortions.size()-1];
|
||||||
|
if( nIndex != aPortions.size()-1 )
|
||||||
|
{//cursor is not standing at the end of the line
|
||||||
|
for( size_t i = 0; i < aPortions.size(); i++ )
|
||||||
|
{
|
||||||
|
if( aPortions[i].nEnd == nIndex )
|
||||||
|
{
|
||||||
|
r = aPortions[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( aPortions.size() == 0 )
|
||||||
|
return TextSelection();
|
||||||
|
|
||||||
|
OUString sStr = aLine.copy( r.nBegin, r.nEnd - r.nBegin );
|
||||||
|
TextPaM aStart( nLine, r.nBegin );
|
||||||
|
TextPaM aEnd( nLine, r.nBegin + sStr.getLength() );
|
||||||
|
return TextSelection( aStart, aEnd );
|
||||||
|
}
|
||||||
|
|
||||||
void EditorWindow::HandleAutoCloseParen()
|
void EditorWindow::HandleAutoCloseParen()
|
||||||
{
|
{
|
||||||
TextSelection aSel = GetEditView()->GetSelection();
|
TextSelection aSel = GetEditView()->GetSelection();
|
||||||
@@ -2646,7 +2676,6 @@ void CodeCompleteListBox::SetMatchingEntries()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
||||||
{
|
{
|
||||||
sal_Unicode aChar = rKeyEvt.GetKeyCode().GetCode();
|
sal_Unicode aChar = rKeyEvt.GetKeyCode().GetCode();
|
||||||
@@ -2685,8 +2714,7 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
|||||||
}
|
}
|
||||||
case KEY_TAB:
|
case KEY_TAB:
|
||||||
{
|
{
|
||||||
TextPaM aTextEnd( GetParentEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetEnd()) );
|
TextSelection aTextSelection = pCodeCompleteWindow->pParent->GetLastHighlightPortionTextSelection();
|
||||||
TextSelection aTextSelection( pCodeCompleteWindow->GetTextSelection().GetStart(), aTextEnd );
|
|
||||||
OUString sTypedText = pCodeCompleteWindow->pParent->GetEditEngine()->GetText(aTextSelection);
|
OUString sTypedText = pCodeCompleteWindow->pParent->GetEditEngine()->GetText(aTextSelection);
|
||||||
if( !aFuncBuffer.isEmpty() )
|
if( !aFuncBuffer.isEmpty() )
|
||||||
{
|
{
|
||||||
@@ -2710,8 +2738,7 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
|||||||
if( !bFound )
|
if( !bFound )
|
||||||
SetMatchingEntries();
|
SetMatchingEntries();
|
||||||
|
|
||||||
TextPaM aEnd( GetParentEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetEnd()) );
|
GetParentEditView()->SetSelection( aTextSelection );
|
||||||
GetParentEditView()->SetSelection(TextSelection(pCodeCompleteWindow->GetTextSelection().GetStart(), aEnd ) );
|
|
||||||
GetParentEditView()->DeleteSelected();
|
GetParentEditView()->DeleteSelected();
|
||||||
GetParentEditView()->InsertText( GetSelectEntry(), sal_False );
|
GetParentEditView()->InsertText( GetSelectEntry(), sal_False );
|
||||||
}
|
}
|
||||||
@@ -2757,7 +2784,6 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
|
|||||||
void CodeCompleteListBox::HideAndRestoreFocus()
|
void CodeCompleteListBox::HideAndRestoreFocus()
|
||||||
{
|
{
|
||||||
pCodeCompleteWindow->Hide();
|
pCodeCompleteWindow->Hide();
|
||||||
GetParentEditView()->SetSelection( GetParentEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
|
|
||||||
pCodeCompleteWindow->pParent->GrabFocus();
|
pCodeCompleteWindow->pParent->GrabFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user