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

Add support for setting prompt marks via OSC 133 #5860

Closed
wants to merge 1 commit into from

Conversation

kchibisov
Copy link
Member

Adds support for setting prompt marks with OSC 133 ; A ST. While
there're other markers for prompt FTCS_PROMPT (A parameter) is
likely the most widely used and useful one.

Fixes #5850.

@kchibisov
Copy link
Member Author

@perfbot

@perfbot
Copy link

perfbot commented Feb 6, 2022

results

Copy link
Member

@chrisduerr chrisduerr left a comment

Choose a reason for hiding this comment

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

You mentioned on IRC that a Vec might be the best option. Have you tried alternative implementations or is this the first attempt?

@kchibisov
Copy link
Member Author

You mentioned on IRC that a Vec might be the best option. Have you tried alternative implementations or is this the first attempt?

I've tried and I don't like it, since it's more code and you have to put it on a grid into scrolling part.

@chrisduerr
Copy link
Member

I've tried and I don't like it, since it's more code and you have to put it on a grid into scrolling part.

Have you considered how we would implement this feature if we wanted to add all of the possible variations instead of just FTCS_PROMPT? Would you do it the same way and always store it in the first column?

@kchibisov
Copy link
Member Author

Have you considered how we would implement this feature if we wanted to add all of the possible variations instead of just FTCS_PROMPT? Would you do it the same way and always store it in the first column?

I think yes, and those will be offsets from the fist column to other prompt marks. It'll just move to extra storage.

CHANGELOG.md Outdated Show resolved Hide resolved
alacritty/src/config/bindings.rs Outdated Show resolved Hide resolved
alacritty_terminal/src/term/cell.rs Outdated Show resolved Hide resolved

let mut cursor_cell = self.grid.cursor_cell();

// Preserve PROMPT_MARK if we had it.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Preserve PROMPT_MARK if we had it.
// Preserve PROMPT_MARK.

Also is this necessary? The prompt shouldn't usually be overwritten?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does get overwritten due to the way everyone is sending prompt marks. They send prompt mark and then start writing the prompt, leading to overwriting the cell. The documentation and recommendations state that you should send it before writing the prompt.

Copy link
Member

Choose a reason for hiding this comment

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

Really not a big fan of this aspect of the escape. Either way though this comment should be fixed.

Comment on lines +1606 to +1659
// We don't want to clear prompt markers.
let prompt_marked = *self.grid[point.line][Column(0)].flags() & Flags::PROMPT_MARK;

Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary? Who rewrites a prompt without writing the prompt there?

alacritty_terminal/src/term/mod.rs Outdated Show resolved Hide resolved
alacritty_terminal/src/term/search.rs Show resolved Hide resolved
alacritty_terminal/src/term/search.rs Outdated Show resolved Hide resolved
alacritty/src/input.rs Outdated Show resolved Hide resolved
alacritty/src/input.rs Outdated Show resolved Hide resolved
Adds support for setting prompt marks with OSC 133 ; A ST. While
there're other markers for prompt `FTCS_PROMPT` (`A` parameter) is
likely the most widely used and useful one.

Fixes alacritty#5850.
Copy link
Member

@chrisduerr chrisduerr left a comment

Choose a reason for hiding this comment

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

Really my only major gripe left with this is the whole reset logic and I'm not sure there's a great solution for this. It's somewhat of an issue with the escape sequence itself and I'm not confident that just deviating from what everyone else does is a great idea.

@@ -30,6 +30,7 @@ bitflags! {
const ALL_UNDERLINES = Self::UNDERLINE.bits | Self::DOUBLE_UNDERLINE.bits
| Self::UNDERCURL.bits | Self::DOTTED_UNDERLINE.bits
| Self::DASHED_UNDERLINE.bits;
const PROMPT_MARK = 0b1000_0000_0000_0000;
Copy link
Member

Choose a reason for hiding this comment

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

Should be above ALL_UNDERLINES. The "special" constants are usually best kept at the bottom because that way one can easily see at a glance that all bits are correctly set for the other constants.

self.vi_mode_cursor.point
} else {
let display_offset = self.grid.display_offset() as i32;
// If we're outside of Vi mode use bottom most visible line.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// If we're outside of Vi mode use bottom most visible line.
// If we're outside of Vi mode, use bottommost visible line.

Topmost/bottommost are one word, as weird as it looks.

} else {
let display_offset = self.grid.display_offset() as i32;
// If we're outside of Vi mode use bottom most visible line.
Point::new(Line(self.screen_lines() as i32 - 1 - display_offset), Column(0))
Copy link
Member

Choose a reason for hiding this comment

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

Why are you using the bottommost line? If I have a prompt visible at the top and another prompt in the middle of my screen, I want to jump to the prompt in the middle of my screen. I don't want to jump to the next offscreen prompt.

This is the same as search, the top of the screen is always to be considered the origin of the search.

This also shouldn't be inverted for goto_previous. Even there we should still make it based on the topmost line and not switch to the bottommost. We always want our search match aligned at the top of the viewport.

}
}

/// Go to previous prompt farthest up in history.
Copy link
Member

Choose a reason for hiding this comment

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

We don't go to the previous prompt farthest up in history, that would mean we skip over as many prompts as possible. We go to the previous prompt in history, so the opposite of farthest. Could say closest/nearest up in history but I feel like that's unnecessary.

let point = if self.mode.contains(TermMode::VI) {
self.vi_mode_cursor.point
} else {
// If we're outside of Vi mode use topmost visible line.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// If we're outside of Vi mode use topmost visible line.
// If we're outside of Vi mode, use topmost visible line.


let mut cursor_cell = self.grid.cursor_cell();

// Preserve PROMPT_MARK if we had it.
Copy link
Member

Choose a reason for hiding this comment

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

Really not a big fan of this aspect of the escape. Either way though this comment should be fixed.

Comment on lines +443 to +445
} else {
point.column = Column(0);
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} else {
point.column = Column(0);
}
point.column = Column(0);

A bit shorter like this and probably compiles down to the same thing anyway?

@kchibisov
Copy link
Member Author

Given that 586f982 (Allow mode-exclusive bindings in any mode) got merged, I'm no longer interested in this escape sequence. Using uniq symbol in a prompt is a good enough solution for me.

@kchibisov kchibisov closed this Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding OSC 133
3 participants