Skip to content

Commit

Permalink
Merge pull request #146 from DenisKaGH/master
Browse files Browse the repository at this point in the history
RuIntl keyboard layouts set addition
  • Loading branch information
jpalmer authored Sep 25, 2024
2 parents 5f84e3e + f722a09 commit 597c535
Show file tree
Hide file tree
Showing 5 changed files with 433 additions and 0 deletions.
47 changes: 47 additions & 0 deletions ru-intl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Description
The RuIntl Russian international is a set of Cyrillic and Latin layouts unified in composition and arrangement of the punctuation marks and special characters.

The Cyrillic layout allows you to type text in the following languages:
- Russian;
- Belarusian;
- Bulgarian;
- Serbian;
- Ukrainian.

Languages ​​available on the Latin layout:
- English;
- Hungarian;
- Dutch;
- Danish;
- Spanish;
- Italian;
- Lithuanian;
- Maltese;
- German;
- Polish;
- Portuguese;
- Romanian;
- Slovak;
- Slovenian;
- Turkish;
- Finnish;
- French;
- Czech;
- Swedish;
- Estonian.

# Details
- The letters (except the Russian and English ones), as well as the special characters located on the right side of the keys (see the layout images below) and highlighted in blue (see the photo of the keyboard stickers below) are typed after using the right Alt (AltGr) key in the Compose key mode;
- To type a diacritics character on the Latin layout, "dead keys" are used; when pressed, the corresponding diacritic is selected for application to the letter of the next pressed key. If the space bar is pressed after the "dead key", a diacritic character will appear on the screen.

**Image of the Cyrillic layout: Russian (international, RU)**

