-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathreplace_Terminal.patch
More file actions
85 lines (69 loc) · 2.3 KB
/
replace_Terminal.patch
File metadata and controls
85 lines (69 loc) · 2.3 KB
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
<<<<<<< SEARCH
useEffect(() => {
if (!xtermRef.current) return;
const term = xtermRef.current;
// Apply options that support HMR
term.options.fontFamily = config.fontFamily;
term.options.fontSize = config.fontSize;
term.options.lineHeight = config.lineHeight;
term.options.cursorStyle = config.cursorStyle;
term.options.scrollback = config.scrollback;
// Sync theme foreground & cursor when isDark or themeColor changes
const themeColor = config.themeColor || '168 85 247';
term.options.theme = buildTheme(themeColor);
if (fitAddonRef.current) {
fitAddonRef.current.fit();
}
}, [config, isDark]);
useEffect(() => {
if (!xtermRef.current) return;
const term = xtermRef.current;
let disp: any;
if (config.copyOnSelect) {
disp = term.onSelectionChange(() => {
const selection = term.getSelection();
if (selection) {
navigator.clipboard.writeText(selection);
}
});
}
return () => {
if (disp) disp.dispose();
}
}, [config.copyOnSelect]);
=======
useEffect(() => {
if (!xtermRef.current) return;
const term = xtermRef.current;
const sshConfig = isSSHConfig(config) ? config : {} as Record<string, any>;
// Apply options that support HMR
term.options.fontFamily = sshConfig.fontFamily;
term.options.fontSize = sshConfig.fontSize;
term.options.lineHeight = sshConfig.lineHeight;
term.options.cursorStyle = sshConfig.cursorStyle;
term.options.scrollback = sshConfig.scrollback;
// Sync theme foreground & cursor when isDark or themeColor changes
const themeColor = sshConfig.themeColor || '168 85 247';
term.options.theme = buildTheme(themeColor);
if (fitAddonRef.current) {
fitAddonRef.current.fit();
}
}, [config, isDark]);
useEffect(() => {
if (!xtermRef.current) return;
const term = xtermRef.current;
let disp: any;
const copyOnSelect = isSSHConfig(config) ? config.copyOnSelect : false;
if (copyOnSelect) {
disp = term.onSelectionChange(() => {
const selection = term.getSelection();
if (selection) {
navigator.clipboard.writeText(selection);
}
});
}
return () => {
if (disp) disp.dispose();
}
}, [config]);
>>>>>>> REPLACE