Change menu item shorthand syntax

I'm changing the syntax a bit because I want it to be more general in
the future.
This commit is contained in:
James Westman 2021-11-28 22:31:33 -06:00
parent 2130c78da9
commit 878ff1b37b
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
3 changed files with 22 additions and 13 deletions

View file

@ -253,7 +253,7 @@ on one line. The action and icon are optional.
.. code-block::
menu {
item _("Copy") "app.copy" "copy-symbolic";
item (_("Copy"), "app.copy", "copy-symbolic")
}

View file

@ -95,19 +95,28 @@ menu_item_shorthand = Group(
Sequence(
Keyword("item"),
UseLiteral("tag", "item"),
OpenParen(),
Group(
MenuAttribute,
Sequence(UseLiteral("name", "label"), value),
),
Optional(Group(
Optional(Sequence(
Comma(),
Optional(Sequence(
Group(
MenuAttribute,
Sequence(UseLiteral("name", "action"), value),
)),
Optional(Group(
),
Optional(Sequence(
Comma(),
Group(
MenuAttribute,
Sequence(UseLiteral("name", "icon"), value),
),
))
))
)),
StmtEnd().expected("`;`"),
CloseParen().expected("')'"),
)
)
@ -163,7 +172,7 @@ def menu_content_completer(ast_node, match_variables):
)
yield Completion(
"item (shorthand)", CompletionItemKind.Snippet,
snippet='item _("${1:Label}") "${2:action-name}" "${3:icon-name}";'
snippet='item (_("${1:Label}"), "${2:action-name}", "${3:icon-name}");'
)
yield Completion(

View file

@ -13,8 +13,8 @@ menu {
label: "test item";
}
item "test item shorthand 1";
item "test item shorthand 2" "app.test-action";
item "test item shorthand 3" "app.test-action" "test-symbolic";
item ("test item shorthand 1")
item ("test item shorthand 2", "app.test-action")
item ("test item shorthand 3", "app.test-action", "test-symbolic")
}
}