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
Conversation
There was a problem hiding this 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?
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 |
I think yes, and those will be offsets from the fist column to other prompt marks. It'll just move to extra storage. |
|
||
let mut cursor_cell = self.grid.cursor_cell(); | ||
|
||
// Preserve PROMPT_MARK if we had it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Preserve PROMPT_MARK if we had it. | |
// Preserve PROMPT_MARK. |
Also is this necessary? The prompt shouldn't usually be overwritten?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
// We don't want to clear prompt markers. | ||
let prompt_marked = *self.grid[point.line][Column(0)].flags() & Flags::PROMPT_MARK; | ||
|
There was a problem hiding this comment.
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?
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.
There was a problem hiding this 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; |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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)) |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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. |
There was a problem hiding this comment.
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.
} else { | ||
point.column = Column(0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else { | |
point.column = Column(0); | |
} | |
point.column = Column(0); |
A bit shorter like this and probably compiles down to the same thing anyway?
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. |
Adds support for setting prompt marks with OSC 133 ; A ST. While
there're other markers for prompt
FTCS_PROMPT
(A
parameter) islikely the most widely used and useful one.
Fixes #5850.