Skip to content
GitLab
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
989ecd45
Commit
989ecd45
authored
Aug 06, 2022
by
Pablo Rauzy
Committed by
Christoph Cullmann
Aug 14, 2022
Browse files
make the kmplay command play the current macro if no argument is provided
parent
7e13e633
Changes
1
Hide whitespace changes
Inline
Side-by-side
addons/keyboardmacros/keyboardmacrosplugin.cpp
View file @
989ecd45
...
...
@@ -614,12 +614,30 @@ KeyboardMacrosPluginCommands::KeyboardMacrosPluginCommands(KeyboardMacrosPlugin
bool
KeyboardMacrosPluginCommands
::
exec
(
KTextEditor
::
View
*
view
,
const
QString
&
cmd
,
QString
&
msg
,
const
KTextEditor
::
Range
&
)
{
QStringList
actionAndName
=
cmd
.
split
(
QRegularExpression
(
QStringLiteral
(
"
\\
s+"
)));
if
(
actionAndName
.
length
()
!=
2
)
{
msg
=
i18n
(
"Usage: %1 <name>."
,
actionAndName
.
at
(
0
));
const
QStringList
&
actionAndName
=
cmd
.
split
(
QRegularExpression
(
QStringLiteral
(
"
\\
s+"
)));
const
QString
&
action
=
actionAndName
.
at
(
0
);
// kmplay can take either zero or one argument, all other commands require exactly one
if
(
actionAndName
.
length
()
>
2
||
(
action
!=
QStringLiteral
(
"kmplay"
)
&&
actionAndName
.
length
()
!=
2
))
{
msg
=
i18n
(
"Usage: %1 <name>."
,
action
);
return
false
;
}
const
QString
&
action
=
actionAndName
.
at
(
0
);
if
(
action
==
QStringLiteral
(
"kmplay"
))
{
// set focus on the view otherwise the macro is executed in the command line
view
->
setFocus
();
if
(
actionAndName
.
length
()
==
1
)
{
// no argument: play the current macro
m_plugin
->
play
();
return
true
;
}
else
{
// otherwise play the given macro
const
QString
&
name
=
actionAndName
.
at
(
1
);
if
(
!
m_plugin
->
play
(
name
))
{
msg
=
i18n
(
"No keyboard macro named '%1' found."
,
name
);
return
false
;
}
return
true
;
}
}
const
QString
&
name
=
actionAndName
.
at
(
1
);
if
(
action
==
QStringLiteral
(
"kmsave"
))
{
if
(
!
m_plugin
->
save
(
name
))
{
...
...
@@ -639,15 +657,6 @@ bool KeyboardMacrosPluginCommands::exec(KTextEditor::View *view, const QString &
return
false
;
}
return
true
;
}
else
if
(
action
==
QStringLiteral
(
"kmplay"
))
{
// set focus on the view otherwise the macro is played with focus on the command line
view
->
setFocus
();
// then attempt to play the given macro
if
(
!
m_plugin
->
play
(
name
))
{
msg
=
i18n
(
"No keyboard macro named '%1' found."
,
name
);
return
false
;
}
return
true
;
}
return
false
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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