Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unspecified Shift effect is announced as "IndexError: list index out of range" #107

Open
jidhub opened this issue Feb 11, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@jidhub
Copy link

jidhub commented Feb 11, 2024

kalamine make https://github.com/jidhub/thumb-external-keyboard-layouts/blob/e3d0589ed7f980cb1c275e6d388428f2af6e863b/thumbsmodifiersv1.toml

When downloading the above link then running the kalamin make command, I obtain the stacktrace below. Specifying the shift effect as done in first change of jidhub/thumb-external-keyboard-layouts@5676aff fixes that. See french details of how I debugged that on https://discord.com/channels/1046720208171175946/1063061534038822942/1206264367822151710

Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.11/pdb.py", line 1775, in main
    pdb._run(target)
  File "/data/data/com.termux/files/usr/lib/python3.11/pdb.py", line 1643, in _run
    self.run(target.code)
  File "/data/data/com.termux/files/usr/lib/python3.11/bdb.py", line 600, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/data/data/com.termux/files/usr/bin/kalamine", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/kalamine/cli.py", line 122, in make
    make_all(layout, Path("dist"))
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/kalamine/cli.py", line 92, in make_all
    layout.svg.write(svg_path, pretty_print=True, encoding="utf-8")
    ^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.11/site-packages/kalamine/layout.py", line 577, in svg
    if level_num == 1 and chars[0] == chars[1].lower():
                                      ~~~~~^^^
IndexError: list index out of range
@fabi1cazenave
Copy link
Collaborator

Thanks for your bug report, I can reproduce your bug.
Note that kalamine is just a keyboard layout maker. It cannot emulate mouse buttons and probably won’t ever be able to do such a thing, which is handled at a lower-level by the OS.

And if I understand correctly, your title is misleading, since you’ve fixed the base char — not the shifted char.

Unless I’ve misunderstood something, we can re-qualify this bug as something like “Better parsing error messages”. WDYT ?

@jidhub
Copy link
Author

jidhub commented Feb 11, 2024

And if I understand correctly, your title is misleading, since you’ve fixed the base char — not the shifted char.

My change is actually specifying ² as a Shift value of first key, in same line than "1" "2" ..., and the relevant part of the change is:

 ┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┲━━━━━━━━━━┓
-│     │ 1 ! │ 2 > │ 3 < │ 4 $ │ 5 % │ 6 ^ │ 7 & │ 8 * │ 9 ± │ 0 ° │ ° } │ + ¦ ┃          ┃
+│ ²   │ 1 ! │ 2 > │ 3 < │ 4 $ │ 5 % │ 6 ^ │ 7 & │ 8 * │ 9 ± │ 0 ° │ ° } │ + ¦ ┃          ┃
 │ ²   │ & | │ é ~ │ " # │ ' { │ ( [ │ - | │ è ` │ _ \ │ ç ^ │ à @ │ ) ] │ = | ┃ ⌫        ┃
 ┢━━━━━┷━━┱──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┴──┬──┺━━┳━━━━━━━┫

I am sorry that I mixed two unrelated changes to the same commit. lClic and rClic did not prevent kalamine from ending normally (I just checked again).

“Better parsing error messages”.

I suggest: Unspecified Shift for key with "²".

@fabi1cazenave
Copy link
Collaborator

Ooohhhh thanks for the explanation. Interesting.

@fabi1cazenave fabi1cazenave added the bug Something isn't working label Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants