Allow creating empty folders
So far it was not possible to create an empty folder that was then was later filled up with commands (or folders). Because of that the structure of input.conf had to be based around the menu. By creating empty folders with the `ignore` command, that requirement has been loosened a bit. Trimming whitespace from `command` was necessary to check for "ignore".
This commit is contained in:

committed by
Tomas Klaen

parent
77550ef999
commit
377a5ef3c6
@@ -253,6 +253,9 @@ If multiple menu items with the same command are defined, **uosc** will concaten
|
||||
|
||||
Menu items are displayed in the order they are defined in `input.conf` file.
|
||||
|
||||
The command `ignore` does not result in a menu item, however all the folders leading up to it will still be created.
|
||||
This allows more flexible structuring of the `input.conf` file.
|
||||
|
||||
#### Examples
|
||||
|
||||
Adds a menu item to load subtitles:
|
||||
@@ -274,6 +277,12 @@ esc quit #! Quit
|
||||
q quit #!
|
||||
```
|
||||
|
||||
Define a folder without defining any of its contents:
|
||||
|
||||
```
|
||||
# ignore #! Folder title >
|
||||
```
|
||||
|
||||
Suggested minimal context menu setup to start with:
|
||||
|
||||
```
|
||||
|
5
uosc.lua
5
uosc.lua
@@ -2837,9 +2837,9 @@ state.context_menu_items = (function()
|
||||
local submenus_by_id = {}
|
||||
|
||||
for line in io.lines(input_conf_path) do
|
||||
local key, command, title = string.match(line, '%s*([%S]+)%s+(.*)%s#!%s*(.-)%s*$')
|
||||
local key, command, title = string.match(line, '%s*([%S]+)%s+(.-)%s+#!%s*(.-)%s*$')
|
||||
if not key then
|
||||
key, command, title = string.match(line, '%s*([%S]+)%s+(.*)%s#menu:%s*(.-)%s*$')
|
||||
key, command, title = string.match(line, '%s*([%S]+)%s+(.-)%s+#menu:%s*(.-)%s*$')
|
||||
end
|
||||
if key then
|
||||
local is_dummy = key:sub(1, 1) == '#'
|
||||
@@ -2859,6 +2859,7 @@ state.context_menu_items = (function()
|
||||
|
||||
target_menu = submenus_by_id[submenu_id]
|
||||
else
|
||||
if command == 'ignore' then break end
|
||||
-- If command is already in menu, just append the key to it
|
||||
if target_menu.items_by_command[command] then
|
||||
local hint = target_menu.items_by_command[command].hint
|
||||
|
Reference in New Issue
Block a user