Edit

kc3-lang/libxkbcommon/test/data/rules/special_indexes

Branch :

  • Show log

    Commit

  • Author : Pierre Le Marre
    Date : 2025-04-11 11:13:25
    Hash : a1e595e7
    Message : rules: Fix merging KcCGST values in layout order When using layout index ranges (e.g. special indexes “any” or “later”), the rules still match following the order in the rules file, so layout indexes may match without following their natural order. So the resulting KcCGST value should not be merged with the output until reaching the end of the rule set. Because the rule set may also involve options, it may match multiple times for the *same* layout index. So these multiple matches should not be merged together either, until reaching the end of the rule set. When reaching the end of the rule set, for each KcCGST component the pending values are then merged: for each layout, for each KcCGST value in the corresponding sequence, merge with the output. --- Example: ! model = symbols * = pc ! layout[any] option = symbols C 1 = +c1:%i C 2 = +c2:%i B 3 = skip B 4 = +b:%i The result of RMLVO {layout: "A,B,C", options: "4,3,2,1"} is: symbols = pc+b:2+c1:3+c2:3 - `skip` was dropped because it has no explicit merge mode; - although every rule was matched in order, the resulting order of the symbols follows the order of the layouts, so `+b` appears before `+c1` and `+c2`. - the relative order of the options for layout C follows the order within the rule set, not the order of RMLVO. Before this commit, the result would have been: symbols = pc+c1:3+c2:3+b:2

  • test/data/rules/special_indexes
  • ! model         = keycodes
      my_model      = my_keycodes
      *             = default_keycodes
    
    ! layout[single] variant    = symbols // valid
      layout_a       my_variant = a+extra_variant
    
    ! layout[single] = symbols
      layout_a       = A
    
    ! layout        = symbols
      layout_b      = B
      layout_c      = C:%i // valid, but unusual
      layout_d      = D
      layout_e      = E
      *             = %l[%i]%(v[%i]) // valid, but unusual
    
    ! layout[first] = symbols
      layout_a      = a:1
      layout_b      = b:1
      layout_c      = c:1
      layout_d      = d:%i // valid, but unusual
      layout_e      = e:1
      *             = %l[%i]%(v[%i]) // valid, cannot be easily expressed otherwise
    
    ! layout[first] = symbols
      layout_e      = %+l // different output if single or multiple layouts
    
    ! layout[later] = symbols
      layout_a      = +x:%i
      layout_b      = +y:%i
      *             = +%l[%i]%(v[%i]):%i
    
    ! layout[any]   = symbols
      layout_c      = +z:%i
    
    ! layout[any] variant[any] = symbols
      *           extra        = +foo:%i|bar:%i
    
    ! layout[1] variant = symbols // invalid mapping
      *         *       = +AAA:%i
    
    ! layout variant[1] = symbols // invalid mapping
      *      *          = +BBB:%i
    
    ! layout[1] variant[2] = symbols // invalid mapping
      *         *          = +CCC:%i
    
    ! layout[any] variant = symbols // invalid mapping
      *           *       = +DDD:%i
    
    ! layout variant[any] = symbols // invalid mapping
      *      *            = +EEE:%i
    
    ! layout[any] variant[1] = symbols // invalid mapping
      *           *          = +FFF:%i
    
    ! layout[any] variant[first] = symbols // invalid mapping
      *           *              = +GGG:%i
    
    ! model         = types
      my_model      = my_types
      *             = default_types
    
    ! model         = compat
      my_model      = my_compat
      *             = default_compat
    
    ! option        = symbols
      my_option     = +extra_option
    
    // Used to check that special indexes merge the KcCGST values in the
    // expected order.
    ! layout[any] option   = symbols
      layout_c    option_2 = +HHH:%i
      layout_b    option_1 = +III:%i
      // should be skipped (no explicit merge mode) and
      // should not interact with other rules
      layout_b    option_2 = skip
      layout_b    option_3 = +JJJ:%i
      layout_c    option_1 = +KKK:%i
    
    ! layout[first] option   = compat symbols
      *             option_1 = skip1  skip
      *             option_2 = skip2  +LLL
    
    ! layout[later] option   = symbols compat
      layout_c      option_2 = +MMM:%i skip1
      layout_c      option_1 = +NNN:%i skip2
      layout_b      option_1 = +OOO:%i skip3