-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #309 from Bristol-Braille/euro-braille-encoding
Allow selection of BRF encoding - adding Eurobraille as an option
- Loading branch information
Showing
20 changed files
with
1,170 additions
and
885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from ..state import state | ||
|
||
|
||
# create a function to call when the button is pressed | ||
# (otherwise the function call happens immediately) | ||
def select_encoding(index): | ||
return lambda: state.app.encoding.select_encoding(index) | ||
|
||
|
||
buttons = { | ||
'single': { | ||
'L': state.app.close_menu, | ||
'2': select_encoding(0), | ||
'3': select_encoding(1), | ||
'4': select_encoding(2), | ||
'5': select_encoding(3), | ||
'6': select_encoding(4), | ||
'7': select_encoding(5), | ||
'8': select_encoding(6), | ||
'9': select_encoding(7), | ||
'<': state.app.previous_page, | ||
'>': state.app.next_page, | ||
'R': state.app.help_menu.toggle | ||
}, | ||
'long': { | ||
'L': state.app.close_menu, | ||
'2': select_encoding(0), | ||
'3': select_encoding(1), | ||
'4': select_encoding(2), | ||
'5': select_encoding(3), | ||
'6': select_encoding(4), | ||
'7': select_encoding(5), | ||
'8': select_encoding(6), | ||
'9': select_encoding(7), | ||
'<': state.app.previous_page, | ||
'>': state.app.next_page, | ||
'R': state.app.help_menu.toggle, | ||
'X': state.hardware.reset_display | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from ..braille import BUILTIN_ENCODINGS, set_encoding | ||
from .. import state | ||
|
||
|
||
class EncodingState: | ||
def __init__(self, root: 'state.RootState'): | ||
self.root = root | ||
self.available = BUILTIN_ENCODINGS | ||
|
||
def select_encoding(self, value): | ||
enc = abs(int(value)) | ||
keys = list(self.available.keys()) | ||
if enc < len(keys): | ||
encoding = keys[enc] | ||
set_encoding(encoding) | ||
self.root.app.user.current_encoding = encoding | ||
self.root.app.location = 'book' | ||
self.root.refresh_display() | ||
self.root.save_state() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from ..braille import from_ascii, format_title, to_ueb_number, from_unicode | ||
|
||
def render_help(width, height): | ||
data = [] | ||
para = _('''\ | ||
You can change the braille encoding by pressing the \ | ||
line select button to the left of your chosen encoding. \ | ||
The encoding will be used to display BRF files. \ | ||
''') | ||
|
||
for line in para.split('\n'): | ||
data.append(from_unicode(line)) | ||
|
||
while len(data) % height: | ||
data.append(tuple()) | ||
|
||
return tuple(data) | ||
|
||
|
||
async def render(width, height, state): | ||
help_menu = state.app.help_menu.visible | ||
if help_menu: | ||
all_lines = render_help(width, height) | ||
num_pages = len(all_lines) // height | ||
page_num = min(state.app.help_menu.page, num_pages - 1) | ||
first_line = page_num * height | ||
off_end = first_line + height | ||
page = all_lines[first_line:off_end] | ||
return page | ||
|
||
enc = state.app.user.current_encoding | ||
encodings = state.app.encoding.available | ||
current_enc = _(encodings.get(enc).title) | ||
|
||
try: | ||
cur_index = list(encodings.keys()).index(enc) | ||
except ValueError: | ||
cur_index = -1 | ||
|
||
# TRANSLATORS: A menu title, to which the encoding title is appended | ||
title = _('encoding:') + ' {}' | ||
title = format_title( | ||
title.format(current_enc), | ||
width, cur_index, len(encodings.keys())) | ||
data = [title] | ||
|
||
for enc in encodings: | ||
encs = list(encodings.keys()).index(enc) | ||
n = from_ascii(to_ueb_number(encs + 1) + ' ') | ||
data.append(n + tuple(from_unicode(_(encodings[enc].title)))) | ||
|
||
while len(data) < height: | ||
data.append(tuple()) | ||
|
||
return tuple(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PROJECT VERSION\n" | ||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" | ||
"POT-Creation-Date: 2024-05-20 13:12+0100\n" | ||
"POT-Creation-Date: 2024-05-20 18:54+0100\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
@@ -17,6 +17,14 @@ msgstr "" | |
"Content-Transfer-Encoding: 8bit\n" | ||
"Generated-By: Babel 2.13.1\n" | ||
|
||
#: ui/braille.py:144 | ||
msgid "North American Braille ASCII" | ||
msgstr "" | ||
|
||
#: ui/braille.py:147 | ||
msgid "Eurobraille" | ||
msgstr "" | ||
|
||
#. TRANSLATORS: This is a language name menu item, so should always appear | ||
#. in the language it denotes so that it remains readable to those who | ||
#. speak only that language, just as "Deutsch" should always be left as | ||
|
@@ -138,6 +146,18 @@ msgstr "" | |
msgid "end of book" | ||
msgstr "" | ||
|
||
#: ui/encoding/view.py:5 | ||
msgid "" | ||
"You can change the braille encoding by pressing the line select button to" | ||
" the left of your chosen encoding. The encoding will be used to display " | ||
"BRF files. " | ||
msgstr "" | ||
|
||
#. TRANSLATORS: A menu title, to which the encoding title is appended | ||
#: ui/encoding/view.py:41 | ||
msgid "encoding:" | ||
msgstr "" | ||
|
||
#: ui/go_to_page/view.py:6 | ||
msgid "" | ||
"You can navigate to a page within a file by entering the page number " | ||
|
@@ -251,14 +271,18 @@ msgid "shutdown" | |
msgstr "" | ||
|
||
#: ui/system_menu/view.py:35 | ||
msgid "backup log to USB stick" | ||
msgid "select language and code" | ||
msgstr "" | ||
|
||
#: ui/system_menu/view.py:36 | ||
msgid "select language and code" | ||
msgid "choose BRF encoding" | ||
msgstr "" | ||
|
||
#: ui/system_menu/view.py:37 | ||
msgid "backup log to USB stick" | ||
msgstr "" | ||
|
||
#: ui/system_menu/view.py:38 | ||
msgid "install upgrade from " | ||
msgstr "" | ||
|
||
|
Binary file not shown.
Oops, something went wrong.