2094 Commits

Author SHA1 Message Date
Mitchell Hashimoto
bb5246c65d apprt/embedded: validate directory for wd 2023-10-03 22:13:36 -07:00
Mitchell Hashimoto
140afb395f apprt/embedded: supporting setting working directory in config 2023-10-03 17:34:44 -07:00
Mitchell Hashimoto
15e6c07bd9 font/fontconfig: adhere to correct function signature 2023-10-03 09:26:14 -07:00
Mitchell Hashimoto
1127330b3a font/coretext: score discovered fonts 2023-10-03 09:17:41 -07:00
Mitchell Hashimoto
72a80234db Merge pull request #608 from mitchellh/mode-2027
terminal: mode 2027
2023-10-02 09:35:02 -07:00
Mitchell Hashimoto
5f96adb993 terminal: mode 2027 2023-10-02 09:34:43 -07:00
Mitchell Hashimoto
2b28106837 update zig 2023-10-02 08:18:35 -07:00
Mitchell Hashimoto
cec45de842 config: note gtk bug 2023-09-30 21:48:22 -07:00
Mitchell Hashimoto
769e7df675 apprt/gtk: implement default window size 2023-09-30 21:41:17 -07:00
Mitchell Hashimoto
a1a8aeb104 initial window size needs to take into account window chrome 2023-09-30 21:35:50 -07:00
Mitchell Hashimoto
cc8e1cd936 macos: support initial window size 2023-09-30 20:47:31 -07:00
Mitchell Hashimoto
8cb96a28c1 config: increase eval branches for new configs 2023-09-30 20:15:07 -07:00
Mitchell Hashimoto
604eeceb03 apprt/glfw: support window-width, window-height configurations 2023-09-30 20:10:08 -07:00
Mitchell Hashimoto
3c0700c6b0 os: launchFromDesktop works even if the artifact is a lib
Fixes #598
2023-09-30 19:09:52 -07:00
Mitchell Hashimoto
abf43ddfcc apprt/gtk: change default cursor to text 2023-09-30 15:46:03 -07:00
Nathan Fisher
614a9775c6 Set the mouse pointer to "text" (an I-beam) when it is over the gl_area
which the terminal embeds into for the Gtk interface. Addresses https://github.com/mitchellh/ghostty/issues/596
2023-09-30 18:26:40 -04:00
Mitchell Hashimoto
6c69f0ef63 apprt/gtk: gtk-single-instance defaults to true only if desktop env
Fixes #473

A new config value for `gtk-single-instance = desktop` is now valid.
This value uses GTK single instance mode only if it detects Ghostty was
launched from a desktop environment (i.e. clicking on the icon) through
the `.desktop` Freedesktop file. Otherwise, it disables single instance.

This enables Ghostty to work well with the CLI and accept all the
typical CLI flags. It will make Ghostty launch slower from the CLI but I
think this is an acceptable tradeoff.
2023-09-30 08:46:39 -07:00
Mitchell Hashimoto
8f82f8cad6 apprt/embedded: adapt to new binding API 2023-09-29 22:13:34 -07:00
Mitchell Hashimoto
56b0cb51d5 apprt/gtk: previous_tab/next_tab action do not consume if there are no tabs 2023-09-29 22:12:38 -07:00
Mitchell Hashimoto
a85c508892 apprt/gtk: add ctrl+page-up/down as prev/next tab 2023-09-29 22:04:30 -07:00
Mitchell Hashimoto
659fa2cc66 config: keybinding clone must clone all members 2023-09-29 22:04:17 -07:00
Mitchell Hashimoto
abc3838546 termio: clear screen always sends form feed (0x0C)
Fixes #555
2023-09-29 21:42:58 -07:00
Mitchell Hashimoto
3569073ff5 core: handle unconsumed bindings in key callbacks 2023-09-29 21:37:30 -07:00
Mitchell Hashimoto
47ee1e7355 input: Binding string can be unconsumed with "unconsumed:" prefix 2023-09-29 21:34:23 -07:00
Mitchell Hashimoto
9d0e7ab138 input: binding set can track unconsumed triggers 2023-09-29 20:18:41 -07:00
Mitchell Hashimoto
f9962a04ef recomment line 2023-09-29 20:01:26 -07:00
Mitchell Hashimoto
ecb1d19890 input: fix regression with ascii mapping to a keypad key 2023-09-29 20:00:50 -07:00
Mitchell Hashimoto
d03083c7f5 apprt/gtk: default working-directory to home if launched from desktop
Fixes #573
2023-09-29 15:52:45 -07:00
Tim Culverhouse
488e6670c2 selection: only clear when keypress has utf8
Currently, the selection on a surface is cleared on any keypress that
generates a control sequence. For applications that enable kitty, this
can mean that every keypress clears the current selection thereby making
it impossible to copy text, since it will be cleared as soon as Control
is pressed. This can be very confusing to terminal users: some
applications I can shift+highlight and copy+paste, some I can't - and
unless I know the implementation of the application I won't know
why...very frustrating.

Only clear the selection when there is printable text, otherwise retain
the selection. From my testing, this makes text selection feel the same
between applications using kitty keyboard and applications that don't.
2023-09-29 16:07:21 -05:00
Mitchell Hashimoto
d878d16779 os: unset lang completely setlocale fails 2023-09-29 13:11:07 -07:00
Mitchell Hashimoto
38a7c2270b os: we need to copy the old lang pointer before we unsetenv 2023-09-29 12:56:43 -07:00
Mitchell Hashimoto
1f5518cd83 Merge pull request #587 from mitchellh/patrickf/document-font-config
Improve docs on font configuration
2023-09-29 11:57:44 -07:00
Mitchell Hashimoto
7bbe669641 Merge pull request #578 from rockorager/dev
Kitty keyboard improvements
2023-09-29 11:56:34 -07:00
Mitchell Hashimoto
a2e2889f2b input: make Key ascii functions comptime-generated 2023-09-29 11:54:05 -07:00
Patrick Fong
741606a7ab fix grammar 2023-09-29 11:44:32 -07:00
Patrick Fong
d832507644 improve docs on font config 2023-09-29 11:42:49 -07:00
Tim Culverhouse
11cb6824cd input: don't ESC prefix non-ascii characters
User input withe Alt modifier is typically ESC prefixed. Escape
prefixing a non-ascii character can cause bugs in some applications. For
example in bash, emitting an Alt+ф allows the user to backspace one
character into the prompt. This can be repeated multiple times.

When a character is outside the ASCII range (exclusive of 0x7F, this is
handled as a control sequence), print the character as is, with no
prefix.
2023-09-29 08:35:21 -07:00
Tim Culverhouse
fb649e689d input(kitty): fix reporting of alternate keys
Fix reporting of alternate keys when using the kitty protocol. Alternate
keyboard layouts were failing to report the "base layout" key. This
implementation now matches kitty's output 1:1, and has some added unit
tests for cyrillic characters.

This also fixes a bug where a caps_lock modified key would report the
shifted key as well. The protocol explicitly requires that shifted keys
are only reported if the shift modifier is true.
2023-09-29 06:37:08 -05:00
Tim Culverhouse
4f2d67d8f3 gtk(input): fix value used for lowercase lower_unicode
When converting keyval to the unshifted version, gdk_keyval_to_lower
returns a keyval type, not a unicode value. Convert this to unicode
before assigning to keyval_unicode_unshifted.

This fixes a bug where the incorrect keycode is sent in alternate
layouts with kitty keyboard on linux.
2023-09-29 06:36:03 -05:00
Mitchell Hashimoto
6fd082ed63 terminal: scroll region scroll up copied the wrong length of data
Fixes #315

This function has various cases that can be hit depending on the state
of the underlying circular buffer. It is a very well tested function but
this particular branch wasn't tested and unsurprisingly turns out there
is a bug in it.

Consider the following circular buffer state representing a terminal
screen with 1 column, 5 rows. Assume the circular buffer representing
this screen is such that `head == tail` and `head = 4` (zero-indexed,
full buffer size is 5). The head and tail are shown with an arrow below.

┌───────────────────────────────────────────────────────────────┐
│                               B                               │
├───────────────────────────────────────────────────────────────┤
│                               C                               │
├───────────────────────────────────────────────────────────────┤
│                               D                               │
├───────────────────────────────────────────────────────────────┤
│                               E                               │
├───────────────────────────────────────────────────────────────┤ ◀───  Head
│                               A                               │       Tail
└───────────────────────────────────────────────────────────────┘

The screen contents are "A B C D E" with each character on a new line.

Next, we set a scroll region from y=0 to y=3 (len=4). The scroll region
contents are "A B C D". Next, we issue a "delete lines" command with
n=2 (`CSI 2 M`) while the cursor is at the top-left corner. The delete
lines command deletes the given number of lines (n=2 in this case) and
shifts the remaining lines up. It does this only within the context
of the scroll region. Therefore, for `CSI 2 M` we would expect our
screen to become "C D _ _ E" (A, B are deleted, C, D shift up, and
E is untouched because its outside of the scroll region).

When executing this operation, we request the memory regions containing
the scroll region. This results in two pointers and lengths. For our
circular buffer state, we get the following:

┌───────────────────────────────────────────────────────────────┐ ◀──── ptr0
│                               A                               │
└───────────────────────────────────────────────────────────────┘

┌───────────────────────────────────────────────────────────────┐ ◀──── ptr1
│                               B                               │
├───────────────────────────────────────────────────────────────┤
│                               C                               │
├───────────────────────────────────────────────────────────────┤
│                               D                               │
└───────────────────────────────────────────────────────────────┘

We get two pointers because our circular buffer wraps around the bottom.
The diagram above shows them in top/bottom order not in memory order
(The value of `ptr0 > ptr1` but it doesn't matter for the bug).

The way the math works is as follows:

  1. We calculate the number of lines we need to shift up. That
     value is `height - n`. Our height is 4 (scroll region height) and
     our n is 2 (`CSI 2 M`), so we know we're shifting up 2 lines.
     Let's call this `shift_lines`.

  2. Our start copy offset is `n` because the lines we are retaining
     are exactly after the `n` we're deleting (i.e. we're deleting 2
     lines so the start of the lines we're shifting up is the 3rd line).
     Let's call this `start_offset`.

  3. We realize that our start offset is greater than the size of ptr0,
     so we must be copy from ptr1 into ptr0. Further, we know our start
     offset into ptr1 must be `start_offset - ptr0.len`.
     Let's call this `start_offset_ptr1 = 1`.

  4. Copy `ptr1[start_offset_ptr1]` to `ptr0`. We copy up to
     `shift_lines` amount. `shift_lines` is 2 but `ptr0.len` is only
     `1`. So, we actually copy `@min(shift_lines, ptr0.len)` and have
     `1` line remaining.
     Let's call that `remaining = 1`.

  5. Copy `remaining` from `ptr1[ptr0.len]` to `ptr1`.

  6. Next we need to zero our remaining lines. Our slices only contain
     our scroll region so we know we can zero the memory from
     `ptr1[remaining]` to the end of `ptr1`. We know this because step 5
     only copied `remaining` bytes.

The end result looks like this:

┌───────────────────────────────────────────────────────────────┐ ◀──── ptr[0]
│                               C                               │
└───────────────────────────────────────────────────────────────┘

┌───────────────────────────────────────────────────────────────┐ ◀──── ptr[1]
│                               D                               │
├───────────────────────────────────────────────────────────────┤
│                                                               │
├───────────────────────────────────────────────────────────────┤
│                                                               │
└───────────────────────────────────────────────────────────────┘

The bug was in step 6. We were incorrectly zeroing from `start_offset_ptr1`
instead of `remaining`. This was just a simple typo. The results are
devastating, but only under the exactly correct circumstances (those
in this commit message). In that scenario, the bug produced the
following:

┌───────────────────────────────────────────────────────────────┐ ◀────────── ptr[0]
│                               C                               │
└───────────────────────────────────────────────────────────────┘

┌───────────────────────────────────────────────────────────────┐ ◀────────── ptr[1]
│                               D                               │
├───────────────────────────────────────────────────────────────┤
│                               C                               │
├───────────────────────────────────────────────────────────────┤
│                                                               │
└───────────────────────────────────────────────────────────────┘

Notice the incorrect "C" that remains and is not zeroed.

This example showed a scenario with 1 column and leaving only 1 line out
of the scroll region. The real bug in #315 would often mistakingly leave
multiple lines in the scroll region. The effect was that scrolling
produced garbage lines because you'd "scroll" and part of what should've
scrolled would remain.

This garbage state was only in the terminal screen state, so it didn't
impact actual programs running or their data (i.e. vim). But, it made
the program unusable.
2023-09-28 21:10:37 -07:00
Nathan Youngman
73331887fe fabs builtin was renamed
https://github.com/ziglang/zig/pull/17248

I just tried installing from source and ran into the error:

> error: invalid builtin function: '@fabs'
2023-09-28 15:29:08 -07:00
Mitchell Hashimoto
28b7782bbe core: do not scroll viewport if mouse reporting is requested
Fixes #570
2023-09-28 09:50:44 -07:00
Mitchell Hashimoto
685495c896 apprt/gtk: make wide-style gtk tabs configurable 2023-09-28 08:54:15 -07:00
Tim Culverhouse
d0c673cdfc terminfo: use 'xterm-ghostty' as primary name
Use "xterm-ghostty" as the primary terminfo name. This is a hack on a
hack...we use "xterm-ghostty" to prevent vim from breaking, and when we
do this as the default we break tcell-based applications (lazygit, aerc,
etc). tcell has a bug where the primary terminfo name must be the
value of TERM. https://github.com/gdamore/tcell/pull/639 fixes the issue
but is not merged yet.

Fixes: 779186ad ("config: add term config option")
2023-09-28 10:00:37 -05:00
Tim Culverhouse
c540d18095 config: default TERM to xterm-ghostty
Default the TERM value to "xterm-ghostty" to prevent breaking vim.
Consider changing back to ghostty in the future
2023-09-28 09:45:57 -05:00
Tim Culverhouse
5e473ebdb0 terminfo: add additional entries, fix smkx/rmkx
Add entries for secondary device attributes, XTVERSION.
2023-09-28 06:57:00 -05:00
Mitchell Hashimoto
fa56d6325e Merge pull request #569 from nfisher1226/expanded_tabs
(Gtk) Set tab labels to fill the available space, so that they will
2023-09-27 21:57:21 -07:00
Mitchell Hashimoto
0529c8bc28 terminfo: increase buffer size for test 2023-09-27 21:56:55 -07:00
Nathan Fisher
dca0ddb7e1 (Gtk) Set tab labels to fill the available space, so that they will
divide up the avialable horizontal area instead of leaving a large
empty space in the tab bar.
2023-09-28 00:10:07 -04:00
Tim Culverhouse
25710dfa6d terminfo: add mouse entries, correct kmouse
Add entries for XM and xm, these tell certain applications how to enable
mouse and the format of response they will receive.

Fix 'kmous' entry to match standard terminfo files.
2023-09-27 21:42:13 -05:00