Sublime Forum

Selectable Region / Annotation / Phantom

#1

Hi there,

I’m trying to create a selectable Region / Annotation / Phantom to display some text that is not part of a view. This would be similar in behaviour to the text displayed when you activate the Show Diff Hunk.

I have tried hunting down the code for the toggle_inline_diff command to no avail. I’m not sure how it runs or where it is pointing. I think if I could use that as an example, I would be able to build this.

I have built something similar using Phantoms to get that inline below text look that I was hoping for but the text is not selectable. I have tried building region annotations but again am running into selectable difficulties and cannot align it underneath.

  1. Selectable
  2. Below desired region in the same manner as a Phantom

Any help would be very much appreciated.

Thanks
Haven

0 Likes

#2

Diffs are a core functionality.

Phantoms are used to add simple inline html content to a document. You can check whether phantoms are part of a selection and perform actions on the result, but they are not designed for content being partially selected.

0 Likes

#3

Hi, thankyou for your response.

By core functionality, do you mean something that cannot be replicated?

Cause if so, I suppose I could look at utilising the diff functionality itself to display my selectable text. Could get rather complex that way but I already have a couple of ideas.

0 Likes

#4

Core functions are implemented in C++ and can’t be modified by plugins, yes.

0 Likes

#5

I believe those inline diffs are called Text phantoms (The regular phantoms are HTML phantoms that provide an API to inject HTML content into the views). Text phantoms aren’t exposed as an API but it would be really nice to see it. You could open a feature request for it https://github.com/sublimehq/sublime_text/issues

0 Likes