Is your feature request related to a problem? Please describe.
I have a program where I want to render clickable hyperlinks as specified by OSC 8, cursive has no native way to render OSC8, and going around cursive for it is a major hassle and not something advisable.
Describe the solution you'd like
A way to specify a hyperlink in cursive, potentially the api could look like this (modeled after the with_* Printer methods):
impl Printer {
/// Wraps the printed text with a hyperlink
pub fn with_hyperlink<F: FnOnce(&Printer)>(&self, link: &str, f: F);
}
and other related methods like set_hyperlink, though this seems weird to set/unset
Alternatively, OSC8 provides a way to label hyperlinks as the same with the id parameter, so the api could look like this (and set_hyperlink would make more sense):
#[derive(Copy, Clone)]
struct Hyperlink<'a> {
link: &'a str,
// this can be a stable hash of the link, or user provided, or just random,
// whatever works best for cursive
// OSC8 intends id's to be used for applications where you have
// hyperlinks split over multiple lines, the id will uniquely
// identify separate segments as one link
// the length of 8 was arbitrarily chosen for demonstration
id: [u8; 8],
}
impl<'a> Hyperlink<'a> {
// using rand here as an example, in this way each new Hyperlink is probabilistically distinct
fn new(link: &'a str) -> Self { Self { link, id: rand::thread_rng().gen() } }
}
impl Printer {
/// Wraps the printed text with a hyperlink
pub fn with_hyperlink<F: FnOnce(&Printer)>(&self, link: Hyperlink, f: F);
}
Additional context
While cursive View's can be used to replicate a portion of the OSC8 hyperlink behavior, this is an API that modern terminal emulators provide, and it would be cool if cursive could support rendering them
Is your feature request related to a problem? Please describe. I have a program where I want to render clickable hyperlinks as specified by OSC 8, cursive has no native way to render OSC8, and going around cursive for it is a major hassle and not something advisable.
OSC 8 described
Describe the solution you'd like A way to specify a hyperlink in cursive, potentially the api could look like this (modeled after the with_* Printer methods):
and other related methods like set_hyperlink, though this seems weird to set/unset
Alternatively, OSC8 provides a way to label hyperlinks as the same with the
id
parameter, so the api could look like this (and set_hyperlink would make more sense):Additional context While cursive View's can be used to replicate a portion of the OSC8 hyperlink behavior, this is an API that modern terminal emulators provide, and it would be cool if cursive could support rendering them