logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

desktop.lua (1421B)


  1. -- Copyright 2006-2024 Mitchell. See LICENSE.
  2. -- Desktop Entry LPeg lexer.
  3. local lexer = lexer
  4. local P, S = lpeg.P, lpeg.S
  5. local lex = lexer.new(...)
  6. -- Keys.
  7. lex:add_rule('key', lex:tag(lexer.VARIABLE_BUILTIN, lex:word_match(lexer.VARIABLE_BUILTIN)))
  8. -- Values.
  9. lex:add_rule('value', lex:tag(lexer.CONSTANT_BUILTIN, lexer.word_match('true false')))
  10. -- Identifiers.
  11. lex:add_rule('identifier', lex:tag(lexer.IDENTIFIER, lexer.alpha * (lexer.alnum + S('_-'))^0))
  12. -- Group headers.
  13. local bracketed = lexer.range('[', ']')
  14. lex:add_rule('header', lexer.starts_line(lex:tag(lexer.HEADING, bracketed)))
  15. -- Locales.
  16. lex:add_rule('locale', lex:tag(lexer.TYPE, bracketed))
  17. -- Strings.
  18. lex:add_rule('string', lex:tag(lexer.STRING, lexer.range('"')))
  19. -- Comments.
  20. lex:add_rule('comment', lex:tag(lexer.COMMENT, lexer.to_eol('#')))
  21. -- Numbers.
  22. lex:add_rule('number', lex:tag(lexer.NUMBER, lexer.number))
  23. -- Field codes.
  24. lex:add_rule('code', lex:tag(lexer.CONSTANT_BUILTIN, '%' * S('fFuUdDnNickvm')))
  25. -- Operators.
  26. lex:add_rule('operator', lex:tag(lexer.OPERATOR, S('=')))
  27. -- Word lists.
  28. lex:set_word_list(lexer.VARIABLE_BUILTIN, {
  29. 'Type', 'Version', 'Name', 'GenericName', 'NoDisplay', 'Comment', 'Icon', 'Hidden', 'OnlyShowIn',
  30. 'NotShowIn', 'TryExec', 'Exec', 'Exec', 'Path', 'Terminal', 'MimeType', 'Categories',
  31. 'StartupNotify', 'StartupWMClass', 'URL'
  32. })
  33. lexer.property['scintillua.comment'] = '#'
  34. return lex