Skip to content

Commit ea27802

Browse files
committed
Add interactive shortcut indicators to the edit format selector when the alt key is pressed
- when 'alt'/'option' key is pressed, replace currently selected edit format with capital letters (spaced 5px): W S D T. The active edit format's letter should be boldened. - when 'alt'/'option' is pressed, the active edit format should not be boldened, but have dotted underline - should use css for these inline styles [Changes] - in 'edit format' tooltip add shortcut with just ⌥ or alt - in prompt field, when pressed alt/option show other, non selected letters of edit formats styled as 'esc' in Header, while keeping the selected one dotted. - when alt/option is pressed, edit format should not be dimmed - remove shortcuts, in their place enter thing like: fast, demanding or fast, easy, or slow, easy, etc. - add missing translations [Fragment] - translate descriptions
1 parent 53cd55a commit ea27802

5 files changed

Lines changed: 205 additions & 19 deletions

File tree

‎apps/editor/src/i18n/translations/views/prompt/handlers/select-edit-format.ts‎

Lines changed: 81 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,39 @@ export const translations = {
1919
},
2020
'views.prompt.handlers.select-edit-format.items.whole.description': {
2121
en: 'Output file contents in full',
22-
pl: 'Wypisz pełną zawartość pliku',
22+
pl: 'Wygeneruj pliki w całości',
2323
'zh-cn': '完整输出文件内容',
24-
ja: 'ファイルの内容をすべて出力する',
24+
ja: 'ファイルの内容を完全に出力する',
2525
'zh-tw': '完整輸出檔案內容',
2626
de: 'Dateiinhalt vollständig ausgeben',
27-
es: 'Mostrar el contenido completo del archivo',
28-
fr: 'Afficher le contenu du fichier en entier',
29-
'pt-br': 'Exibir o conteúdo do arquivo na íntegra',
30-
ru: 'Вывод содержимого файла целиком',
27+
es: 'Generar el contenido del archivo completo',
28+
fr: 'Générer le contenu du fichier en entier',
29+
'pt-br': 'Gerar o conteúdo do arquivo na íntegra',
30+
ru: 'Вывести содержимое файла целиком',
3131
ko: '전체 파일 내용 출력',
32-
it: 'Output completo del contenuto del file',
32+
it: 'Invia in output i contenuti del file per intero',
3333
tr: 'Dosya içeriğini tam olarak çıkar',
3434
cs: 'Vypsat celý obsah souboru',
35-
hu: 'A fájl teljes tartalmának megjelenítése',
36-
bg: 'Извеждане на пълното съдържание на файла'
35+
hu: 'Fájl tartalmának teljes kiírása',
36+
bg: 'Извеждане на съдържанието на файла изцяло'
37+
},
38+
'views.prompt.handlers.select-edit-format.items.whole.hint': {
39+
en: 'use for difficult refactors',
40+
pl: 'używaj do trudnych refaktoryzacji',
41+
'zh-cn': '用于困难的重构',
42+
ja: '難しいリファクタリングに使用',
43+
'zh-tw': '用於困難的重構',
44+
de: 'für schwierige Refactorings verwenden',
45+
es: 'usar para refactorizaciones difíciles',
46+
fr: 'à utiliser pour les refactorisations difficiles',
47+
'pt-br': 'usar para refatorações difíceis',
48+
ru: 'использовать для сложного рефакторинга',
49+
ko: '어려운 리팩토링에 사용',
50+
it: 'usa per refactoring difficili',
51+
tr: 'zorlu yeniden yapılandırmalar için kullanın',
52+
cs: 'použít pro složité refaktorování',
53+
hu: 'nehéz refaktoráláshoz ajánlott',
54+
bg: 'използвайте за трудни рефакторинги'
3755
},
3856
'views.prompt.handlers.select-edit-format.items.search-replace': {
3957
en: 'Search & Replace',
@@ -73,6 +91,24 @@ export const translations = {
7391
hu: 'Módosított blokkok elkülönítése <<<<<<< SEARCH, =======, >>>>>>> REPLACE elválasztókkal',
7492
bg: 'Изолиране на променените блокове с разделители <<<<<<< SEARCH, =======, >>>>>>> REPLACE'
7593
},
94+
'views.prompt.handlers.select-edit-format.items.search-replace.hint': {
95+
en: 'general purpose',
96+
pl: 'ogólnego przeznaczenia',
97+
'zh-cn': '通用',
98+
ja: '汎用',
99+
'zh-tw': '通用',
100+
de: 'Allzweck',
101+
es: 'propósito general',
102+
fr: 'usage général',
103+
'pt-br': 'uso geral',
104+
ru: 'общего назначения',
105+
ko: '다목적',
106+
it: 'uso generale',
107+
tr: 'genel amaçlı',
108+
cs: 'obecné použití',
109+
hu: 'általános célú',
110+
bg: 'общо предназначение'
111+
},
76112
'views.prompt.handlers.select-edit-format.items.diff': {
77113
en: 'Unified Diff',
78114
pl: 'Zunifikowany Diff',
@@ -110,6 +146,24 @@ export const translations = {
110146
hu: 'Változások soronkénti megjelenítése törlés - és hozzáadás + jelölőkkel',
111147
bg: 'Представяне на промените ред по ред чрез маркери за изтриване - и добавяне +'
112148
},
149+
'views.prompt.handlers.select-edit-format.items.diff.hint': {
150+
en: 'general purpose',
151+
pl: 'ogólnego przeznaczenia',
152+
'zh-cn': '通用',
153+
ja: '汎用',
154+
'zh-tw': '通用',
155+
de: 'Allzweck',
156+
es: 'propósito general',
157+
fr: 'usage général',
158+
'pt-br': 'uso geral',
159+
ru: 'общего назначения',
160+
ko: '다목적',
161+
it: 'uso generale',
162+
tr: 'genel amaçlı',
163+
cs: 'obecné použití',
164+
hu: 'általános célú',
165+
bg: 'общо предназначение'
166+
},
113167
'views.prompt.handlers.select-edit-format.items.truncated': {
114168
en: 'Ellipsis truncations',
115169
pl: 'Skrócenie za pomocą wielokropka',
@@ -146,6 +200,24 @@ export const translations = {
146200
hu: 'Csonkítás ellipszissel a változatlan részekhez',
147201
bg: 'Използване на съкращения с многоточие за непроменените части'
148202
},
203+
'views.prompt.handlers.select-edit-format.items.truncated.hint': {
204+
en: 'handy with local models',
205+
pl: 'przydatne przy modelach lokalnych',
206+
'zh-cn': '适用于本地模型',
207+
ja: 'ローカルモデルで便利',
208+
'zh-tw': '適用於本地模型',
209+
de: 'praktisch bei lokalen Modellen',
210+
es: 'práctico con modelos locales',
211+
fr: 'pratique avec les modèles locaux',
212+
'pt-br': 'útil com modelos locais',
213+
ru: 'удобно с локальными моделями',
214+
ko: '로컬 모델에서 유용함',
215+
it: 'utile con i modelli locali',
216+
tr: 'yerel modellerle kullanışlıdır',
217+
cs: 'užitečné u lokálních modelů',
218+
hu: 'hasznos helyi modellekkel',
219+
bg: 'удобно с локални модели'
220+
},
149221
'views.prompt.handlers.select-edit-format.placeholder': {
150222
en: 'Select edit format',
151223
pl: 'Wybierz format edycji',

‎apps/editor/src/views/prompt/backend/message-handlers/handle-select-edit-format.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,43 @@ export const handle_select_edit_format = async (
1010
_: SelectEditFormatMessage
1111
): Promise<void> => {
1212
const current_format = prompt_view_provider.edit_format
13-
const is_mac = process.platform == 'darwin'
1413

1514
const items: (vscode.QuickPickItem & { value: EditFormat })[] = [
1615
{
1716
label: t('views.prompt.handlers.select-edit-format.items.whole'),
18-
description: is_mac ? '⌥W' : 'Alt+W',
17+
description: t(
18+
'views.prompt.handlers.select-edit-format.items.whole.hint'
19+
),
1920
detail: t(
2021
'views.prompt.handlers.select-edit-format.items.whole.description'
2122
),
2223
value: 'whole'
2324
},
2425
{
2526
label: t('views.prompt.handlers.select-edit-format.items.search-replace'),
26-
description: is_mac ? '⌥S' : 'Alt+S',
27+
description: t(
28+
'views.prompt.handlers.select-edit-format.items.search-replace.hint'
29+
),
2730
detail: t(
2831
'views.prompt.handlers.select-edit-format.items.search-replace.description'
2932
),
3033
value: 'search-replace'
3134
},
3235
{
3336
label: t('views.prompt.handlers.select-edit-format.items.diff'),
34-
description: is_mac ? '⌥D' : 'Alt+D',
37+
description: t(
38+
'views.prompt.handlers.select-edit-format.items.diff.hint'
39+
),
3540
detail: t(
3641
'views.prompt.handlers.select-edit-format.items.diff.description'
3742
),
3843
value: 'diff'
3944
},
4045
{
4146
label: t('views.prompt.handlers.select-edit-format.items.truncated'),
42-
description: is_mac ? '⌥T' : 'Alt+T',
47+
description: t(
48+
'views.prompt.handlers.select-edit-format.items.truncated.hint'
49+
),
4350
detail: t(
4451
'views.prompt.handlers.select-edit-format.items.truncated.description'
4552
),

‎packages/ui/src/components/editor/prompt/Configurations/Configurations.module.scss‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@
115115

116116
.footer {
117117
display: flex;
118-
padding: 10px 12px;
118+
padding: 10px 12px 12px 12px;
119119

120120
:global([data-modern-ui='true']) & {
121-
padding: 9px 10px;
121+
padding: 9px 10px 10px 10px;
122122
}
123123

124124
> button {

‎packages/ui/src/components/editor/prompt/prompts/PromptField/PromptField.module.scss‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,38 @@
221221
&:hover {
222222
opacity: 1;
223223
}
224+
225+
&--alt-pressed {
226+
text-decoration: none;
227+
opacity: 1;
228+
}
229+
}
230+
231+
&__shortcuts {
232+
display: flex;
233+
gap: 3px;
234+
align-items: center;
235+
}
236+
237+
&__shortcut {
238+
text-decoration: none;
239+
display: flex;
240+
justify-content: center;
241+
padding: 1px 0;
242+
width: 16px;
243+
font-size: 10px;
244+
245+
&--active {
246+
text-decoration: underline dotted;
247+
text-underline-offset: 4px;
248+
}
249+
250+
&--inactive {
251+
background-color: var(--vscode-sideBar-background);
252+
color: var(--vscode-foreground);
253+
border: 1px solid var(--cwc-border-color-dimmed);
254+
border-radius: 4px;
255+
}
224256
}
225257
}
226258

‎packages/ui/src/components/editor/prompt/prompts/PromptField/PromptField.tsx‎

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,24 +608,99 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
608608
{is_edit_format_hovered && (
609609
<Tooltip
610610
message={props.translations.edit_format}
611+
details={is_mac ? '⌥' : 'Alt'}
611612
align="center"
612613
/>
613614
)}
614615
<button
615-
className={styles['footer__right__edit-format__button']}
616+
className={cn(
617+
styles['footer__right__edit-format__button'],
618+
{
619+
[styles[
620+
'footer__right__edit-format__button--alt-pressed'
621+
]]: is_alt_pressed
622+
}
623+
)}
616624
onClick={() => props.on_edit_format_change?.()}
617625
onMouseEnter={() => set_is_edit_format_hovered(true)}
618626
onMouseLeave={() => set_is_edit_format_hovered(false)}
619627
>
620-
{
628+
{is_alt_pressed ? (
629+
<span
630+
className={
631+
styles['footer__right__edit-format__shortcuts']
632+
}
633+
>
634+
<span
635+
className={cn(
636+
styles['footer__right__edit-format__shortcut'],
637+
{
638+
[styles[
639+
'footer__right__edit-format__shortcut--active'
640+
]]: props.edit_format == 'whole',
641+
[styles[
642+
'footer__right__edit-format__shortcut--inactive'
643+
]]: props.edit_format != 'whole'
644+
}
645+
)}
646+
>
647+
W
648+
</span>
649+
<span
650+
className={cn(
651+
styles['footer__right__edit-format__shortcut'],
652+
{
653+
[styles[
654+
'footer__right__edit-format__shortcut--active'
655+
]]: props.edit_format == 'search-replace',
656+
[styles[
657+
'footer__right__edit-format__shortcut--inactive'
658+
]]: props.edit_format != 'search-replace'
659+
}
660+
)}
661+
>
662+
S
663+
</span>
664+
<span
665+
className={cn(
666+
styles['footer__right__edit-format__shortcut'],
667+
{
668+
[styles[
669+
'footer__right__edit-format__shortcut--active'
670+
]]: props.edit_format == 'diff',
671+
[styles[
672+
'footer__right__edit-format__shortcut--inactive'
673+
]]: props.edit_format != 'diff'
674+
}
675+
)}
676+
>
677+
D
678+
</span>
679+
<span
680+
className={cn(
681+
styles['footer__right__edit-format__shortcut'],
682+
{
683+
[styles[
684+
'footer__right__edit-format__shortcut--active'
685+
]]: props.edit_format == 'truncated',
686+
[styles[
687+
'footer__right__edit-format__shortcut--inactive'
688+
]]: props.edit_format != 'truncated'
689+
}
690+
)}
691+
>
692+
T
693+
</span>
694+
</span>
695+
) : (
621696
{
622697
whole: props.translations.edit_format_whole,
623698
'search-replace':
624699
props.translations.edit_format_search_replace,
625700
diff: props.translations.edit_format_diff,
626701
truncated: props.translations.edit_format_truncated
627702
}[props.edit_format as EditFormat]
628-
}
703+
)}
629704
</button>
630705
</div>
631706
)}

0 commit comments

Comments
 (0)