# Note that we don't call this table "uncontracted", even though there
# is also a "Russian contracted braille" table. This is because
# contractions are not officially used in Russian, and only few people
# know of it.
#-index-name: Russian, with capitals
#-display-name: Russian braille with indication of capitals
#
#+language: ru
#+type: literary
#+dots: 6
#+contraction: no
#+direction: both
#+variant: detailed
#
#  Copyright (C) 2020-2021 Andrey Yakuboy <braille@yakuboy.ru>
#  Copyright (C) 2020-2021 Bert Frees <bertfrees@gmail.com>
#
#  This file is part of liblouis.
#
#  liblouis is free software: you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as
#  published by the Free Software Foundation, either version 2.1 of the
#  License, or (at your option) any later version.
#
#  liblouis is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with liblouis. If not, see
#  <http://www.gnu.org/licenses/>.
#
# "Руководство по выпуску брайлевских изданий массового распространения" (Guidelines for edition of
# mass-distribution braille publications) <http://liblouis.org/braille-specs/russian/> advises to
# use the capital sign (45) only in certain cases where it is important to tell the difference
# between a capital or small letter. Because this rule is controversial, Liblouis provides the
# choice between a table with indication of capital letters a table without.

# Symbol attributes for special rules below (duplicated in ru-litbrl.ctb):
attribute upperlatin ABCDEFGHIJKLMNOPQRSTUVWXYZ\x00c0\x00c1\x00c2\x00c4\x00c6\x00c7\x00c8\x00c9\x00ca\x00cb\x00cd\x00ce\x00cf\x00d3\x00d4\x00d6\x00d9\x00da\x00db\x00dc\x00dd\x0106\x0139\x0143\x0152\x0154\x015a\x0179\x01f4\x1e30\x1e3e\x1e54\x1e82\x1e9e
attribute uppercyrillic \x0401\x0410\x0411\x0412\x0413\x0414\x0415\x0416\x0417\x0418\x0419\x041a\x041b\x041c\x041d\x041e\x041f\x0420\x0421\x0422\x0423\x0424\x0425\x0426\x0427\x0428\x0429\x042a\x042b\x042c\x042d\x042e\x042f\x0400\x0404\x0405\x0406\x0407\x040b\x040d\x0460\x0462\x0464\x0466\x0468\x046a\x046c\x046e\x0470\x0472\x0474\x0476\x0478\x047a\x047e\x0480\x04e0\xa640\xa642\xa648\xa650\xa652\xa656\xa64a
attribute uppergreek \x0391\x0392\x0393\x0394\x0395\x0396\x0397\x0398\x0399\x039a\x039b\x039c\x039d\x039e\x039f\x03a0\x03a1\x03a3\x03a4\x03a5\x03a6\x03a7\x03a8\x03a9

# Meaning of variables used in context rules below:
# #1: 0 = cyrillic mode (default) / 1 = latin mode (last letter was latin) / 2 = Greek mode (last letter was Greek)
# #2: 1 = uppercase mode (last character was uppercase letter)

# Mark uppercase cyrillic letters where it is appropriate.
noback context #1=0#2=1[]%uppercyrillic ?
noback context []%uppercyrillic2-65532 @45-45#1=0#2=1       # a word consists of several cyrillic uppercase letters: 45-45
noback context []%uppercyrillic @45#1=0#2=1                 # uppercase cyrillic letter not following uppercase cyrillic letter: 45

# Mark uppercase latin letters where it is appropriate.
noback context #1=1#2=1[]%upperlatin ?
noback context []%upperlatin @46#1=1#2=1                    # uppercase latin letter not following uppercase latin letter: 46

# Mark uppercase Greek letters where it is appropriate.
noback context #1=2#2=1[]%uppergreek ?
noback context []%uppergreek @456#1=2#2=1                   # uppercase Greek letter not following uppercase Greek letter: 456

include ru-litbrl.ctb

# Enter uppercase mode
noback context []%uppercyrillic #1=0#2=1
noback context []%upperlatin #1=1#2=1
noback context []%uppergreek #1=2#2=1

# Exit uppercase mode
swapcd updigit 1234567890 1,12,14,145,15,124,1245,125,24,245
noback context #2=1$d %updigit#2=0
noback context #1=1#2=1[]!%upperlatin #2=0
noback context #1=0#2=1[]!%uppercyrillic #2=0
noback context #1=2#2=1[]!%uppergreek #2=0
