Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
0b55713e
Commit
0b55713e
authored
Dec 29, 2020
by
Waqar Ahmed
Committed by
Christoph Cullmann
Dec 30, 2020
Browse files
Revert to previous context length
parent
c30a6831
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/search/plugin_search.cpp
View file @
0b55713e
...
...
@@ -951,7 +951,7 @@ void KatePluginSearchView::addMatchMark(KTextEditor::Document *doc, QTreeWidgetI
void
KatePluginSearchView
::
matchFound
(
const
QString
&
url
,
const
QString
&
fName
,
const
QString
&
lineContent
,
int
matchLen
,
int
startLine
,
int
startColumn
,
int
endLine
,
int
endColumn
)
{
static
constexpr
int
contextLen
=
14
0
;
static
constexpr
int
contextLen
=
7
0
;
if
(
!
m_curResults
||
(
sender
()
==
&
m_searchDiskFiles
&&
m_blockDiskMatchFound
))
{
return
;
...
...
@@ -975,11 +975,12 @@ void KatePluginSearchView::matchFound(const QString &url, const QString &fName,
}
post
=
post
.
toHtmlEscaped
();
QString
style
=
QStringLiteral
(
"<span style=
\"
background-color:"
)
+
m_searchBackgroundColor
+
QStringLiteral
(
";
\"
>"
);
pre
.
append
(
style
+
match
+
QStringLiteral
(
"</span>"
)
+
post
);
QString
displayText
=
QStringLiteral
(
"(<span style=
\"
color:%3;
\"
>%1:%2</span>) "
).
arg
(
startLine
+
1
).
arg
(
startColumn
+
1
).
arg
(
m_lineNumberColor
);
QString
matchHighlighted
=
QStringLiteral
(
"<span style=
\"
background-color:%1; color:%2;
\"
>%3</span>"
).
arg
(
m_searchBackgroundColor
).
arg
(
m_foregroundColor
).
arg
(
match
);
pre
.
append
(
matchHighlighted
+
post
);
displayText
.
append
(
pre
);
QStringList
txt
{
pre
};
TreeWidgetItem
*
item
=
new
TreeWidgetItem
(
static_cast
<
TreeWidgetItem
*>
(
nullptr
),
txt
);
TreeWidgetItem
*
item
=
new
TreeWidgetItem
(
static_cast
<
TreeWidgetItem
*>
(
nullptr
),
QStringList
{
displayText
});
item
->
setData
(
0
,
ReplaceMatches
::
FileUrlRole
,
url
);
item
->
setData
(
0
,
Qt
::
ToolTipRole
,
url
);
...
...
@@ -1113,11 +1114,20 @@ void KatePluginSearchView::startSearch()
return
;
}
// search color to use in search results
KTextEditor
::
ConfigInterface
*
ciface
=
qobject_cast
<
KTextEditor
::
ConfigInterface
*>
(
m_mainWindow
->
activeView
());
if
(
ciface
)
{
m_searchBackgroundColor
=
ciface
->
configValue
(
QStringLiteral
(
"search-highlight-color"
)).
value
<
QColor
>
().
name
();
qobject_cast
<
SPHtmlDelegate
*>
(
m_curResults
->
tree
->
itemDelegate
())
->
setDisplayFont
(
ciface
->
configValue
(
QStringLiteral
(
"font"
)).
value
<
QFont
>
());
/**
* update the search widget colors. This is done on start of every
* search so that if the user changes the theme, he can see the new colors
* on the next search
*/
{
KTextEditor
::
ConfigInterface
*
ciface
=
qobject_cast
<
KTextEditor
::
ConfigInterface
*>
(
m_mainWindow
->
activeView
());
if
(
ciface
)
{
// save for later reuse when the search tree starts getting populated
m_searchBackgroundColor
=
ciface
->
configValue
(
QStringLiteral
(
"search-highlight-color"
)).
value
<
QColor
>
().
name
();
m_lineNumberColor
=
ciface
->
configValue
(
QStringLiteral
(
"line-number-color"
)).
value
<
QColor
>
().
name
();
m_foregroundColor
=
m_mainWindow
->
activeView
()
->
defaultStyleAttribute
(
KTextEditor
::
dsNormal
)
->
foreground
().
color
().
name
();
qobject_cast
<
SPHtmlDelegate
*>
(
m_curResults
->
tree
->
itemDelegate
())
->
setDisplayFont
(
ciface
->
configValue
(
QStringLiteral
(
"font"
)).
value
<
QFont
>
());
}
}
m_curResults
->
regExp
=
reg
;
...
...
addons/search/plugin_search.h
View file @
0b55713e
...
...
@@ -207,6 +207,8 @@ private:
QTimer
m_updateSumaryTimer
;
QPointer
<
KTextEditor
::
Message
>
m_infoMessage
;
QString
m_searchBackgroundColor
;
QString
m_foregroundColor
;
QString
m_lineNumberColor
;
/**
* current project plugin view, if any
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment