This repository has been archived by the owner on Mar 31, 2024. It is now read-only.
Add support for hyperlinks in kitty #165
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,11 +128,15 @@ impl TerminalCapabilities { | |
} | ||
|
||
/// Terminal capabilities of Kitty. | ||
pub fn kitty() -> TerminalCapabilities { | ||
pub fn kitty(version: (u8, u8, u8)) -> TerminalCapabilities { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like for these constructors to always return the same set of capabilities. Would you mind to leave |
||
TerminalCapabilities { | ||
name: "Kitty".to_string(), | ||
style: Some(StyleCapability::Ansi(AnsiStyle)), | ||
links: None, | ||
links: if version >= (0, 19, 0) { | ||
Some(LinkCapability::OSC8(self::osc::OSC8Links)) | ||
} else { | ||
None | ||
}, | ||
image: Some(ImageCapability::Kitty(self::kitty::KittyImages)), | ||
marks: None, | ||
} | ||
|
@@ -155,8 +159,8 @@ impl TerminalCapabilities { | |
Self::iterm2() | ||
} else if self::terminology::is_terminology() { | ||
Self::terminology() | ||
} else if self::kitty::is_kitty() { | ||
Self::kitty() | ||
} else if let Some(version) = self::kitty::is_kitty() { | ||
Self::kitty(version) | ||
} else if get_vte_version().filter(|&v| v >= (50, 0)).is_some() { | ||
Self::vte50() | ||
} else { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This will fail if
kitty
is not in$PATH
or doesn't exist at all (e.g. inside a chroot or systemd container). And worse, it won't fail gracefully in this case and detect kitty without hyperlinks; instead it'll make mdcat believe that it's not running in kitty at all, even if$TERM
says it's kitty.Can we somehow get the version in a more reliable way? Perhaps by means of some escape sequence?
And is the version actually sufficient? What about the
allow_hyperlinks
setting?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
kitty
is not in$PATH
image display would also fail. You're right aboutallow_hyperlinks
, but looking at the issue and at the commits inkitty
I haven't seen anything implemented for feature detection.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.
I wasn't aware that image display uses
kitty
. In this case I agree that it's a good idea to fail completely ifkitty
isn't found! But please document this in the docstring of the method, so that I don't forget and think it's a bug in six months 😉