Skip to content

Commit

Permalink
format shortcuts text according to OS conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecarenzo committed Aug 29, 2023
1 parent e1becf1 commit 704f317
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/attack_flow_builder/public/settings_macos.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
"duplicate": "Meta+D",
"find": "Meta+F",
"find_next": "Meta+G",
"find_previous": "Meta+Shift+G",
"find_previous": "Shift+Meta+G",
"select_all": "Meta+A"
},
"layout": {
"selection_to_front": "Meta+Shift+F",
"selection_to_back": "Meta+Shift+B",
"selection_to_front": "Shift+Meta+F",
"selection_to_back": "Shift+Meta+B",
"bring_selection_forward": "",
"send_selection_backward": "",
"align_left": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,35 @@
</template>

<script lang="ts">
import { Browser, OperatingSystem } from '@/assets/scripts/Browser';
import { defineComponent, PropType } from 'vue';
import {
ContextMenu, ContextMenuItem,
ContextMenuSection, MenuType
} from "@/assets/scripts/ContextMenuTypes";
const KeyToText: { [key: string]: string } = {
const KeyToTextWin: { [key: string]: string } = {
Control : "Ctrl",
Escape : "Esc",
ArrowLeft : "",
ArrowUp : "",
ArrowRight : "",
ArrowDown : "",
Delete : "Del",
Meta : ""
Meta : "Win"
}
const KeyToTextMacOS: { [key: string]: string } = {
Control : "",
Escape : "Esc",
ArrowLeft : "",
ArrowUp : "",
ArrowRight : "",
ArrowDown : "",
Delete : "Del",
Meta : "",
Shift : "",
Alt : ""
}
export default defineComponent({
Expand Down Expand Up @@ -193,10 +207,17 @@ export default defineComponent({
if(!shortcut) {
return shortcut;
} else {
return shortcut
.split("+")
.map(c => c in KeyToText ? KeyToText[c] : c)
.join("+");
if(Browser.getOperatingSystemClass() === OperatingSystem.MacOS) {
return shortcut
.split("+")
.map(c => c in KeyToTextMacOS ? KeyToTextMacOS[c] : c)
.join("")
} else {
return shortcut
.split("+")
.map(c => c in KeyToTextWin ? KeyToTextWin[c] : c)
.join("+");
}
}
}
Expand Down

0 comments on commit 704f317

Please sign in to comment.