blob: 5a95be418b6b8c21559f23e01d4180bee2d28e43 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
type Platform = "mac" | "linux" | "windows" | "unknown";
export function getPlatform(): Platform {
const platform = window.navigator.platform.toUpperCase();
if (platform.indexOf("MAC") >= 0) {
return "mac";
} else if (platform.indexOf("LINUX") >= 0) {
return "linux";
} else if (platform.indexOf("WIN") >= 0) {
return "windows";
} else {
return "unknown";
}
}
export function isMetaEquivalentKeyPressed(event: {
metaKey: boolean;
ctrlKey: boolean;
}): boolean {
const platform = getPlatform();
switch (platform) {
case "mac":
return event.metaKey;
case "linux":
case "windows":
return event.ctrlKey;
default:
return event.metaKey;
}
}
export function getMetaKeyLabel(): string {
const platform = getPlatform();
switch (platform) {
case "mac":
return "⌘";
case "linux":
case "windows":
return "^";
default:
return "⌘";
}
}
export function getFontSize(): number {
const fontSize = localStorage.getItem("fontSize");
return fontSize ? parseInt(fontSize) : 13;
}
export function getMarkdownLanguageTagForFile(filepath: string): string {
const ext = filepath.split(".").pop();
switch (ext) {
case "py":
return "python";
case "js":
return "javascript";
case "ts":
return "typescript";
case "java":
return "java";
case "go":
return "go";
case "rb":
return "ruby";
case "rs":
return "rust";
case "c":
return "c";
case "cpp":
return "cpp";
case "cs":
return "csharp";
case "php":
return "php";
case "scala":
return "scala";
case "swift":
return "swift";
case "kt":
return "kotlin";
case "md":
return "markdown";
case "json":
return "json";
case "html":
return "html";
case "css":
return "css";
case "sh":
return "shell";
case "yaml":
return "yaml";
case "toml":
return "toml";
case "tex":
return "latex";
case "sql":
return "sql";
default:
return "";
}
}
|