563 Commits

Author SHA1 Message Date
Bryan Lee
bf6cce23da Prevent hyperlink hover state when mouse is outside viewport 2025-01-22 02:49:37 +08:00
otomist
e5a3be3c46 use whitespace instead of new flag for selecting full line 2025-01-20 10:23:41 -08:00
otomist
95debc59d1 add and use flag for selecting empty lines in the selectLine function 2025-01-14 12:04:43 -05:00
Mitchell Hashimoto
844f20d01f Handle setting _NET_WM_STATE (#4936)
As recommended in
https://github.com/ghostty-org/ghostty/pull/4927#issuecomment-2585003934,
adds a config option `maximize` for starting a window in a maximized
state in terms of window properties. Also adds a `toggle_maximize`
keybind to allow users to manually toggle this feature on and off.

It might make more sense to make this an optional config value so that
we don't toggle the state off if the WM already handles that for us, but
I'll let a reviewer decide.

Closes https://github.com/ghostty-org/ghostty/issues/4646
2025-01-13 13:14:31 -08:00
Mitchell Hashimoto
6c5c5b2ec0 core: clear selection whenever preedit is changed 2025-01-11 14:06:42 -08:00
Bryan Lee
2409d46600 Correct IME position calculation with window padding 2025-01-12 01:15:53 +08:00
Adam Wolf
c9636598fc chore: rename config value to maximize and move startup logic to proper location 2025-01-10 23:24:00 -06:00
Adam Wolf
8102fddceb apprt/gtk: add toggle_maximize keybind and window-maximize config option 2025-01-10 22:42:41 -06:00
Bryan Lee
5213edfa6c Add keybind action copy_url_to_clipboard 2025-01-08 13:22:33 -08:00
Bryan Lee
140ac93884 Add close_tab keybinding action for macOS
Implement `close_tab` keybinding action to close the current tab and all splits within that tab.
2025-01-08 12:04:40 -08:00
Sabarigirish Manikandan
306c7ea2be close_tab keybind (gtk apprt only) (#4033)
Title. Adds a close_tab keybind that essentially behaves the exact same
as clicking the tab close button on the tab bar.
2025-01-08 19:07:00 +00:00
George Joseph
c127daa552 Fix minimum initial window size
Change the calculation of minimum initial window size so it agrees with
the documented 10x4 cells instead of 640x480 px.

Resolves: #4655
2025-01-06 07:13:51 -07:00
Mitchell Hashimoto
1bcfff3b79 macos: manual send keyUp event for command key 2025-01-04 14:02:16 -08:00
Mitchell Hashimoto
4d103ca16d core: add keyEventIsBinding
This API can be used to determine if the next key event, if given as-is,
would result in a key binding being triggered.
2025-01-04 12:45:15 -08:00
Mitchell Hashimoto
e6399c947a update our default bindings that are performable 2025-01-02 15:54:09 -08:00
Mitchell Hashimoto
95b73f197f Add docs for performable 2025-01-02 15:41:01 -08:00
Ethan Conneely
f38d1585e8 Do nothing if action not performed with flag 2025-01-02 01:14:47 +00:00
Ethan Conneely
46097617b4 copy_to_clipboard return false if not performed 2025-01-02 00:18:05 +00:00
Jeffrey C. Ollie
cf34ffa28e core: fix windows compile regression from #4021 2024-12-31 12:56:18 -06:00
Mitchell Hashimoto
d59a57e133 write_*_file actions default to mode 0600
This commit changes the default filemode for the write actions so that
it is only readable and writable by the user running Ghostty.
2024-12-31 07:16:43 -08:00
Mitchell Hashimoto
d7c5017cd2 surface: don't issue mode 2031 DSR reports when colors are changed by a VT sequence (#3994)
#3965
2024-12-30 21:10:32 -08:00
Bryan Lee
c62f64866c Ensure correct coordinate ordering in selection file write
When writing selected text to file, use `topLeft` and `bottomRight` instead of
`start` and `end` to ensure correct coordinate ordering. This fixes an issue
where selection files could be empty when selecting text in reverse order.

- Use `terminal.Selection.topLeft()` for start coordinate
- Use `terminal.Selection.bottomRight()` for end coordinate
2024-12-31 01:14:56 +08:00
Mitchell Hashimoto
e17bb69645 config: edit opens AppSupport over XDG on macOS, prefers non-empty paths (#4004)
Fixes #3953
Fixes #3284

This fixes two issues. In fixing one issue, the other became apparent so
I fixed both in this one commit.

The first issue is that on macOS, the `open` command should take the
`-t` flag to open text files in a text editor. To do this, the `os.open`
function now takes a type hint that is used to better do the right
thing.

Second, the order of the paths that we attempt to open when editing a
config on macOS is wrong. Our priority when loading configs is well
documented:
https://ghostty.org/docs/config#macos-specific-path-(macos-only). But
open_config does the opposite. This makes it too easy for people to have
configs that are being overridden without them realizing it.

This commit changes the order of the paths to match the documented
order. If neither path exists, we prefer AppSupport.
2024-12-30 08:52:55 -08:00
Mitchell Hashimoto
318641f5a1 surface: handle hyperlinks more reliably (#3903)
We refresh the link hover state in two (generic) cases

1. When the modifiers change
2. When the cursor changes position

Each of these have additional state qualifiers. Modify the qualifiers
such that we refresh links under the following scenarios:

1. Modifiers change
  - Control is pressed (this is handled in the renderer)
  - Mouse reporting is off
    OR
    Mouse reporting is on AND shift is pressed AND we are NOT reporting
    shift to the terminal

2. Cursor changes position
  - Control is pressed (this is handled in the renderer)
  - We previously were over a link
  - The position changed (or we had no previous position)
  - Mouse reporting is off
    OR
    Mouse reporting is on AND shift is pressed AND we are NOT reporting
    shift to the terminal

This fixes a few issues with the previous implementation:

1. If mouse reporting was on and you were over a link, pressing ctrl
   would enable link hover state. If you moved your mouse, you would
   exit that state. The logic in the keyCallback and the
   cursorPosCallback was not the same. Now, they both check for the same
   set of conditions
2. If mouse reporting was off, you could hold control and move the mouse
   to discover links. If mouse reporting was on, holding control + shift
   would not allow you to discover links. You had to be hovering one
   when you pressed the modifiers. Previously, we only refreshed links
   if we *weren't* reporting the mouse event. Now, we refresh links even
   even if we report a mouse event (ie a mouse motion event with the
   shift modifier pressed *will* hover links and also report events)

## Old Behavior

Notice that the state of the hyperlink is erratic in `comlink`. When I
am over it and press ctrl the link is underlined and the url hint in the
lower left shown for one frame, but then the state is dropped.


https://github.com/user-attachments/assets/52d6a8c8-8459-4d67-85eb-5d91f9833771

## New Behavior

State is retained when holding ctrl+shift. And the link only underlines
if I press both ctrl+shift. If I move the mouse around while holding
these keys, I can discover new links.


https://github.com/user-attachments/assets/78fa8e97-eb0c-4618-bd96-fe40d6bc67ce
2024-12-30 08:50:35 -08:00
Mitchell Hashimoto
adcaff7137 config: edit opens AppSupport over XDG on macOS, prefers non-empty paths
Fixes #3953
Fixes #3284

This fixes two issues. In fixing one issue, the other became apparent so
I fixed both in this one commit.

The first issue is that on macOS, the `open` command should take the
`-t` flag to open text files in a text editor. To do this, the `os.open`
function now takes a type hint that is used to better do the right
thing.

Second, the order of the paths that we attempt to open when editing a
config on macOS is wrong. Our priority when loading configs is well documented:
https://ghostty.org/docs/config#macos-specific-path-(macos-only). But
open_config does the opposite. This makes it too easy for people to have
configs that are being overridden without them realizing it.

This commit changes the order of the paths to match the documented
order. If neither path exists, we prefer AppSupport.
2024-12-30 08:43:59 -08:00
moni-dz
4d983a2083 surface: don't issue mode 2031 DSR reports when colors are changed by a VT sequence 2024-12-30 12:33:05 +08:00
Mitchell Hashimoto
5be77ded3a config: add title_report (default false) to configure CSI 21 t 2024-12-29 08:56:53 -08:00
Tim Culverhouse
e24f33ae6b surface: handle hyperlinks more reliably
We refresh the link hover state in two (generic) cases

1. When the modifiers change
2. When the cursor changes position

Each of these have additional state qualifiers. Modify the qualifiers
such that we refresh links under the following scenarios:

1. Modifiers change
  - Control is pressed (this is handled in the renderer)
  - Mouse reporting is off
    OR
    Mouse reporting is on AND shift is pressed AND we are NOT reporting
    shift to the terminal

2. Cursor changes position
  - Control is pressed (this is handled in the renderer)
  - We previously were over a link
  - The position changed (or we had no previous position)
  - Mouse reporting is off
    OR
    Mouse reporting is on AND shift is pressed AND we are NOT reporting
    shift to the terminal

This fixes a few issues with the previous implementation:

1. If mouse reporting was on and you were over a link, pressing ctrl
   would enable link hover state. If you moved your mouse, you would
   exit that state. The logic in the keyCallback and the
   cursorPosCallback was not the same. Now, they both check for the same
   set of conditions
2. If mouse reporting was off, you could hold control and move the mouse
   to discover links. If mouse reporting was on, holding control + shift
   would not allow you to discover links. You had to be hovering one
   when you pressed the modifiers. Previously, we only refreshed links
   if we *weren't* reporting the mouse event. Now, we refresh links even
   even if we report a mouse event (ie a mouse motion event with the
   shift modifier pressed *will* hover links and also report events)
2024-12-29 10:04:06 -06:00
Mohammadi, Erfan
85fc49b22c confirm-close-surface option can be set to always to always require confirmation
Fixes #3648
The confirm-close-surface configuration can now be set to always
ensuring a confirmation dialog is shown before closing a surface, even
if shell integration indicates no running processes.
2024-12-28 19:16:36 -08:00
moni
819b7e066d surface: don't early return when clearing hyperlinks
When outside the viewport, other actions such as scrolling might be happening, and doing an early return when clearing hyperlinks prevents scrolling upwards.

We do not early return so we can process scrolling when it happens.
2024-12-21 04:24:00 +08:00
Mitchell Hashimoto
df97c19a37 macOS: "option-as-alt" defaults to "true" for US keyboard layouts
A common issue for US-centric users of a terminal is that the "option"
key on macOS is not treated as the "alt" key in the terminal.

## Background

macOS does not have an "alt" key, but instead has an "option" key. The "option"
key is used for a variety of purposes, but the troublesome behavior for some
(and expected/desired behavior for others) is that it is used to input special
characters.

For example, on a US standard layout, `option-b` inputs `∫`. This is not
a typically desired character when using a terminal and most users will
instead expect that `option-b` maps to `alt-b` for keybinding purposes
with whatever shell, TUI, editor, etc. they're using.

On non-US layouts, the "option" key is a critical modifier key for
inputting certain characters in the same way "shift" is a critical
modifier key for inputting certain characters on US layouts.

We previously tried to change the default for `macos-option-as-alt`
to `left` (so that the left option key behaves as alt) because I had the
wrong assumption that international users always used the right option
key with terminals or were used to this. But very quickly beta users
with different layouts (such as German, I believe) noted that this is
not the case and broke their idiomatic input behavior. This behavior was
therefore reverted.

## Solution

This confusing behavior happened frequently enough that I decided to
implement the more complex behavior in this commit. The new behavior is
that when a US layout is active, `macos-option-as-alt` defaults to true
if it is unset. When a non-US layout is active, `macos-option-as-alt`
defaults to false if it is unset. This happens live as users change
their keyboard layout.

**An important goal of Ghostty is to have zero-config defaults** that
satisfy the majority of users. Fiddling with configurations is -- for
most -- an annoying task and software that works well enough out of the
box is delightful. Based on surveying beta users, I believe this commit
will result in less configuration for the majority of users.

## Other Terminals

This behavior is unique amongst terminals as far as I know.
Terminal.app, Kitty, iTerm2, Alacritty (I stopped checking there) all
default to the default macOS behavior (option is option and special
characters are inputted).

All of the aforementioned terminals have a setting to change this
behavior, identical to Ghostty (or, Ghostty identical to them perhaps
since they all predate Ghostty).

I couldn't find any history where users requested the behavior of
defaulting this to something else for US based keyboards. That's
interesting since this has come up so frequently during the Ghostty
beta!
2024-12-11 10:27:08 -08:00
Mitchell Hashimoto
43a7dece02 config: title can reload at runtime
Related to #2898
2024-12-08 11:22:15 -08:00
Valentin Shinkarev
e7bfc17318 fix slow scroll in mouseReport 2024-12-01 22:58:46 +03:00
Mitchell Hashimoto
dca3cd7c10 Merge pull request #2788 from ghostty-org/push-rxpmmzxptqwt
surface needs to preserve original config working-directory
2024-11-23 10:05:16 -08:00
Mitchell Hashimoto
2b30186259 surface needs to preserve original config working-directory
Fixes #2785
2024-11-23 09:54:19 -08:00
Mitchell Hashimoto
6658aae21f Merge pull request #2771 from ghostty-org/push-quwzwysosskr
mode 2031 should send updates on any color palette change
2024-11-23 09:53:53 -08:00
Mitchell Hashimoto
cd49015243 App applies conditional state, supports theme setting
The prior light/dark mode awareness work works on surface-level APIs. As
a result, configurations used at the app-level (such as split divider
colors, inactive split opacity, etc.) are not aware of the current theme
configurations and default to the "light" theme.

This commit adds APIs to specify app-level color scheme changes. This
changes the configuration for the app and sets the default conditional
state to use that new theme. This latter point makes it so that future
surfaces use the correct theme on load rather than requiring some apprt
event loop ticks. Some users have already reported a short "flicker" to
load the correct theme, so this should help alleviate that.
2024-11-22 14:08:35 -08:00
Mitchell Hashimoto
1c6adf4065 mode 2031 should send updates on any color palette change
Related #2755

From the mode 2031 spec[1]:

> Send CSI ? 2031 h to the terminal to enable unsolicited DSR (device status
> report) messages for color palette updates and CSI ? 2031 l respectively to
> disable it again.
>
> The sent out DSR looks equivalent to the already above mentioned. This
> notification is not just sent when dark/light mode has been changed by the
> operating system / desktop, but also if the user explicitly changed color
> scheme, e.g. by configuration.

My reading of this paired with the original discussion is that this is
meant to be sent out for anything that could possibly change terminal
colors.

Previous to this commit, we only sent out the DSR when the actual system
light/dark mode changed. This commit changes it to send out the DSR on
any operation that _may_ change the terminal colors.

[1]: https://contour-terminal.org/vt-extensions/color-palette-update-notifications/#example-source-code
2024-11-22 13:14:12 -08:00
Mitchell Hashimoto
a191f3c396 apprt: switch to reload_config action that calls update_config API 2024-11-22 11:52:34 -08:00
Mitchell Hashimoto
fadfb08efe apprt: add config_change action 2024-11-21 10:30:27 -08:00
Mitchell Hashimoto
b7f1eaa145 apprt: action to change conditional state, implement for embedded 2024-11-19 15:36:31 -08:00
Mitchell Hashimoto
7605472922 Balance padding uses the explicit padding value for grid calculations
This fixes window resize not working properly when
`window-padding-balance` is set to true.
2024-11-15 15:16:00 -08:00
Mitchell Hashimoto
bdf3d1cb5f apprt/embedded: fix new size struct 2024-11-14 13:58:15 -08:00
Mitchell Hashimoto
b3b5e15e96 renderer/metal: use new size struct 2024-11-14 13:44:05 -08:00
Mitchell Hashimoto
90c59f2462 termio: change all sizes to the new size type 2024-11-14 13:31:10 -08:00
Mitchell Hashimoto
dcb1ce8377 termio: change resize message to use new size struct 2024-11-14 13:23:24 -08:00
Mitchell Hashimoto
ca8130bec9 core: make surface use only renderer.Size 2024-11-14 13:15:56 -08:00
Mitchell Hashimoto
3ca246ceb9 apprt: support a pwd change action 2024-11-13 12:29:30 -08:00
Mitchell Hashimoto
aed51fd0b0 terminal: PageList rename "page" to "node" everywhere
This is more correct: a pagelist is a linked list of nodes, not pages.
The nodes themselves contain pages but we were previously calling the
nodes "pages" which was confusing, especially as I plan some future
changes to the way pages are stored.
2024-11-07 13:44:39 -08:00
Mitchell Hashimoto
65f1cefb4e config: add "initial-command" config, "-e" sets that
Fixes #2601

It is more expected behavior that `-e` affects only the first window. By
introducing a dedicated configuration we avoid making `-e` too magical:
its simply syntax sugar for setting the "initial-command" configuration.
2024-11-05 16:58:20 -08:00