wxSTC looses previous Selection...
void wxSearchInFilesFrame::selectLine(uint iLine)
{
m_scintilla->GotoLine(iLine - 1);
int lineStart = m_scintilla->PositionFromLine(m_scintilla->GetCurrentLine());
int lineEnd = m_scintilla->PositionFromLine(m_scintilla->GetCurrentLine() + 1);
m_scintilla->SetSelection(lineStart, lineEnd);
}
Any Idea how to make it persistent.
wxSTC looses previous Selection...
-
- Super wx Problem Solver
- Posts: 469
- Joined: Tue Jun 20, 2006 6:47 pm
- Contact:
Re: wxSTC looses previous Selection...
I'm not sure what you're asking. Do you want to extend the selection from the old selection to iLine? If so, you could do something like
Or if you want true multiple selections, you could do:
Code: Select all
int s = m_scintilla->GetSelectionStart();
int e = m_scintilla->GetSelectionEnd();
m_scintilla->GotoLine(iLine - 1);
int lineStart = m_scintilla->PositionFromLine(m_scintilla->GetCurrentLine());
int lineEnd = m_scintilla->PositionFromLine(m_scintilla->GetCurrentLine() + 1);
if(s<lineStart)
m_scintilla->SetSelection(s, lineEnd);
else if(e<lineEnd)
m_scintilla->SetSelection(lineStart, lineEnd);
else
m_scintilla->SetSelection(lineStart, e);
Code: Select all
int selections = m_scintilla->GetSelections();
std::vector<int> carets,anchors;
for(int i=0;i<selections;i++)
{
carets.push_back(m_scintilla->GetSelectionNCaret(i));
anchors.push_back(m_scintilla->GetSelectionNAnchor(i));
}
m_scintilla->GotoLine(iLine - 1);
int lineStart = m_scintilla->PositionFromLine(m_scintilla->GetCurrentLine());
int lineEnd = m_scintilla->PositionFromLine(m_scintilla->GetCurrentLine() + 1);
for(int i=0;i<selections;i++)
{
m_scintilla->AddSelection(carets[i],anchors[i]);
}
m_scintilla->AddSelection(lineStart,lineEnd);
Re: wxSTC looses previous Selection...
Actually the second piece of code did the job.
No i wonder how do i change the selection color ?
Kind Regards
Dode
No i wonder how do i change the selection color ?
Kind Regards
Dode
-
- Super wx Problem Solver
- Posts: 469
- Joined: Tue Jun 20, 2006 6:47 pm
- Contact:
Re: wxSTC looses previous Selection...
You can set the colors for the main selection with lines like:
Setting colors for the additional selections is slightly different:
You can also set a transparency level for selections with:where <n> is an integer between 0 and 256 (256=no alpha). I've never been able to make anything look good using transparency though.
Incidentally, since STC has so many methods, I wrote a program that breaks the methods into categories and lets you try them out with a styled text control. If you're going to be doing a lot of work with that control, you might find it helpful.
wxStyledTextCtrl Method and Event Explorer
Code: Select all
m_scintilla->SetSelForeground( true, wxColour(<red>,<green>,<blue>) );
m_scintilla->SetSelBackground( true, wxColour(<red>,<green>,<blue>) );
Code: Select all
m_scintilla->SetAdditionalSelBackground( wxColour(<red>,<green>,<blue>) );
m_scintilla->SetAdditionalSelForeground( wxColour(<red>,<green>,<blue>) );
Code: Select all
m_scintilla->SetSelAlpha( <n> );
m_scintilla->SetAdditionalSelAlpha( <n> );
Incidentally, since STC has so many methods, I wrote a program that breaks the methods into categories and lets you try them out with a styled text control. If you're going to be doing a lot of work with that control, you might find it helpful.
wxStyledTextCtrl Method and Event Explorer