![Image of the Cyrillic layout](https://raw.githubusercontent.com/DenisKaGH/RuIntl/main/Screenshots/RuIntl_RU.png)

**Image of the Latin layout: Russian (international, EN)**

![Image of the Latin layout](https://raw.githubusercontent.com/DenisKaGH/RuIntl/main/Screenshots/RuIntl_EN.png)

**The keyboard stickers photo**

![The keyboard stickers photo](https://raw.githubusercontent.com/DenisKaGH/RuIntl/main/Photos/Stickers.jpg)
198 changes: 198 additions & 0 deletions ru-intl/remap/en/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/*
Copyright 2021 The Extra Keyboards for Chrome OS Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
RuIntl latin keyboard layout
Based on the English standard keyboard layout
The AltGr key to be used as the Compose key
Updated 2024-09-21
Version 1.3
*/

let contextID = 0;

const capsoffkeys = [
"Backquote",
"Digit1",
"Digit2",
"Digit3",
"Digit4",
"Digit5",
"Digit6",
"Digit7",
"Digit8",
"Digit9",
"Digit0",
"Minus",
"Equal",
"BracketLeft",
"BracketRight",
"Backslash",
"Semicolon",
"Quote",
"Period",
"Slash"
];

//The lookup table (lut) object structure:
// "keyData.code" : [ "plain", "shifted", "altered", "altered&shifted" ]
const lut = {
"Backquote" : [ "dead_grave", "dead_acute", "`", " ́" ],
"Digit1" : [ "1", "!", "¡", "¹" ],
"Digit2" : [ "2", "\"","@", "²" ],
"Digit3" : [ "3", "#", "¿", "³" ],
"Digit4" : [ "4", ";", "$", "¤" ],
"Digit5" : [ "5", "%", "€", "£" ],
"Digit6" : [ "6", ":", "^", "¼" ],
"Digit7" : [ "7", "?", "&", "½" ],
"Digit8" : [ "8", "*", "~", "¾" ],
"Digit9" : [ "9", "(", "«", "±" ],
"Digit0" : [ "0", ")", "»", "™" ],
"Minus" : [ "-", "_", "¥", "dead_abovering" ],
"Equal" : [ "=", "+", "×", "÷" ],
"KeyQ" : [ "q", "Q", "ä", "Ä" ],
"KeyW" : [ "w", "W", "å", "Å" ],
"KeyE" : [ "e", "E", "é", "É" ],
"KeyR" : [ "r", "R", "¶", "®" ],
"KeyT" : [ "t", "T", "þ", "Þ" ],
"KeyY" : [ "y", "Y", "ü", "Ü" ],
"KeyU" : [ "u", "U", "ú", "Ú" ],
"KeyI" : [ "i", "I", "í", "Í" ],
"KeyO" : [ "o", "O", "ó", "Ó" ],
"KeyP" : [ "p", "P", "ö", "Ö" ],
"BracketLeft" : [ "dead_circumflex", "dead_diaeresis", "{", "“" ],
"BracketRight" : [ "dead_tilde", "dead_macron", "}", "”" ],
"Backslash" : [ "/", "\\", "|", "¬" ],
"KeyA" : [ "a", "A", "á", "Á" ],
"KeyS" : [ "s", "S", "ß", "§" ],
"KeyD" : [ "d", "D", "ð", "Ð" ],
"KeyF" : [ "f", "F", "", "ª" ],
"KeyG" : [ "g", "G", "Ω", "" ],
"KeyH" : [ "h", "H", "ħ", "Ħ" ],
"KeyJ" : [ "j", "J", "ø", "Ø" ],
"KeyK" : [ "k", "K", "œ", "Œ" ],
"KeyL" : [ "l", "L", "ł", "Ł" ],
"Semicolon" : [ "dead_cedilla", "dead_ogonek", "[", "‘" ],
"Quote" : [ "dead_doubleacute", "dead_breve", "]", "’" ],
"KeyZ" : [ "z", "Z", "æ", "Æ" ],
"KeyX" : [ "x", "X", "", "" ],
"KeyC" : [ "c", "C", "¢", "©" ],
"KeyV" : [ "v", "V", "↓", "↑" ],
"KeyB" : [ "b", "B", "ij", "IJ" ],
"KeyN" : [ "n", "N", "ñ", "Ñ" ],
"KeyM" : [ "m", "M", "µ", "º" ],
"Comma" : [ "ç", "Ç", "<", "←" ],
"Period" : [ "dead_abovedot", "dead_caron", ">", "→" ],
"Slash" : [ ".", ",", "'", "°" ],
"Space" : [ " ", " ", "\u00a0", "\u00a0" ],
};

const deadkeys = {
"dead_acute" : { "u": "ú", "U": "Ú", "y": "ý", "Y": "Ý", "o": "ó", "O": "Ó", "e": "é", "E": "É",
"a": "á", "A": "Á", "n": "ń", "N": "Ń", "i": "í", "I": "Í", "w": "ẃ", "W": "Ẃ",
" ": " ́", "z": "ź", "Z": "Ź", "r": "ŕ", "R": "Ŕ", "m": "ḿ", "M": "Ḿ", "p": "ṕ",
"P": "Ṕ", "s": "ś", "S": "Ś", "g": "ǵ", "G": "Ǵ", "k": "ḱ", "K": "Ḱ", "l": "ĺ",
"L": "Ĺ", "c": "ć", "C": "Ć", },
"dead_grave" : { "u": "ù", "U": "Ù", "y": "ỳ", "Y": "Ỳ", "o": "ò", "O": "Ò", "e": "è", "E": "È",
"a": "à", "A": "À", "n": "ǹ", "N": "Ǹ", "i": "ì", "I": "Ì", "w": "ẁ", "W": "Ẁ",
" ": "`", },
"dead_diaeresis" : { "u": "ü", "U": "Ü", "y": "ÿ", "Y": "Ÿ", "o": "ö", "O": "Ö", "e": "ë", "E": "Ë",
"a": "ä", "A": "Ä", "i": "ï", "I": "Ï", "w": "ẅ", "W": "Ẅ", " ": "¨", },
"dead_tilde" : { "u": "ũ", "U": "Ũ", "y": "ỹ", "Y": "Ỹ", "o": "õ", "O": "Õ", "e": "ẽ", "E": "Ẽ",
"a": "ã", "A": "Ã", "n": "ñ", "N": "Ñ", "i": "ĩ", "I": "Ĩ", " ": "~", },
"dead_circumflex" : { "u": "û", "U": "Û", "y": "ŷ", "Y": "Ŷ", "o": "ô", "O": "Ô", "e": "ê", "E": "Ê",
"a": "â", "A": "Â", "i": "î", "I": "Î", "w": "ŵ", "W": "Ŵ", " ": "^",
"z": "ẑ", "Z": "Ẑ", "s": "ŝ", "S": "Ŝ", "g": "ĝ", "G": "Ĝ", "c": "ĉ", "C": "Ĉ", },
"dead_breve" : { "u": "ŭ", "U": "Ŭ", "o": "ŏ", "O": "Ŏ", "e": "ĕ", "E": "Ĕ", "a": "ă", "A": "Ă",
"g": "ğ", "G": "Ğ", "i": "ĭ", "I": "Ĭ", " ": "˘", },
"dead_caron" : { "u": "ǔ", "U": "Ǔ", "o": "ǒ", "O": "Ǒ", "e": "ě", "E": "Ě", "a": "ǎ", "A": "Ǎ",
"n": "ň", "N": "Ň", "i": "ǐ", "I": "Ǐ", " ": "ˇ", "z": "ž", "Z": "Ž", "r": "ř",
"R": "Ř", "s": "š", "S": "Š", "g": "ǧ", "G": "Ǧ", "k": "ǩ", "K": "Ǩ", "l": "ľ",
"L": "Ľ", "c": "č", "C": "Č", },
"dead_doubleacute": { "u": "ű", "U": "Ű", "o": "ő", "O": "Ő", " ": "˝", },
"dead_ogonek" : { "u": "ų", "U": "Ų", "o": "ǫ", "O": "Ǫ", "e": "ę", "E": "Ę", "a": "ą", "A": "Ą",
"i": "į", "I": "Į", " ": "˛", },
"dead_macron" : { "u": "ū", "U": "Ū", "y": "ȳ", "Y": "Ȳ", "o": "ō", "O": "Ō", "e": "ē", "E": "Ē",
"a": "ā", "A": "Ā", "i": "ī", "I": "Ī", " ": "¯", },
"dead_abovedot" : { "y": "ẏ", "Y": "Ẏ", "o": "ȯ", "O": "Ȯ", "e": "ė", "E": "Ė", "a": "ȧ", "A": "Ȧ",
"n": "ṅ", "N": "Ṅ", "i": "ı", "I": "İ", "w": "ẇ", "W": "Ẇ", " ": "˙",
"z": "ż", "Z": "Ż", "r": "ṙ", "R": "Ṙ", "m": "ṁ", "M": "Ṁ", "p": "ṗ", "P": "Ṗ",
"s": "ṡ", "S": "Ṡ", "g": "ġ", "G": "Ġ", "c": "ċ", "C": "Ċ", },
"dead_abovering" : { "u": "ů", "U": "Ů", "y": "ẙ", "a": "å", "A": "Å", "w": "ẘ", " ": "°", },
"dead_cedilla" : { "c": "ç", "C": "Ç", "s": "ş", "S": "Ş", "t": "ţ", "T": "Ţ", " ": "¸", },
};

let altstate = false;
let deadkey = null;

chrome.input.ime.onFocus.addListener(
function(context) {
contextID = context.contextID;
}
);

chrome.input.ime.onBlur.addListener(() => {
contextID = 0;
})

chrome.input.ime.onKeyEvent.addListener(
function(engineID, keyData) {
let handled = false;

if ((keyData.type == "keydown") && (keyData.code == "AltRight")) {
if (altstate == false) {
altstate = true;
}
}

if (keyData.type == "keydown" && keyData.altKey == false && keyData.ctrlKey == false) {

if (lut[keyData.code]) {
let modified = (keyData.shiftKey != keyData.capsLock) + 2 * altstate;
if (capsoffkeys.includes(keyData.code)) {
modified = keyData.shiftKey + 2 * altstate;
}

let emit = lut[keyData.code][modified];
altstate = false;

if (deadkey != null) {
if (deadkeys[deadkey][emit]) {
emit = deadkeys[deadkey][emit];
}
deadkey = null;
}

if ((deadkey == null) && (deadkeys[emit])) {
deadkey = emit;
emit = null;
}

if (emit != null && contextID != 0) {
chrome.input.ime.commitText({
"contextID": contextID,
"text": emit,
}, () => {
if (chrome.runtime.lastError) {
console.error('Error committing text:', chrome.runtime.lastError);
return;
}
});
}
handled = true;
}
}
return handled;
});
22 changes: 22 additions & 0 deletions ru-intl/remap/en/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Russian (EN, intl., with dead keys)",
"version": "1.3",
"manifest_version": 3,
"description": "RuIntl latin keyboard layout",
"background": {
"service_worker": "background.js"
},
"permissions": [
"input"
],
"input_components": [
{
"name": "Russian (EN, intl., with dead keys)",
"type": "ime",
"id": "ruintl_en",
"description": "RuIntl latin keyboard layout",
"language": "en-US",
"layouts": ["us"]
}
]
}
Loading

0 comments on commit 597c535

Please sign in to comment.