515 Commits

Author SHA1 Message Date
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
Mitchell Hashimoto
b56cb7038a core: only do cursor click to move without a mouse selection 2024-10-31 09:34:46 -07:00
Mitchell Hashimoto
c97c0858be macos: rectangle select only requires option + drag
Fixes #2537

This matches Terminal.app. iTerm2 requires cmd+option (our old
behavior). Kitty doesn't seem to support rectangle select or I couldn't
figure out how to make it work. WezTerm matches Terminal.app too.
Outside of terminal emulators, this is also the rectangular select
binding for neovim.
2024-10-30 20:47:24 -04:00
Mitchell Hashimoto
569d887de8 core: show mouse whenever focus state changes on surface
Related to #2525
2024-10-30 18:03:16 -04:00
Mitchell Hashimoto
1065359b9a apprt: rename set_bg/fg to "color_change" to report all color changes 2024-10-30 16:33:18 -04:00
CJ van den Berg
a2a1d93d5c apprt: propagate OSC10/11 (set term fore/background color) through to apprt
This is to allow the running apprt to set the UI theme to match the
terminal application coloring.
2024-10-30 17:35:34 +01:00
Jeffrey C. Ollie
348287c620 core: add a .txt extenstion to scrollback file
This should make it easier for open or xdg-open to find an appropriate
application to open the scrollback file with.
2024-10-27 16:03:18 -05:00
Mitchell Hashimoto
de5ec5d83e macos: make move_tab work 2024-10-25 11:54:07 -07:00
axdank
520dda65cb apply review changes 2024-10-25 08:07:11 -03:00
axdank
465d60def8 gui: add move_current_tab action 2024-10-24 00:01:54 -03:00
Tim Culverhouse
4f1cee8eb9 fix: report correct screen pixel size
Mode 2048 and CSI 14 t are size report control sequences which contain
the text area size in pixels. The text area is defined to be the extents
of the grid (rows and columns). Ghostty calculates the available size
for the text area by setting the available padding, and then filling as
much of the remaining space as possible. However, if there are remainder
pixels these are still reported as part of the text area size.

Pass the cell_size geometry through so that we can always report the
correct value: columns * cell width and rows * cell height.
2024-10-18 22:29:52 -05:00
Mitchell Hashimoto
3f1d6eb301 expand explicit error set usage
This continues our work to improve the amount of explicit error sets
we use in the codebase. Explicit error sets make it easier to understand
possible failure scenarios, allow us to use exhaustive matching, create
compiler errors if errors are unexpectedly added or removed, etc.

The goal eventually is 100% coverage but we're not even close yet.
This just moves us a little closer.
2024-10-18 08:10:41 -07:00
Qwerasd
de16541bca macOS: fix quicklook position
Account for padding and properly calculate text baseline, since that is
the position that the NSView `showDefinition` method ultimately needs.
2024-10-15 15:40:15 -04:00
Mitchell Hashimoto
745079cbb5 core: simplify scroll math, fix horizontal scroll direction on macOS
This simplifies the math for calculating scroll vectors based on mouse
scroll events. This was done to fix inverted horizontal scrolling on
macOS with natural scrolling enabled. Many assertions were added for
assumptions and our preconditions are clearly documented.

The preconditions are:

  * Apprt scroll offsets are negative down/left, positive up/right
  * Terminal vertical scroll is postive down, negative up (opposite
    since scroll for a terminal means how many rows to move down).
  * `Surface.scrollCallback` is always call with an apprt offset.
  * Apprt is responsible for implementing natural scrolling. Surface
    always assumes negative is down/left.
2024-10-10 16:24:16 -07:00
Mitchell Hashimoto
e90dec04be core: support mouse button 6/7 for mouse reports
Fixes #2423

This corresponds to horizontal scroll on macOS and likely other mice.
2024-10-09 11:24:36 -07:00
Mitchell Hashimoto
4ffb1c8cf9 core: modifier-only keys do not reset pending key sequences
This allows nested key sequences to be used such as `ctrl+a>ctrl+b>c`.
2024-10-09 09:46:16 -07:00
Mitchell Hashimoto
5c1ffbb642 apprt: implement key_sequence action 2024-10-08 21:55:00 -07:00
Mitchell Hashimoto
8d7367fa64 input: return a K/V entry for the binding set get 2024-10-08 06:29:54 -10:00
Leah Amelia Chen
fbc621a7d8 gtk: implement splitting leftwards and upwards 2024-10-07 18:19:27 -07:00
Mitchell Hashimoto
65c907ddab core: negative x/y for cursor position indicates mouse exited viewport 2024-10-06 15:20:17 -10:00
Mitchell Hashimoto
520c21d665 core: refresh hyperlink state without hacky cursorPosCallback
This fixes a longstanding piece of tech debt which caused all sorts of
bugs. Instead of trying to jam cursorPosCallback into a modsChanged
event we bring out the link refreshing into a dedicated method that is
shared.
2024-10-05 15:31:36 -10:00
theprimeagen
f0591b4afb fix: scrolling with fraction produces different lines count due to @floor vs @trunc (-1 vs 1) 2024-10-03 11:19:41 -06:00
Mitchell Hashimoto
1d09cdb382 Mouse movement events are sent with shift until a button is pressed
Ghostty was previously treating shift as a way to always stop mouse
reporting. That's true for mouse button events, but not for mouse
movement events. For mouse movement events, shift should be treated as
a modifier until a button (any mouse button) is pressed. Once it is
pressed, we pause mouse reporting until all buttons are released.

Found by @ldemailly. This matches the behavior of Kitty, Alacritty,
WezTerm, and xterm.
2024-10-02 17:08:37 -07:00
Mitchell Hashimoto
be3ae56bc8 font: add stylistic variants for built-in font, fix naming convention
Fixes #2364

This adds the bold, italic, and bold italic variants of JB Mono so it is
built-in. This also fixes up the naming convention for the embedded font
files across tests and removes redundant embedded font files.
2024-10-02 15:17:18 -07:00
Mitchell Hashimoto
66f2d75ddd Change copy-on-select behavior to be more idiomatic for Linux
Fixes #2345

The new docs for `copy-on-select`:

Whether to automatically copy selected text to the clipboard. `true`
will prefer to copy to the selection clipboard if supported by the
OS, otherwise it will copy to the system clipboard.

The value `clipboard` will always copy text to the system clipboard
(for supported systems) as well as the system clipboard. This is sometimes
a preferred behavior on Linux.

Middle-click paste will always use the selection clipboard on Linux
and the system clipboard on macOS. Middle-click paste is always enabled
even if this is `false`.

The default value is true on Linux and false on macOS. macOS copy on
select behavior is not typical for applications so it is disabled by
default. On Linux, this is a standard behavior so it is enabled by
default.
2024-10-01 20:38:27 -07:00
Mitchell Hashimoto
6d68db3bdc core: only extend selection on mouse if click interval is exceeded
Previously, once we had one click registered, shift+click would always
go into selection extend mode. This is not the behavior we want, since
we want shift+double/triple click to work in alternate screens.

This commit changes the behavior so that we only extend the selection
after the multi-click interval has passed.

I see a lot of opportunity to improve this whole callback much more but
I don't want to risk introducing new bugs since this is a hard to test
area, so I'm going to leave it for now.
2024-09-27 14:21:27 -07:00
Mitchell Hashimoto
f6f91b5eb5 core: fix invalid action call that wasn't setting our metrics properly
Fixes #2308
2024-09-27 12:28:15 -07:00
Paul Berg
f1474c220d bind: add toggle_tab_overview binding 2024-09-27 10:13:05 -07:00
Mitchell Hashimoto
4ae20212bf libghostty: unified action dispatch
First, this commit modifies libghostty to use a single unified action
dispatch system based on a tagged union versus the one-off callback
system that was previously in place. This change simplifies the code on
both the core and consumer sides of the library. Importantly, as we
introduce new actions, we can now maintain ABI compatibility so long as
our union size does not change (something I don't promise yet).

Second, this moves a lot more of the functions call on a surface into
the action system. This affects all apprts and continues the previous
work of introducing a more unified API for optional surface features.
2024-09-26 22:00:11 -07:00
Mitchell Hashimoto
4cc4eb5ed0 core: remove more hasdecls 2024-09-26 14:21:06 -07:00
Mitchell Hashimoto
e29918ebb8 core: more actions 2024-09-26 10:20:44 -07:00
Mitchell Hashimoto
9202cba1f5 core: many more actions 2024-09-26 10:05:10 -07:00
Mitchell Hashimoto
1e010b8e08 core: more actions 2024-09-26 09:37:31 -07:00
Mitchell Hashimoto
26cba70b69 core: no need for hasTabs apprt function 2024-09-26 08:34:20 -07:00
Mitchell Hashimoto
02d7e766e1 core: move password input into action enum 2024-09-25 11:43:48 -07:00
Mitchell Hashimoto
1b31663865 apprt/embedded: new_window can be called without a parent 2024-09-24 18:33:10 -07:00
Mitchell Hashimoto
1ad904478d Tap events, core API to handle global keybinds 2024-09-24 16:29:02 -07:00
Mitchell Hashimoto
17caeb5fac core: "all" bindings work 2024-09-23 19:21:23 -07:00
Mitchell Hashimoto
7f8c1a37ff core: handle app bindings in the App struct 2024-09-23 19:08:23 -07:00
Mitchell Hashimoto
66143a33ef input: move flags to a packed struct 2024-09-23 14:03:53 -07:00
Mitchell Hashimoto
261ce00552 apprt/macos,gtk: unfocused splits now highlight hovered links
Fixes #1547

The core change to make this work is to make the cursor position
callback support taking updated modifiers. On both macOS and GTK, cursor
position events also provide the pressed modifiers so we can pass those
in.
2024-09-21 15:16:14 -07:00
Mitchell Hashimoto
1ed1c73c1a macos: enable secure input on password input 2024-09-19 16:38:32 -07:00
Mitchell Hashimoto
c0e0eff468 core: add toggle_secure_input keybinding 2024-09-19 10:20:30 -07:00
Mitchell Hashimoto
e3d528cf0b termio: use surface messages to trigger password input state 2024-09-18 21:14:05 -07:00
Mitchell Hashimoto
e8bbc987e0 termio: stop the termios poller when not focused 2024-09-18 11:56:07 -07:00
Jeffrey C. Ollie
5f759a19d1 GTK: Fix clicking on desktop notifications
Currently, clicking on a desktop notification will bring Ghostty
to the foreground, but it won't necessarily bring the right window
to the top and it won't switch tabs or change the focus on splits.

With this patch, clicking on a desktop notification will raise the
correct window, change to the correct tab, and focus on the correct
split that send the original desktop notification.
2024-09-13 13:37:38 -07:00
Jeffrey C. Ollie
f1473a1464 fix: Surface.selectionString should return sentinel slice
The underlying API call returns a sentinel slice so selectionString
should do the same or there are problems later trying to free the
allocated memory.
2024-09-10 17:22:29 -05:00
Gregory Anders
df06697899 termio: send initial focus reports
When the focus reporting mode (1004) is enabled, send the current focus
state. This allows applications to track their own focus state without
first having to wait for a focus event (or query
it by sending a DECSET followed by a DECRST).

Ghostty's focus state is stored only in the renderer, where the termio
thread cannot access it. We duplicate the focus state tracking in the
Terminal struct with the addition of a new (1-bit) flag. We duplicate
the state because the renderer uses the focus state for its own purposes
(in particular, the Metal renderer uses the focus state to manage
its DisplayLink), and synchronizing access to the shared terminal state
is more cumbersome than simply tracking the focus state in the renderer
in addition to the terminal.
2024-09-04 22:13:52 -05:00
Mitchell Hashimoto
8f5eea6bf8 core: set crash state in surface in various places 2024-09-02 10:30:09 -07:00