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
04905df8
Commit
04905df8
authored
Feb 11, 2021
by
Waqar Ahmed
Browse files
Allow adding exceptions to Esc key behaviour
parent
0716a13a
Changes
2
Hide whitespace changes
Inline
Side-by-side
addons/konsole/kateconsole.cpp
View file @
04905df8
...
...
@@ -474,19 +474,21 @@ void KateConsole::handleEsc(QEvent *e)
return
;
}
QString
exceptString
=
KConfigGroup
(
KSharedConfig
::
openConfig
(),
"Konsole"
).
readEntry
(
"KonsoleEscKeyExceptions"
,
QStringLiteral
(
"vi,vim,nvim"
));
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
const
auto
exceptList
=
exceptString
.
split
(
QLatin1Char
(
','
),
Qt
::
SkipEmptyParts
);
#else
const
auto
exceptList
=
exceptString
.
split
(
QLatin1Char
(
','
),
QString
::
SkipEmptyParts
);
#endif
if
(
!
m_mw
||
!
m_part
||
!
m_toolView
||
!
e
)
{
return
;
}
auto
notInBlockEscApps
=
[](
QStringView
app
)
{
static
const
QLatin1String
blockEscApps
[]
=
{
QLatin1String
(
"vi"
),
QLatin1String
(
"vim"
),
QLatin1String
(
"nvim"
)};
return
std
::
find
(
std
::
begin
(
blockEscApps
),
std
::
end
(
blockEscApps
),
app
)
==
std
::
end
(
blockEscApps
);
};
QKeyEvent
*
k
=
static_cast
<
QKeyEvent
*>
(
e
);
if
(
k
->
key
()
==
Qt
::
Key_Escape
&&
k
->
modifiers
()
==
Qt
::
NoModifier
)
{
auto
name
=
qobject_cast
<
TerminalInterface
*>
(
m_part
)
->
foregroundProcessName
();
if
(
m_toolView
&&
m_toolView
->
isVisible
()
&&
notInBlockEscApps
(
name
))
{
const
auto
app
=
qobject_cast
<
TerminalInterface
*>
(
m_part
)
->
foregroundProcessName
();
if
(
m_toolView
&&
m_toolView
->
isVisible
()
&&
!
exceptList
.
contains
(
app
))
{
m_mw
->
hideToolView
(
m_toolView
);
}
}
...
...
@@ -540,9 +542,14 @@ KateKonsoleConfigPage::KateKonsoleConfigPage(QWidget *parent, KateKonsolePlugin
cbSetEscHideKonsole
=
new
QCheckBox
(
i18n
(
"Hide Konsole on pressing 'Esc'"
));
lo
->
addWidget
(
cbSetEscHideKonsole
);
QLabel
*
hideKonsoleLabel
=
new
QLabel
(
i18n
(
"This may cause issues with terminal apps that use Esc key, for e.g., vim"
),
this
);
QLabel
*
hideKonsoleLabel
=
new
QLabel
(
i18n
(
"This may cause issues with terminal apps that use Esc key, for e.g., vim. Add these apps in the input below (Comma separated list)"
),
this
);
lo
->
addWidget
(
hideKonsoleLabel
);
leEscExceptions
=
new
QLineEdit
(
this
);
lo
->
addWidget
(
leEscExceptions
);
reset
();
lo
->
addStretch
();
...
...
@@ -551,6 +558,7 @@ KateKonsoleConfigPage::KateKonsoleConfigPage(QWidget *parent, KateKonsolePlugin
connect
(
lePrefix
,
&
QLineEdit
::
textChanged
,
this
,
&
KateKonsoleConfigPage
::
changed
);
connect
(
cbSetEditor
,
&
QCheckBox
::
stateChanged
,
this
,
&
KateKonsoleConfigPage
::
changed
);
connect
(
cbSetEscHideKonsole
,
&
QCheckBox
::
stateChanged
,
this
,
&
KateKonsoleConfigPage
::
changed
);
connect
(
leEscExceptions
,
&
QLineEdit
::
textChanged
,
this
,
&
KateKonsoleConfigPage
::
changed
);
}
void
KateKonsoleConfigPage
::
slotEnableRunWarning
()
...
...
@@ -581,6 +589,7 @@ void KateKonsoleConfigPage::apply()
config
.
writeEntry
(
"RunPrefix"
,
lePrefix
->
text
());
config
.
writeEntry
(
"SetEditor"
,
cbSetEditor
->
isChecked
());
config
.
writeEntry
(
"KonsoleEscKeyBehaviour"
,
cbSetEscHideKonsole
->
isChecked
());
config
.
writeEntry
(
"KonsoleEscKeyExceptions"
,
leEscExceptions
->
text
());
config
.
sync
();
mPlugin
->
readConfig
();
}
...
...
@@ -593,6 +602,7 @@ void KateKonsoleConfigPage::reset()
lePrefix
->
setText
(
config
.
readEntry
(
"RunPrefix"
,
""
));
cbSetEditor
->
setChecked
(
config
.
readEntry
(
"SetEditor"
,
false
));
cbSetEscHideKonsole
->
setChecked
(
config
.
readEntry
(
"KonsoleEscKeyBehaviour"
,
true
));
leEscExceptions
->
setText
(
config
.
readEntry
(
"KonsoleEscKeyExceptions"
,
"vi,vim,nvim"
));
}
#include "kateconsole.moc"
...
...
addons/konsole/kateconsole.h
View file @
04905df8
...
...
@@ -233,6 +233,7 @@ private:
class
QLineEdit
*
lePrefix
;
class
QCheckBox
*
cbSetEditor
;
class
QCheckBox
*
cbSetEscHideKonsole
;
class
QLineEdit
*
leEscExceptions
;
KateKonsolePlugin
*
mPlugin
;
private
Q_SLOTS
:
...
...
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