Skip to content

Clickable links in opam show#4568

Draft
dra27 wants to merge 2 commits intoocaml:masterfrom
dra27:clickable-links
Draft

Clickable links in opam show#4568
dra27 wants to merge 2 commits intoocaml:masterfrom
dra27:clickable-links

Conversation

@dra27
Copy link
Copy Markdown
Member

@dra27 dra27 commented Feb 26, 2021

A piece of sleeplessness-induced silliness looking at #4565 - if a field in opam show parses as a URL, turn the field marker into a clickable hyperlink.

Not for 2.1 (if at all, but the function might be useful, even if not used in opam show)

Allows generation of OSC 8 sequences for clickable hyperlinks.
try
let basic_contents = detail_printer ~prettify:true ?normalise ~sort st nv item in
let contents_url = OpamUrl.parse basic_contents in
if OpamUrl.(contents_url.transport = "http" || contents_url.transport = "https") then
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A reason to not use the backend field ?

carriage_delete_unix

let url ~ref ~label =
if not (color ()) || Sys.win32 && get_win32_console_shim `stdout Mode = Shim then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be worth a comment linking to the handy https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda which describes the escape codes for Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: WIP Not for merge at this stage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants