Skip to content

Commit

Permalink
chore: move footnote up
Browse files Browse the repository at this point in the history
  • Loading branch information
Crissium committed Jul 4, 2024
1 parent ef908da commit cc1dfc2
Showing 1 changed file with 54 additions and 54 deletions.
108 changes: 54 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,60 @@ The dark theme is not built in, but rendered with the [Dark Reader Firefox exten
- [X] Localisation
- [X] [A real mobile app](https://github.com/Crissium/SilverDict-mobile)
- [ ] Make the browser's back/forward buttons work
- [ ] (Ongoing) A C++/Qt (or QML) desktop client for better integration with the system (e.g. Ctrl+C+C to look up a word)[^3]
- [ ] (Ongoing) A C++/Qt (or QML) desktop client for better integration with the system (e.g. Ctrl+C+C to look up a word)

Note: If all you need is this key combination, then perhaps `xbindkeys` suffices, which is quite huge though. Or you can use the following script:

```python
import pyperclip
import webbrowser
from pynput import keyboard
from urllib.parse import urlencode

server_address = 'http://localhost:2628/'
group = 'English'

class KeyListener:
def __init__(self):
self.ctrl_pressed = False
self.c_pressed_once = False

def on_press(self, key):
try:
if key == keyboard.Key.ctrl_l or key == keyboard.Key.ctrl_r:
self.ctrl_pressed = True
elif key.char == 'c' and self.ctrl_pressed:
if self.c_pressed_once:
selection = pyperclip.paste()
# Uncomment (and comment the line below) to use the full web UI
# params = urlencode({'group': group, 'key': selection})
# webbrowser.open_new_tab(server_address + '?' + params)

webbrowser.open_new_tab(f'{server_address}api/query/{group}/{selection}')
self.reset()
else:
self.c_pressed_once = True
else:
self.reset()
except AttributeError:
self.reset()

def on_release(self, key):
if key == keyboard.Key.esc:
return False

def reset(self):
self.ctrl_pressed = False
self.c_pressed_once = False

if __name__ == '__main__':
listener = KeyListener()
with keyboard.Listener(
on_press=listener.on_press,
on_release=listener.on_release
) as listener:
listener.join()
```

## Usage

Expand Down Expand Up @@ -192,56 +245,3 @@ This project is licensed under GPLv3. But it's said that programs designed to ru
[^1]: GoldenDict stores the decoded entries and _full-text_ definitions in its custom index. I see no reason why I should follow suit when one can always convert dictionaries in this obnoxious format into HTML-formatted StarDict with the excellent [pyglossary](https://github.com/ilius/pyglossary).

[^2]: The original use case is to support an ancient Greek lexicon that uses mixed Greek/Beta Code headwords. Normal dictionaries should not have this problem. Besides, implementing, say, a QWERTY-JCUKEN mapping is too trivial, whereas real transliteration is overcomplicated.

[^3]: If all you need is this key combination, then perhaps `xbindkeys` suffices, which is quite huge though. Or you can use the following script:

```python
import pyperclip
import webbrowser
from pynput import keyboard
from urllib.parse import urlencode

server_address = 'http://localhost:2628/'
group = 'English'

class KeyListener:
def __init__(self):
self.ctrl_pressed = False
self.c_pressed_once = False

def on_press(self, key):
try:
if key == keyboard.Key.ctrl_l or key == keyboard.Key.ctrl_r:
self.ctrl_pressed = True
elif key.char == 'c' and self.ctrl_pressed:
if self.c_pressed_once:
selection = pyperclip.paste()
# Uncomment (and comment the line below) to use the full web UI
# params = urlencode({'group': group, 'key': selection})
# webbrowser.open_new_tab(server_address + '?' + params)

webbrowser.open_new_tab(f'{server_address}api/query/{group}/{selection}')
self.reset()
else:
self.c_pressed_once = True
else:
self.reset()
except AttributeError:
self.reset()

def on_release(self, key):
if key == keyboard.Key.esc:
return False

def reset(self):
self.ctrl_pressed = False
self.c_pressed_once = False

if __name__ == '__main__':
listener = KeyListener()
with keyboard.Listener(
on_press=listener.on_press,
on_release=listener.on_release
) as listener:
listener.join()
```

0 comments on commit cc1dfc2

Please sign in to comment.