this PR intereduces a config submodle. It allows for central managment of configurations and also for the user to change these as needed.
For now this module only containes INTERRUPT_KEYS, a list of keys that result in readchar() raising a KeyboardInterrupt. It defaults to key.CTRL_C
Testing implementation:
[x] existing default behavior
[x] import full libary
import readchar
while True:
k = readchar.readkey()
- [x] from import
```python
from readchar import readkey
while True:
k = readkey()
[x] import full libary
import readchar
readchar.config.INTERRUPT_KEYS.append("q")
while True:
k = readchar.readkey()
[x] from import
from readchar import readkey, config
config.INTERRUPT_KEYS.clear()
config.INTERRUPT_KEYS.append("q")
while True:
k = readkey()
from readchar import readkey, config
config.INTERRUPT_KEYS = ["q"]
while True:
k = readkey()
Warningonly works with the list methodes!! using config.INTERRUPT_KEYS = [] will not work
changed so that config is a class with class-attributes, this makes it much easier to interact with. Now both of these work, making it much easyer for the user:
# now works:
config.INTERRUPT_KEYS = ["q"]
# still works:
config.INTERRUPT_KEYS.clear()
config.INTERRUPT_KEYS.append("q")
Coverage increased (+0.3%) to 94.737% when pulling d3f69913f277ac6d0c6c51424c48fb5fa33afbc1 on config-interrupt-keys into b7d554ce08e5352585917c75c62586606712db07 on master.
this PR intereduces a
config
submodle. It allows for central managment of configurations and also for the user to change these as needed.For now this module only containes
INTERRUPT_KEYS
, a list of keys that result inreadchar()
raising aKeyboardInterrupt
. It defaults tokey.CTRL_C
Testing implementation:
[x] existing default behavior
while True: k = readchar.readkey()
[x] import full libary
[x] from import
changed so that
config
is a class with class-attributes, this makes it much easier to interact with. Now both of these work, making it much easyer for the user: