@@ -215,7 +215,6 @@ impl Project {
spawn_task,
shell,
env,
- Some(settings.blinking),
settings.cursor_shape.unwrap_or_default(),
settings.alternate_scroll,
settings.max_scroll_history_lines,
@@ -42,7 +42,7 @@ use serde::{Deserialize, Serialize};
use settings::Settings;
use smol::channel::{Receiver, Sender};
use task::{HideStrategy, Shell, TaskId};
-use terminal_settings::{AlternateScroll, CursorShape, TerminalBlink, TerminalSettings};
+use terminal_settings::{AlternateScroll, CursorShape, TerminalSettings};
use theme::{ActiveTheme, Theme};
use util::truncate_and_trailoff;
@@ -102,7 +102,7 @@ pub enum Event {
CloseTerminal,
Bell,
Wakeup,
- BlinkChanged,
+ BlinkChanged(bool),
SelectionsChanged,
NewNavigationTarget(Option<MaybeNavigationTarget>),
Open(MaybeNavigationTarget),
@@ -315,7 +315,6 @@ impl TerminalBuilder {
task: Option<TaskState>,
shell: Shell,
mut env: HashMap<String, String>,
- blink_settings: Option<TerminalBlink>,
cursor_shape: CursorShape,
alternate_scroll: AlternateScroll,
max_scroll_history_lines: Option<usize>,
@@ -378,16 +377,11 @@ impl TerminalBuilder {
let (events_tx, events_rx) = unbounded();
//Set up the terminal...
let mut term = Term::new(
- config,
+ config.clone(),
&TerminalSize::default(),
ZedListener(events_tx.clone()),
);
- //Start off blinking if we need to
- if let Some(TerminalBlink::On) = blink_settings {
- term.set_private_mode(PrivateMode::Named(NamedPrivateMode::BlinkingCursor));
- }
-
//Alacritty defaults to alternate scrolling being on, so we just need to turn it off.
if let AlternateScroll::Off = alternate_scroll {
term.unset_private_mode(PrivateMode::Named(NamedPrivateMode::AlternateScroll));
@@ -437,6 +431,7 @@ impl TerminalBuilder {
pty_tx: Notifier(pty_tx),
completion_tx,
term,
+ term_config: config,
events: VecDeque::with_capacity(10), //Should never get this high.
last_content: Default::default(),
last_mouse: None,
@@ -588,6 +583,7 @@ pub struct Terminal {
pty_tx: Notifier,
completion_tx: Sender<()>,
term: Arc<FairMutex<Term<ZedListener>>>,
+ term_config: Config,
events: VecDeque<InternalEvent>,
/// This is only used for mouse mode cell change detection
last_mouse: Option<(AlacPoint, AlacDirection)>,
@@ -672,7 +668,9 @@ impl Terminal {
self.write_to_pty(format(self.last_content.size.into()))
}
AlacTermEvent::CursorBlinkingChange => {
- cx.emit(Event::BlinkChanged);
+ let terminal = self.term.lock();
+ let blinking = terminal.cursor_style().blinking;
+ cx.emit(Event::BlinkChanged(blinking));
}
AlacTermEvent::Bell => {
cx.emit(Event::Bell);
@@ -957,7 +955,8 @@ impl Terminal {
}
pub fn set_cursor_shape(&mut self, cursor_shape: CursorShape) {
- self.term.lock().set_cursor_style(Some(cursor_shape.into()));
+ self.term_config.default_cursor_style = cursor_shape.into();
+ self.term.lock().set_options(self.term_config.clone());
}
pub fn total_lines(&self) -> usize {
@@ -104,7 +104,7 @@ pub struct TerminalView {
context_menu: Option<(View<ContextMenu>, gpui::Point<Pixels>, Subscription)>,
cursor_shape: CursorShape,
blink_state: bool,
- blinking_on: bool,
+ blinking_terminal_enabled: bool,
blinking_paused: bool,
blink_epoch: usize,
can_navigate_to_selected_word: bool,
@@ -184,7 +184,7 @@ impl TerminalView {
context_menu: None,
cursor_shape,
blink_state: true,
- blinking_on: false,
+ blinking_terminal_enabled: false,
blinking_paused: false,
blink_epoch: 0,
can_navigate_to_selected_word: false,
@@ -434,7 +434,6 @@ impl TerminalView {
pub fn should_show_cursor(&self, focused: bool, cx: &mut gpui::ViewContext<Self>) -> bool {
//Don't blink the cursor when not focused, blinking is disabled, or paused
if !focused
- || !self.blinking_on
|| self.blinking_paused
|| self
.terminal
@@ -450,7 +449,10 @@ impl TerminalView {
//If the user requested to never blink, don't blink it.
TerminalBlink::Off => true,
//If the terminal is controlling it, check terminal mode
- TerminalBlink::TerminalControlled | TerminalBlink::On => self.blink_state,
+ TerminalBlink::TerminalControlled => {
+ !self.blinking_terminal_enabled || self.blink_state
+ }
+ TerminalBlink::On => self.blink_state,
}
}
@@ -642,7 +644,14 @@ fn subscribe_for_terminal_events(
cx.emit(Event::Wakeup);
}
- Event::BlinkChanged => this.blinking_on = !this.blinking_on,
+ Event::BlinkChanged(blinking) => {
+ if matches!(
+ TerminalSettings::get_global(cx).blinking,
+ TerminalBlink::TerminalControlled
+ ) {
+ this.blinking_terminal_enabled = *blinking;
+ }
+ }
Event::TitleChanged => {
cx.emit(ItemEvent::UpdateTab);