Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Punto] UA layouts #16811

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions extensions/punto/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Punto Changelog

## [Ua layout mapping] - 2025-02-04

- Added Ukrainian layout mapping to dropdown

## [Ru layout mapping] - 2025-02-03

- Replaced ru layout preference with a dropdown to map layout caption with names
Expand Down
9 changes: 5 additions & 4 deletions extensions/punto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

![](media/example.png)

Changes the layout of selected text to the opposite one and additionally changes the keyboard layout to a target one with the help of the [keyboardSwitcher](https://github.com/Lutzifer/keyboardSwitcher)
Changes the layout of selected text to the opposite one and additionally changes the keyboard layout to a target one using MacOS built-in capabilities.


Supported languages:
- English
- Russian
Supported keyboard layouts:
- Latin (English or any else)
- Cyrillic (Russian/Ukranian)

Limitations:
- If the cursor was at the end of the line, the `getSelectedText` function will return the whole line instead of selection and the switched layout text will appear right after the cursor
- If a required layout is not selectable in the dropdown, you can request it by raising an [issues](https://github.com/raycast/extensions/issues) to Punto extension

Recommended Hotkey: Option+Option (To apply, just hit the Option button 2 times)

Expand Down
27 changes: 19 additions & 8 deletions extensions/punto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
"default": "control"
},
{
"name": "ruLayoutName",
"title": "Russian Layout",
"description": "The name of the Russian layout",
"name": "cyrLayoutName",
"title": "Cyrillic Layout",
"description": "The name of the Cyrillic layout",
"type": "dropdown",
"required": true,
"data": [
Expand All @@ -59,14 +59,25 @@
{
"title": "Russian - QWERTY",
"value": "Russian - Phonetic"
},
{
"title": "Ukrainian",
"value": "Ukrainian - PC"
},
{
"title": "Ukrainian - Legacy",
"value": "Ukrainian"
},
{
"title": "Ukrainian - QWERTY",
"value": "Ukrainian-QWERTY"
}
],
"default": "Russian"
]
},
{
"name": "enLayoutName",
"title": "English Layout",
"description": "The name of the English layout",
"name": "latLayoutName",
"title": "Latin Layout",
"description": "The name of the Latin layout",
"type": "textfield",
"required": true,
"default": "ABC"
Expand Down
16 changes: 8 additions & 8 deletions extensions/punto/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { promisify } from "util";
const exec = promisify(Exec);
interface Preferences {
layoutSwitchModifier: string;
enLayoutName: string;
ruLayoutName: string;
latLayoutName: string;
cyrLayoutName: string;
showSuccessHUD: boolean;
}

enum Layout {
EN = "EN",
RU = "RU",
LAT = "LAT",
CYR = "CYR",
}

export default async function main() {
Expand Down Expand Up @@ -57,9 +57,9 @@ async function switchKeyboardLayout(
// console.log("installed layout names are " + languages.join(", "));
// console.log("target layout is " + targetLayout);
const targetLayoutName =
targetLayout === Layout.EN
? preferences.enLayoutName
: preferences.ruLayoutName;
targetLayout === Layout.LAT
? preferences.latLayoutName
: preferences.cyrLayoutName;
if (!languages.includes(targetLayoutName)) {
await showHUD(
"Layout " +
Expand Down Expand Up @@ -108,7 +108,7 @@ function detectLayout(input: string): Layout {
const array = input.split("");
const enChars = array.filter((c) => en_ru.has(c)).length;
const ruChars = array.filter((c) => ru_en.has(c)).length;
return enChars > ruChars ? Layout.EN : Layout.RU;
return enChars > ruChars ? Layout.LAT : Layout.CYR;
}

function switchCharacterLayout(char: string): string {
Expand Down
Loading