CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/components/account/config/editor/terminal.tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Col, Row, Space } from "antd";
7
8
import {
9
example,
10
theme_desc,
11
} from "@cocalc/frontend/frame-editors/terminal-editor/theme-data";
12
import Loading from "components/share/loading";
13
import useEditTable from "lib/hooks/edit-table";
14
import register from "../register";
15
import { Paragraph, Title } from "components/misc";
16
17
interface Data {
18
terminal: {
19
color_scheme: keyof typeof theme_desc;
20
font_size: number;
21
};
22
}
23
24
const desc = {
25
font_size: `New terminals will use this font size by default. You can change this
26
for a particular terminal at any time.`,
27
color_scheme: `The color scheme used for terminals.`,
28
font: `The CoCalc terminal uses your browser's fixed-width font, which you can change in your browser's preferences.`,
29
} as const;
30
31
register({
32
path: "editor/terminal",
33
title: "Terminals",
34
icon: "terminal",
35
desc: "Terminal default font size, color theme, etc.",
36
search: desc,
37
Component: () => {
38
const { edited, original, Save, EditNumber, EditSelect } =
39
useEditTable<Data>({
40
accounts: { terminal: null },
41
});
42
43
if (original == null || edited == null) {
44
return <Loading />;
45
}
46
47
return (
48
<Row gutter={[20, 30]}>
49
<Col md={24} sm={24}>
50
<Save />
51
</Col>
52
<Col md={14} sm={24}>
53
<Space direction="vertical" size="large">
54
<EditNumber
55
path="terminal.font_size"
56
title="Terminal Font Size"
57
icon="text-height"
58
desc={desc.font_size}
59
min={5}
60
max={32}
61
units="px"
62
/>
63
<EditSelect
64
path="terminal.color_scheme"
65
icon="colors"
66
desc={desc.color_scheme}
67
options={theme_desc}
68
style={{ width: "30ex" }}
69
/>
70
<Space direction="vertical">
71
<Title level={2} style={{ marginTop: "15px" }}>
72
Font
73
</Title>
74
<Paragraph>{desc.font}</Paragraph>
75
</Space>
76
</Space>
77
</Col>
78
<Col md={10} sm={24}>
79
<h3 style={{ marginTop: "10px" }}>Preview</h3>
80
<div
81
style={{
82
fontSize: `${edited.terminal.font_size}px`,
83
overflow: "hidden",
84
}}
85
dangerouslySetInnerHTML={{
86
__html: example(edited.terminal.color_scheme),
87
}}
88
/>
89
</Col>
90
</Row>
91
);
92
},
93
});
94
95