repl: Make the terminal background transparent (#15022)
Keeps the background the same as the output area background by making the terminal background be `Hsla::transparent_black()`. Release Notes: - N/A --------- Co-authored-by: Nathan Sobo <nathan@zed.dev> Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
d0f52e90e6
commit
53b711c2b4
2 changed files with 57 additions and 94 deletions
|
@ -61,11 +61,13 @@ impl TerminalOutput {
|
||||||
.iter()
|
.iter()
|
||||||
.chain(Some(&self.handler.current_text_run))
|
.chain(Some(&self.handler.current_text_run))
|
||||||
.map(|ansi_run| {
|
.map(|ansi_run| {
|
||||||
let color = terminal_view::terminal_element::convert_color(&ansi_run.fg, theme);
|
let color = terminal_view::terminal_element::convert_color(
|
||||||
let background_color = Some(terminal_view::terminal_element::convert_color(
|
&ansi_run.fg.unwrap_or(Color::Named(NamedColor::Foreground)),
|
||||||
&ansi_run.bg,
|
|
||||||
theme,
|
theme,
|
||||||
));
|
);
|
||||||
|
let background_color = ansi_run
|
||||||
|
.bg
|
||||||
|
.map(|bg| terminal_view::terminal_element::convert_color(&bg, theme));
|
||||||
|
|
||||||
TextRun {
|
TextRun {
|
||||||
len: ansi_run.len,
|
len: ansi_run.len,
|
||||||
|
@ -99,21 +101,11 @@ impl LineHeight for TerminalOutput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Default)]
|
||||||
struct AnsiTextRun {
|
struct AnsiTextRun {
|
||||||
len: usize,
|
len: usize,
|
||||||
fg: alacritty_terminal::vte::ansi::Color,
|
fg: Option<alacritty_terminal::vte::ansi::Color>,
|
||||||
bg: alacritty_terminal::vte::ansi::Color,
|
bg: Option<alacritty_terminal::vte::ansi::Color>,
|
||||||
}
|
|
||||||
|
|
||||||
impl AnsiTextRun {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
len: 0,
|
|
||||||
fg: Color::Named(NamedColor::Foreground),
|
|
||||||
bg: Color::Named(NamedColor::Background),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TerminalHandler {
|
struct TerminalHandler {
|
||||||
|
@ -126,11 +118,7 @@ impl TerminalHandler {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
text_runs: Vec::new(),
|
text_runs: Vec::new(),
|
||||||
current_text_run: AnsiTextRun {
|
current_text_run: AnsiTextRun::default(),
|
||||||
len: 0,
|
|
||||||
fg: Color::Named(NamedColor::Foreground),
|
|
||||||
bg: Color::Named(NamedColor::Background),
|
|
||||||
},
|
|
||||||
buffer: String::new(),
|
buffer: String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,15 +147,11 @@ impl TerminalHandler {
|
||||||
self.text_runs.push(self.current_text_run.clone());
|
self.text_runs.push(self.current_text_run.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut text_run = AnsiTextRun {
|
let mut text_run = AnsiTextRun::default();
|
||||||
len: 0,
|
|
||||||
fg: self.current_text_run.fg,
|
|
||||||
bg: self.current_text_run.bg,
|
|
||||||
};
|
|
||||||
|
|
||||||
match attr {
|
match attr {
|
||||||
Attr::Foreground(color) => text_run.fg = color,
|
Attr::Foreground(color) => text_run.fg = Some(color),
|
||||||
Attr::Background(color) => text_run.bg = color,
|
Attr::Background(color) => text_run.bg = Some(color),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
109
docs/src/repl.md
109
docs/src/repl.md
|
@ -1,29 +1,11 @@
|
||||||
# REPL
|
# REPL
|
||||||
|
|
||||||
Read. Eval. Print. Loop.
|
|
||||||
|
|
||||||
<div class="warning">
|
|
||||||
|
|
||||||
This feature is in active development. Details may change. We're delighted to get feedback as the REPL feature evolves.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
Bring the power of [Jupyter kernels](https://docs.jupyter.org/en/latest/projects/kernels.html) to your editor! The built-in REPL for Zed allows you to run code interactively in your editor similarly to a notebook with your own text files.
|
Bring the power of [Jupyter kernels](https://docs.jupyter.org/en/latest/projects/kernels.html) to your editor! The built--in REPL for Zed allows you to run code interactively in your editor similarly to a notebook with your own text files.
|
||||||
|
|
||||||
<!-- TODO: Include GIF in action -->
|
<!-- TODO: Include GIF in action -->
|
||||||
|
|
||||||
To start using the REPL, add the following to your Zed `settings.json`:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"jupyter": {
|
|
||||||
"enabled": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Zed supports running code in multiple languages. To get started, you need to install a kernel for the language you want to use.
|
Zed supports running code in multiple languages. To get started, you need to install a kernel for the language you want to use.
|
||||||
|
@ -33,7 +15,6 @@ Zed supports running code in multiple languages. To get started, you need to ins
|
||||||
* [Python (ipykernel)](#python)
|
* [Python (ipykernel)](#python)
|
||||||
* [TypeScript (Deno)](#typescript-deno)
|
* [TypeScript (Deno)](#typescript-deno)
|
||||||
|
|
||||||
|
|
||||||
Once installed, you can start using the REPL in the respective language files, or other places those languages are supported, such as Markdown.
|
Once installed, you can start using the REPL in the respective language files, or other places those languages are supported, such as Markdown.
|
||||||
|
|
||||||
<!-- TODO: Make markdown a link with an example -->
|
<!-- TODO: Make markdown a link with an example -->
|
||||||
|
@ -46,48 +27,6 @@ The `repl: run` command will be executed on your selection(s), and the result wi
|
||||||
|
|
||||||
Outputs can be cleared with the `repl: clear outputs` command, or from the REPL menu in the toolbar.
|
Outputs can be cleared with the `repl: clear outputs` command, or from the REPL menu in the toolbar.
|
||||||
|
|
||||||
## Changing which kernel is used per language {#changing-kernels}
|
|
||||||
|
|
||||||
Assign kernels by name to languages in your `settings.json`.
|
|
||||||
|
|
||||||
```jsonc
|
|
||||||
{
|
|
||||||
"jupyter": {
|
|
||||||
"kernel_selections": {
|
|
||||||
"python": "conda-env",
|
|
||||||
"typescript": "deno-debug"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
If you have `jupyter` installed, you can run `jupyter kernelspec list` to see the available kernels.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ jupyter kernelspec list
|
|
||||||
Available kernels:
|
|
||||||
ark /Users/z/Library/Jupyter/kernels/ark
|
|
||||||
conda-base /Users/z/Library/Jupyter/kernels/conda-base
|
|
||||||
deno /Users/z/Library/Jupyter/kernels/deno
|
|
||||||
deno-debug /Users/z/Library/Jupyter/kernels/deno-debug
|
|
||||||
deno-release /Users/z/Library/Jupyter/kernels/deno-release
|
|
||||||
python-chatlab-dev /Users/z/Library/Jupyter/kernels/python-chatlab-dev
|
|
||||||
python3 /Users/z/Library/Jupyter/kernels/python3
|
|
||||||
ruby /Users/z/Library/Jupyter/kernels/ruby
|
|
||||||
rust /Users/z/Library/Jupyter/kernels/rust
|
|
||||||
```
|
|
||||||
|
|
||||||
Note: Zed will not find kernels nested within your Python `sys.prefix`, shown here as `/Users/z/.pyenv/versions/miniconda3-latest/`.
|
|
||||||
|
|
||||||
```
|
|
||||||
$ jupyter kernelspec list
|
|
||||||
Available kernels:
|
|
||||||
conda-base /Users/z/Library/Jupyter/kernels/conda-base
|
|
||||||
python3 /Users/z/.pyenv/versions/miniconda3-latest/share/jupyter/kernels/python3
|
|
||||||
```
|
|
||||||
|
|
||||||
You must run `python -m ipykernel install --user` to install the kernel.
|
|
||||||
|
|
||||||
## Language specific instructions
|
## Language specific instructions
|
||||||
|
|
||||||
### Python {#python}
|
### Python {#python}
|
||||||
|
@ -100,7 +39,6 @@ On MacOS, your system Python will _not_ work. Either set up [pyenv](https://gith
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
To setup your current python to have an available kernel, run:
|
To setup your current python to have an available kernel, run:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -116,7 +54,6 @@ conda install ipykernel
|
||||||
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
|
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
#### Virtualenv with pip
|
#### Virtualenv with pip
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -130,7 +67,7 @@ python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
|
||||||
[Install Deno](https://docs.deno.com/runtime/manual/getting_started/installation/) and then install the Deno jupyter kernel:
|
[Install Deno](https://docs.deno.com/runtime/manual/getting_started/installation/) and then install the Deno jupyter kernel:
|
||||||
|
|
||||||
```
|
```
|
||||||
deno jupyter --unstable --install
|
deno jupyter --install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Other languages
|
### Other languages
|
||||||
|
@ -142,3 +79,45 @@ The following languages and kernels are also supported. You can help us out by e
|
||||||
- [Ark Kernel](https://github.com/posit-dev/ark) - via Positron, formerly RStudio
|
- [Ark Kernel](https://github.com/posit-dev/ark) - via Positron, formerly RStudio
|
||||||
- [Xeus-R](https://github.com/jupyter-xeus/xeus-r)
|
- [Xeus-R](https://github.com/jupyter-xeus/xeus-r)
|
||||||
* [Scala (almond)](https://almond.sh/docs/quick-start-install)
|
* [Scala (almond)](https://almond.sh/docs/quick-start-install)
|
||||||
|
|
||||||
|
## Changing which kernel is used per language {#changing-kernels}
|
||||||
|
|
||||||
|
Zed automatically detects the available kernels on your system. If you need to configure a different default kernel for a
|
||||||
|
language, you can assign a kernel for any supported language in your `settings.json`.
|
||||||
|
|
||||||
|
```jsonc
|
||||||
|
{
|
||||||
|
"jupyter": {
|
||||||
|
"kernel_selections": {
|
||||||
|
"python": "conda-env",
|
||||||
|
"typescript": "deno",
|
||||||
|
"javascript": "deno"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If you have `jupyter` installed, you can run `jupyter kernelspec list` to see the available kernels.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ jupyter kernelspec list
|
||||||
|
Available kernels:
|
||||||
|
ark /Users/z/Library/Jupyter/kernels/ark
|
||||||
|
conda-base /Users/z/Library/Jupyter/kernels/conda-base
|
||||||
|
deno /Users/z/Library/Jupyter/kernels/deno
|
||||||
|
python-chatlab-dev /Users/z/Library/Jupyter/kernels/python-chatlab-dev
|
||||||
|
python3 /Users/z/Library/Jupyter/kernels/python3
|
||||||
|
ruby /Users/z/Library/Jupyter/kernels/ruby
|
||||||
|
rust /Users/z/Library/Jupyter/kernels/rust
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: Zed will not find kernels nested within your Python `sys.prefix`, shown here as `/Users/z/.pyenv/versions/miniconda3-latest/`.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ jupyter kernelspec list
|
||||||
|
Available kernels:
|
||||||
|
conda-base /Users/z/Library/Jupyter/kernels/conda-base
|
||||||
|
python3 /Users/z/.pyenv/versions/miniconda3-latest/share/jupyter/kernels/python3
|
||||||
|
```
|
||||||
|
|
||||||
|
You must run `python -m ipykernel install --user` to install the kernel.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue