Skip to content

Commit

Permalink
add array support, circling buffer section
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed May 15, 2020
1 parent 0ef3f85 commit e895bea
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions doc/specs/#980 - SnapOnOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ Typical Unix terminals work differently. Rather than disabling the output, they

## Solution Design

`snapOnOutput` will be a profile-level `ICoreSettings` setting of type enum. It can be set to the following values:
`SnapOnOutput` will be a profile-level `ICoreSettings` setting of type enum or enum array. It can be set to one or multiple of the following values:
- `never`: new output does not cause the viewport to update to the bottom of the scroll region
- `noSelection`: (**default**) new output causes the viewport to update to the bottom of the scroll region **IF** no selection is active
- `atBottom`: new output causes the viewport to update **IF** the viewport is already at the virtual bottom
- `always`: new output causes the viewport to update to the bottom of the scroll region

The `TerminalCore` is responsible for moving the viewport on a scroll event. All of the logic for this feature should be handled here.

A new private enum `_snapOnOutput` will be introduced for each of the possible settings values. The `_NotifyScrollEvent()` calls (and nearby code) will be surrounded by conditional checks for the enums above.

`_snapOnOutput` can then be used to determine if the viewport should update given a specific situation.
A new private enum array `_snapOnOutput` will be introduced to save which of these settings are included. The `_NotifyScrollEvent()` calls (and nearby code) will be surrounded by conditional checks for the enums above. This allows it to be used to determine if the viewport should update given a specific situation.

## UI/UX Design

The `snapOnOutput` setting is done at a profile-level to be near `snapOnInput`. Additionally, the `never` value seems more valuable when the user can dedicate a specific task to the profile. Such a scenario would be a shell that frequently generates new output (i.e.: a live-generating log), but the user is not necessarily interested in what the latest output is.

The default `snapOnOutput` value will be `[ "noSelection", "atBottom" ]`.

## Capabilities

### Accessibility

N/A
The `UiaRenderer` exposes new content that is rendered to the screen upon a scroll. No additional changes are necessary here.

### Security

Expand All @@ -63,20 +63,28 @@ N/A

## Potential Issues

### Circling the buffer
If the text buffer fills up, the text buffer begins 'circling'. This means that new output shifts lines of the buffer up to make space. In a case like this, if `snapOnOutput` is set to `never`, the viewport should actually scroll up to keep the same content on the viewport.

In the event that the buffer is circling and the viewport has been moved to the top of the buffer, that content of the buffer is now lost (as the 'Infinite Scrollback' feature does not exist or is disabled). At that point, the viewport will remain at the top of the buffer and the new output will push old output out of the buffer.

### Infinite Scrollback
See **Future considerations** > **Infinite Scrollback**.

## Future considerations

### Extensibility
The introduction of `std::function<bool(void)> _snapOnOutput` allows for this feature to be enabled/disabled in more complex scenarios. A potential extension would be to introduce a new UI element or keybinding to toggle this feature.
The introduction of `enum SnapOnOutput` allows for this feature to be enabled/disabled in more complex scenarios. A potential extension would be to introduce a new UI element or keybinding to toggle this feature.

Another would be to introduce a more complex boolean function dependent on the state of the app or the contents of the new output. Consider the output from a large testing suite. A user could create an extension that snaps on output for failing tests or when the testing has concluded.
Another would be to introduce additional accepted values. Consider the output from a large testing suite. A user could create an extension that snaps on output for failing tests or when the testing has concluded.

### Infinite Scrollback
At the time of introducing this, the infinite scrollback feature is not supported. This means that the buffer saves the history up to the `historySize` amount of lines. When infinite scrollback is introduced, the buffer needs to change its own contents to allow the user to scroll beyond the `historySize`. With infinite scrollback enabled and the mutable viewport **NOT** snapping to new output, the `TerminalCore` needs to keep track of...
- what contents are currently visible to the user (in the current location of the mutable viewport)
- how to respond to a user's action of changing the location of the mutable viewport (i.e.: snapOnInput, scroll up/down)

The `TermControl`'s scrollbar will abstract this issue away. As the viewport moves, really we're just presenting content that was saved to the text buffer.

### Private Mode Escape Sequences
There are a couple of private mode escape sequences that some terminals use to control this kind of thing. Mode 1010, for example, snaps the viewport to the bottom on output, whereas Mode 1011 spans the viewport to the bottom on a keypress.

Expand Down

1 comment on commit e895bea

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New misspellings found, please review:

  • carlos
  • zamora
To accept these changes, run the following commands
remove_obsolete_words=$(mktemp)
echo '#!/usr/bin/perl -ni
my $re=join "|", qw('"
bitfield
Emojis
HREF
memcpying
OUTPATHROOT
storageitems
textblock
usr
vpack
"');
next if /^($re)(?:$| .*)/;
print;' > $remove_obsolete_words
chmod +x $remove_obsolete_words
for file in .github/actions/spell-check/whitelist/alphabet.txt .github/actions/spell-check/whitelist/web.txt .github/actions/spell-check/whitelist/whitelist.txt; do $remove_obsolete_words $file; done
rm $remove_obsolete_words
(
echo "
carlos
zamora
"
) | sort -u -f | perl -ne 'next unless /./; print' > new_whitelist.txt && mv new_whitelist.txt '.github/actions/spell-check/whitelist/e895bea54ce03886053c4ac2911df66a89ae6278.txt'
✏️ Contributor please read this
  • If the items listed above are names, please add them to .github/actions/spell-check/dictionary/names.txt.
  • If they're APIs, you can add them to a file in .github/actions/spell-check/dictionary/.
  • If they're just things you're using, please add them to an appropriate file in .github/actions/spell-check/whitelist/.
  • If you need to use a specific token in one place and it shouldn't generally be used, you can
    add an item in an appropriate file in .github/actions/spell-check/patterns/.

See the README.md in each directory for more information.

⚠️ Reviewers

At present, the action that triggered this message will not show its ❌ in this PR unless the branch is within this repository.
Thus, you should make sure that this comment has been addressed before encouraging the merge bot to merge this PR.

Please sign in to comment.