Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/components/account/config/editor/options.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Space } from "antd";67import A from "components/misc/A";8import Loading from "components/share/loading";9import useEditTable from "lib/hooks/edit-table";10import register from "../register";1112const desc = {13code_folding: `Enable the code folding plugin. When enabled, you can fold or unfold all14selected code by typing control+Q, or by clicking the triangle to the left of code.`,15smart_indent: `When you are editing code, smart indent automatically indents new lines based16on the editor's understanding of your code.`,17electric_chars: `When electric characters is enabled, typing certain characters, such18as { and } in C-like languages, cause the current line to be reindented.`,19match_brackets: "Highlight matching brackets near cursor",20auto_close_brackets:21"When you type a bracket character, for example ( or [, CoCalc will automatically insert the corresponding close character. Some people love how this saves them time, and other people find this extremely annoying; if this annoys you, disable it.",22match_xml_tags: "Automatically match XML tags",23auto_close_xml_tags:24"Automatically close XML tags. For example, if you are editing HTML and type <a> then </a> is automatically inserted.",25auto_close_latex:26"Automatically close LaTeX environments. For example, if you type \\begin{verbatim} and hit enter, then \\end{verbatim} is automatically inserted.",27strip_trailing_whitespace: `This open makes it so that whenever a file in the editor is saved to disk, whitespace from the ends of lines is removed, since it usually serves no purpose and can get accidentally inserted when editing. Note that markdown files are always exempt, since trailing whitespace is meaningful for them.`,28show_trailing_whitespace:29"Visibly display any trailing whitespace at the ends of lines. This is useful so that such whitespace isn't invisible.",30spaces_instead_of_tabs:31"Send spaces instead of a tab character when the tab key is pressed. Use this if you prefer, e.g., 4 spaces instead of a tab in your code. The number of spaces depends on the type of code you are editing.",32extra_button_bar:33"Show additional editing functionality (mainly in Sage worksheets)",34build_on_save: `Trigger a build of LaTex, Rmd, etc. files whenever they are saved to disk, instead of only building when you click the Build button. This is fine for small documents, but can be annoying for large documents, especially if you are a "compulsive saver".`,35show_exec_warning:36"Show a warning if you hit shift+enter (or other keys) when editing certain files, e.g., Python code, that is not directly executable. This is just to avoid confusion if you create a .py file and think it is a Jupyter notebook.",37show_my_other_cursors:38"Enable this if you want to see your own cursor when you are editing the same file in multiple browser tabs.",39} as const;4041register({42path: "editor/options",43title: "Options",44icon: "check-square",45desc: "Configure general behavior of the editors in CoCalc.",46search: desc,47Component: () => {48const { edited, original, Save, EditBoolean } = useEditTable({49accounts: { editor_settings: null },50});5152if (original == null || edited == null) {53return <Loading />;54}5556return (57<Space direction="vertical" size="large">58<Save />59<EditBoolean60icon="caret-down"61path="editor_settings.code_folding"62desc={desc.code_folding}63/>64<EditBoolean65icon="indent"66path="editor_settings.smart_indent"67desc={desc.smart_indent}68/>69<EditBoolean70icon="indent"71path="editor_settings.electric_chars"72title={`"Electric" Character Indentation`}73label={"Electric characters"}74desc={desc.electric_chars}75/>76<EditBoolean77icon="tab"78path="editor_settings.match_brackets"79desc={desc.match_brackets}80/>81<EditBoolean82icon="code"83path="editor_settings.auto_close_brackets"84desc={desc.auto_close_brackets}85/>86<EditBoolean87icon="code"88path="editor_settings.match_xml_tags"89title="Match XML tags"90desc={desc.match_xml_tags}91label="Match XML tags"92/>93<EditBoolean94icon="code"95path="editor_settings.auto_close_xml_tags"96title="Automatically Close XML Tags"97desc={desc.auto_close_xml_tags}98label="Autoclose XML tags"99/>100<EditBoolean101icon="tex"102path="editor_settings.auto_close_latex"103title="Automatically close LaTeX environments"104desc={desc.auto_close_latex}105label="Autoclose LaTeX environments"106/>107<EditBoolean108icon="align-left"109path="editor_settings.strip_trailing_whitespace"110desc={111<>112{desc.strip_trailing_whitespace}{" "}113<A href="https://www.python.org/dev/peps/pep-0008/#other-recommendations">114Stripping trailing whitespace is officially recommended for115Python code.116</A>117</>118}119/>120<EditBoolean121icon="align-left"122path="editor_settings.show_trailing_whitespace"123desc={desc.show_trailing_whitespace}124/>125<EditBoolean126icon="tab"127path="editor_settings.spaces_instead_of_tabs"128title="Spaces Instead of Tabs"129desc={130<>131{desc.spaces_instead_of_tabs}{" "}132<A href="https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces">133Spaces instead of tabs are officially recommended for Python134code.135</A>136</>137}138/>139<EditBoolean140icon="bars"141path="editor_settings.extra_button_bar"142desc={desc.extra_button_bar}143/>144<EditBoolean145icon="play-circle"146path="editor_settings.build_on_save"147desc={desc.build_on_save}148/>149<EditBoolean150icon="step-forward"151title="Show Execution Warning"152path="editor_settings.show_exec_warning"153desc={desc.show_exec_warning}154/>155<br />156<Save />157</Space>158);159},160});161162163