core: cursor click to move can be disabled

This commit is contained in:
Mitchell Hashimoto
2023-12-20 22:12:04 -08:00
parent 3776b8a777
commit 900b127a04
3 changed files with 21 additions and 0 deletions

View File

@ -178,6 +178,7 @@ The currently supported shell integration features in Ghostty:
- The cursor at the prompt is turned into a bar.
- The `jump_to_prompt` keybinding can be used to scroll the terminal window
forward and back through prompts.
- Alt+click (option+click on macOS) to move the cursor at the prompt.
#### Shell Integration Installation and Verification

View File

@ -182,6 +182,7 @@ const DerivedConfig = struct {
clipboard_paste_bracketed_safe: bool,
copy_on_select: configpkg.CopyOnSelect,
confirm_close_surface: bool,
cursor_click_to_move: bool,
desktop_notifications: bool,
mouse_interval: u64,
mouse_hide_while_typing: bool,
@ -235,6 +236,7 @@ const DerivedConfig = struct {
.clipboard_paste_bracketed_safe = config.@"clipboard-paste-bracketed-safe",
.copy_on_select = config.@"copy-on-select",
.confirm_close_surface = config.@"confirm-close-surface",
.cursor_click_to_move = config.@"cursor-click-to-move",
.desktop_notifications = config.@"desktop-notifications",
.mouse_interval = config.@"click-repeat-interval" * 1_000_000, // 500ms
.mouse_hide_while_typing = config.@"mouse-hide-while-typing",
@ -2094,6 +2096,9 @@ pub fn mouseButtonCallback(
/// screen point if possible. This works by converting the path to the
/// given point into a series of arrow key inputs.
fn clickMoveCursor(self: *Surface, to: terminal.point.ScreenPoint) !void {
// If click-to-move is disabled then we're done.
if (!self.config.cursor_click_to_move) return;
const t = &self.io.terminal;
// Click to move cursor only works on the primary screen where prompts

View File

@ -264,6 +264,21 @@ palette: Palette = .{},
/// will be chosen.
@"cursor-text": ?Color = null,
/// Enables the ability to move the cursor at prompts by using alt+click
/// on Linux and option+click on macOS.
///
/// This feature requires shell integration (specifically prompt marking
/// via OSC 133) and only works in primary screen mode. Alternate screen
/// applications like vim usually have their own version of this feature
/// but this configuration doesn't control that.
///
/// It should be noted that this feature works by translating your desired
/// position into a series of synthetic arrow key movements, so some weird
/// behavior around edge cases are to be expected. This is unfortunately
/// how this feature is implemented across terminals because there isn't
/// any other way to implement it.
@"cursor-click-to-move": bool = true,
/// Hide the mouse immediately when typing. The mouse becomes visible
/// again when the mouse is used. The mouse is only hidden if the mouse
/// cursor is over the active terminal surface.