terminal: Make CursorShape configurable (#18530)
This builds on top of @Yevgen's #15840 and combines it with the settings names introduced in #17572. Closes #4731. Release Notes: - Added a setting for the terminal's default cursor shape. The setting is `{"terminal": {"cursor_shape": "block"}}``. Possible values: `block`, `bar`, `hollow`, `underline`. Demo: https://github.com/user-attachments/assets/96ed28c2-c222-436b-80cb-7cd63eeb47dd
This commit is contained in:
parent
57ad5778fa
commit
533416c5a9
5 changed files with 88 additions and 4 deletions
|
@ -18,7 +18,9 @@ use alacritty_terminal::{
|
|||
Config, RenderableCursor, TermMode,
|
||||
},
|
||||
tty::{self},
|
||||
vte::ansi::{ClearMode, Handler, NamedPrivateMode, PrivateMode},
|
||||
vte::ansi::{
|
||||
ClearMode, CursorStyle as AlacCursorStyle, Handler, NamedPrivateMode, PrivateMode,
|
||||
},
|
||||
Term,
|
||||
};
|
||||
use anyhow::{bail, Result};
|
||||
|
@ -40,7 +42,7 @@ use serde::{Deserialize, Serialize};
|
|||
use settings::Settings;
|
||||
use smol::channel::{Receiver, Sender};
|
||||
use task::{HideStrategy, Shell, TaskId};
|
||||
use terminal_settings::{AlternateScroll, TerminalBlink, TerminalSettings};
|
||||
use terminal_settings::{AlternateScroll, CursorShape, TerminalBlink, TerminalSettings};
|
||||
use theme::{ActiveTheme, Theme};
|
||||
use util::truncate_and_trailoff;
|
||||
|
||||
|
@ -314,6 +316,7 @@ impl TerminalBuilder {
|
|||
shell: Shell,
|
||||
mut env: HashMap<String, String>,
|
||||
blink_settings: Option<TerminalBlink>,
|
||||
cursor_shape: CursorShape,
|
||||
alternate_scroll: AlternateScroll,
|
||||
max_scroll_history_lines: Option<usize>,
|
||||
window: AnyWindowHandle,
|
||||
|
@ -353,6 +356,7 @@ impl TerminalBuilder {
|
|||
// Setup Alacritty's env, which modifies the current process's environment
|
||||
alacritty_terminal::tty::setup_env();
|
||||
|
||||
let default_cursor_style = AlacCursorStyle::from(cursor_shape);
|
||||
let scrolling_history = if task.is_some() {
|
||||
// Tasks like `cargo build --all` may produce a lot of output, ergo allow maximum scrolling.
|
||||
// After the task finishes, we do not allow appending to that terminal, so small tasks output should not
|
||||
|
@ -365,6 +369,7 @@ impl TerminalBuilder {
|
|||
};
|
||||
let config = Config {
|
||||
scrolling_history,
|
||||
default_cursor_style,
|
||||
..Config::default()
|
||||
};
|
||||
|
||||
|
@ -951,6 +956,10 @@ impl Terminal {
|
|||
&self.last_content
|
||||
}
|
||||
|
||||
pub fn set_cursor_shape(&mut self, cursor_shape: CursorShape) {
|
||||
self.term.lock().set_cursor_style(Some(cursor_shape.into()));
|
||||
}
|
||||
|
||||
pub fn total_lines(&self) -> usize {
|
||||
let term = self.term.clone();
|
||||
let terminal = term.lock_unfair();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue