Finished mouse compatability
This commit is contained in:
parent
9f9bafd2a7
commit
cfbda00cc4
5 changed files with 77 additions and 30 deletions
|
@ -102,8 +102,8 @@
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
"working_directory": "current_project_directory",
|
"working_directory": "current_project_directory",
|
||||||
//Set the cursor blinking behavior in the terminal.
|
// Set the cursor blinking behavior in the terminal.
|
||||||
//May take 4 values:
|
// May take 4 values:
|
||||||
// 1. Never blink the cursor, ignoring the terminal mode
|
// 1. Never blink the cursor, ignoring the terminal mode
|
||||||
// "blinking": "off",
|
// "blinking": "off",
|
||||||
// 2. Default the cursor blink to off, but allow the terminal to
|
// 2. Default the cursor blink to off, but allow the terminal to
|
||||||
|
@ -112,17 +112,27 @@
|
||||||
// 3. Always blink the cursor, ignoring the terminal mode
|
// 3. Always blink the cursor, ignoring the terminal mode
|
||||||
// "blinking": "on",
|
// "blinking": "on",
|
||||||
"blinking": "terminal_controlled",
|
"blinking": "terminal_controlled",
|
||||||
//Any key-value pairs added to this list will be added to the terminal's
|
// Set whether Alternate Scroll mode (code: ?1007) is active by default.
|
||||||
//enviroment. Use `:` to seperate multiple values.
|
// Alternate Scroll mode converts mouse scroll events into up / down key
|
||||||
|
// presses when in the alternate screen (e.g. when running applications
|
||||||
|
// like vim or less). The terminal can still set and unset this mode.
|
||||||
|
// May take 2 values:
|
||||||
|
// 1. Default alternate scroll mode to on
|
||||||
|
// "alternate_scroll": "on",
|
||||||
|
// 2. Default alternate scroll mode to off
|
||||||
|
// "alternate_scroll": "off",
|
||||||
|
"alternate_scroll": "off",
|
||||||
|
// Any key-value pairs added to this list will be added to the terminal's
|
||||||
|
// enviroment. Use `:` to seperate multiple values.
|
||||||
"env": {
|
"env": {
|
||||||
//"KEY": "value1:value2"
|
// "KEY": "value1:value2"
|
||||||
}
|
}
|
||||||
//Set the terminal's font size. If this option is not included,
|
// Set the terminal's font size. If this option is not included,
|
||||||
//the terminal will default to matching the buffer's font size.
|
// the terminal will default to matching the buffer's font size.
|
||||||
//"font_size": "15"
|
// "font_size": "15"
|
||||||
//Set the terminal's font family. If this option is not included,
|
// Set the terminal's font family. If this option is not included,
|
||||||
//the terminal will default to matching the buffer's font family.
|
// the terminal will default to matching the buffer's font family.
|
||||||
//"font_family": "Zed Mono"
|
// "font_family": "Zed Mono"
|
||||||
},
|
},
|
||||||
// Different settings for specific languages.
|
// Different settings for specific languages.
|
||||||
"languages": {
|
"languages": {
|
||||||
|
@ -155,15 +165,15 @@
|
||||||
"tab_size": 2
|
"tab_size": 2
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//LSP Specific settings.
|
// LSP Specific settings.
|
||||||
"lsp": {
|
"lsp": {
|
||||||
//Specify the LSP name as a key here.
|
// Specify the LSP name as a key here.
|
||||||
//As of 8/10/22, supported LSPs are:
|
// As of 8/10/22, supported LSPs are:
|
||||||
//pyright
|
// pyright
|
||||||
//gopls
|
// gopls
|
||||||
//rust-analyzer
|
// rust-analyzer
|
||||||
//typescript-language-server
|
// typescript-language-server
|
||||||
//vscode-json-languageserver
|
// vscode-json-languageserver
|
||||||
// "rust_analyzer": {
|
// "rust_analyzer": {
|
||||||
// //These initialization options are merged into Zed's defaults
|
// //These initialization options are merged into Zed's defaults
|
||||||
// "initialization_options": {
|
// "initialization_options": {
|
||||||
|
|
|
@ -84,6 +84,7 @@ pub struct TerminalSettings {
|
||||||
pub font_family: Option<String>,
|
pub font_family: Option<String>,
|
||||||
pub env: Option<HashMap<String, String>>,
|
pub env: Option<HashMap<String, String>>,
|
||||||
pub blinking: Option<TerminalBlink>,
|
pub blinking: Option<TerminalBlink>,
|
||||||
|
pub alternate_scroll: Option<AlternateScroll>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, JsonSchema)]
|
||||||
|
@ -114,6 +115,19 @@ impl Default for Shell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, JsonSchema)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum AlternateScroll {
|
||||||
|
On,
|
||||||
|
Off,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for AlternateScroll {
|
||||||
|
fn default() -> Self {
|
||||||
|
AlternateScroll::On
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum WorkingDirectory {
|
pub enum WorkingDirectory {
|
||||||
|
|
|
@ -134,8 +134,8 @@ pub fn scroll_report(
|
||||||
pub fn alt_scroll(scroll_lines: i32) -> Vec<u8> {
|
pub fn alt_scroll(scroll_lines: i32) -> Vec<u8> {
|
||||||
let cmd = if scroll_lines > 0 { b'A' } else { b'B' };
|
let cmd = if scroll_lines > 0 { b'A' } else { b'B' };
|
||||||
|
|
||||||
let mut content = Vec::with_capacity(scroll_lines as usize * 3);
|
let mut content = Vec::with_capacity(scroll_lines.abs() as usize * 3);
|
||||||
for _ in 0..scroll_lines {
|
for _ in 0..scroll_lines.abs() {
|
||||||
content.push(0x1b);
|
content.push(0x1b);
|
||||||
content.push(b'O');
|
content.push(b'O');
|
||||||
content.push(cmd);
|
content.push(cmd);
|
||||||
|
|
|
@ -28,7 +28,7 @@ use mappings::mouse::{
|
||||||
alt_scroll, mouse_button_report, mouse_moved_report, mouse_point, mouse_side, scroll_report,
|
alt_scroll, mouse_button_report, mouse_moved_report, mouse_point, mouse_side, scroll_report,
|
||||||
};
|
};
|
||||||
use modal::deploy_modal;
|
use modal::deploy_modal;
|
||||||
use settings::{Settings, Shell, TerminalBlink};
|
use settings::{AlternateScroll, Settings, Shell, TerminalBlink};
|
||||||
use std::{collections::HashMap, fmt::Display, ops::Sub, path::PathBuf, sync::Arc, time::Duration};
|
use std::{collections::HashMap, fmt::Display, ops::Sub, path::PathBuf, sync::Arc, time::Duration};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
@ -263,6 +263,7 @@ impl TerminalBuilder {
|
||||||
env: Option<HashMap<String, String>>,
|
env: Option<HashMap<String, String>>,
|
||||||
initial_size: TerminalSize,
|
initial_size: TerminalSize,
|
||||||
blink_settings: Option<TerminalBlink>,
|
blink_settings: Option<TerminalBlink>,
|
||||||
|
alternate_scroll: &AlternateScroll,
|
||||||
) -> Result<TerminalBuilder> {
|
) -> Result<TerminalBuilder> {
|
||||||
let pty_config = {
|
let pty_config = {
|
||||||
let alac_shell = shell.clone().and_then(|shell| match shell {
|
let alac_shell = shell.clone().and_then(|shell| match shell {
|
||||||
|
@ -306,6 +307,14 @@ impl TerminalBuilder {
|
||||||
term.set_mode(alacritty_terminal::ansi::Mode::BlinkingCursor)
|
term.set_mode(alacritty_terminal::ansi::Mode::BlinkingCursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Start alternate_scroll if we need to
|
||||||
|
if let AlternateScroll::On = alternate_scroll {
|
||||||
|
term.set_mode(alacritty_terminal::ansi::Mode::AlternateScroll)
|
||||||
|
} else {
|
||||||
|
//Alacritty turns it on by default, so we need to turn it off.
|
||||||
|
term.unset_mode(alacritty_terminal::ansi::Mode::AlternateScroll)
|
||||||
|
}
|
||||||
|
|
||||||
let term = Arc::new(FairMutex::new(term));
|
let term = Arc::new(FairMutex::new(term));
|
||||||
|
|
||||||
//Setup the pty...
|
//Setup the pty...
|
||||||
|
|
|
@ -10,7 +10,7 @@ use workspace::{Item, Workspace};
|
||||||
|
|
||||||
use crate::TerminalSize;
|
use crate::TerminalSize;
|
||||||
use project::{LocalWorktree, Project, ProjectPath};
|
use project::{LocalWorktree, Project, ProjectPath};
|
||||||
use settings::{Settings, WorkingDirectory};
|
use settings::{AlternateScroll, Settings, WorkingDirectory};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
@ -94,12 +94,26 @@ impl TerminalView {
|
||||||
let shell = settings.terminal_overrides.shell.clone();
|
let shell = settings.terminal_overrides.shell.clone();
|
||||||
let envs = settings.terminal_overrides.env.clone(); //Should be short and cheap.
|
let envs = settings.terminal_overrides.env.clone(); //Should be short and cheap.
|
||||||
|
|
||||||
|
//TODO: move this pattern to settings
|
||||||
|
let scroll = settings
|
||||||
|
.terminal_overrides
|
||||||
|
.alternate_scroll
|
||||||
|
.as_ref()
|
||||||
|
.unwrap_or(
|
||||||
|
settings
|
||||||
|
.terminal_defaults
|
||||||
|
.alternate_scroll
|
||||||
|
.as_ref()
|
||||||
|
.unwrap_or_else(|| &AlternateScroll::On),
|
||||||
|
);
|
||||||
|
|
||||||
let content = match TerminalBuilder::new(
|
let content = match TerminalBuilder::new(
|
||||||
working_directory.clone(),
|
working_directory.clone(),
|
||||||
shell,
|
shell,
|
||||||
envs,
|
envs,
|
||||||
size_info,
|
size_info,
|
||||||
settings.terminal_overrides.blinking.clone(),
|
settings.terminal_overrides.blinking.clone(),
|
||||||
|
scroll,
|
||||||
) {
|
) {
|
||||||
Ok(terminal) => {
|
Ok(terminal) => {
|
||||||
let terminal = cx.add_model(|cx| terminal.subscribe(cx));
|
let terminal = cx.add_model(|cx| terminal.subscribe(cx));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue