Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write_scrollback_file doesn't include what's on the current screen #3496

Closed
Tenzer opened this issue Dec 27, 2024 · 6 comments
Closed

write_scrollback_file doesn't include what's on the current screen #3496

Tenzer opened this issue Dec 27, 2024 · 6 comments

Comments

@Tenzer
Copy link

Tenzer commented Dec 27, 2024

First off, great work on the achievement of this project!

The write_scrollback_file action was suggested in #189 (comment) to be an alternative to the currently missing scrollback search functionality.

When testing this out, I however noticed it's only contents of the scrollback which is outside of the current screen which get written to the file, which means - if you want to search through the scrollback - you will only be able to search through the lines which are not visible on the screen.

Is this intended? Would it not be better to output everything in the scrollback, including what is visible on the current screen?

I can't think of a use case where you'd only want the contents that aren't visible on the screen to be written in the file.

As a quick way of testing this, you can open a new tab, enter for i in $(seq 1 100); do echo $i; done to print out numbered lines, and then perform the write_scrollback_file action by pressing super + shift + j and notice it doesn't include all the lines outputted from the loop.

@mitchellh
Copy link
Contributor

write_screen_file is what you want. write_scrollback_file only writes the scrollback (not the active screen)

@Tenzer
Copy link
Author

Tenzer commented Dec 27, 2024

Sorry! Right after creating this, I noticed the write_screen_file (link) action is available which does include the contents of the current screen.

@jcollie
Copy link
Collaborator

jcollie commented Dec 28, 2024

FWIW, write_screen_file and write_scrollback_file are absolutely awful names for these operations given what they do. I think that we should re-open this issue as a springboard to rename them and to change the default keybinding.

@mitchellh
Copy link
Contributor

This is the terminology we use internally:

/// The possible reference locations for a point. When someone says "(42, 80)" in the context of a terminal, that could mean multiple
/// things: it is in the current visible viewport? the current active
/// area of the screen where the cursor is? the entire scrollback history?
/// etc. This tag is used to differentiate those cases.
pub const Tag = enum {
/// Top-left is part of the active area where a running program can
/// jump the cursor and make changes. The active area is the "editable"
/// part of the screen.
///
/// The bottom-right of the active tag differs from all other tags
/// because it includes the full height (rows) of the screen, including
/// rows that may not be written yet. This is required because the active
/// area is fully "addressable" by the running program (see below) whereas
/// the other tags are used primarily for reading/modifying past-written
/// data so they can't address unwritten rows.
///
/// Note for those less familiar with terminal functionality: there
/// are escape sequences to move the cursor to any position on
/// the screen, but it is limited to the size of the viewport and
/// the bottommost part of the screen. Terminal programs can't --
/// with sequences at the time of writing this comment -- modify
/// anything in the scrollback, visible viewport (if it differs
/// from the active area), etc.
active,
/// Top-left is the visible viewport. This means that if the user
/// has scrolled in any direction, top-left changes. The bottom-right
/// is the last written row from the top-left.
viewport,
/// Top-left is the furthest back in the scrollback history
/// supported by the screen and the bottom-right is the bottom-right
/// of the last written row. Note this last point is important: the
/// bottom right is NOT necessarily the same as "active" because
/// "active" always allows referencing the full rows tall of the
/// screen whereas "screen" only contains written rows.
screen,
/// The top-left is the same as "screen" but the bottom-right is
/// the line just before the top of "active". This contains only
/// the scrollback history.
history,
};

@00-kat
Copy link
Contributor

00-kat commented Dec 28, 2024

This is the terminology we use internally:

In my opinion, expecting users to guess that it's internal terminology is not a good idea.

(I also opened a discussion; would it be a good idea to use that discussion instead of this issue instead?)

@mitchellh
Copy link
Contributor

I’m not trying to suggest it. I’m just posting it as information.

mitchellh added a commit that referenced this issue Jan 22, 2025
…creen_file`) (#5285)

The current default keybinding on `Ctrl-Shift-J`/`Cmd-Shift-J` utilize
[`write_scrollback_file`](https://ghostty.org/docs/config/keybind/reference#write_scrollback_file)
which only captures text that's scrolled off-screen. This can be
confusing, as I would expect it to capture everything on and off-screen.

Per the docs,
[`write_screen_file`](https://ghostty.org/docs/config/keybind/reference#write_screen_file)
is the "Same as `write_scrollback_file` but writes the full screen
contents" which is perfect to solve this problem and aligns exactly with
the expected behavior.

This change addresses the friction that people have reported in the
discussions below and specifically coming from the [search scrollback
feature discussion](#189),
where `Ctrl-Shift-J`/`Cmd-Shift-J` is one of the interim decent
workarounds but then you also have to figure out the extra intricacy to
use `write_screen_file` instead of `write_scrollback_file`.

Previous discussions:

 - #3652
 - #3496
 - #4911
 - #4390
-
#2363 (comment)
-
#189 (comment)
 - #2040
 
### Workaround

Before this PR is merged, you can achieve the same result by updating
your Ghostty config:

`.config/ghostty`
```sh
# So we have more scrollback history (the size of the scrollback buffer in bytes)
scrollback-limit = 100000000

# The default keybindings use `write_scrollback_file` but that only includes what is
# offscreen. `write_screen_file` includes what's on screen and offscreen.
keybind = ctrl+shift+j=write_screen_file:paste
keybind = ctrl+shift+alt+j=write_screen_file:open
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants