Skip to content
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

Inserting graphic in the text #87

Closed
ghost opened this issue Oct 9, 2014 · 6 comments
Closed

Inserting graphic in the text #87

ghost opened this issue Oct 9, 2014 · 6 comments

Comments

@ghost
Copy link

ghost commented Oct 9, 2014

Hi Tomas,
Is there a way for me to assign a graphic to a line.
I would like to be able to add a line across the width of text area.

For example, when I concatenate multiple StyledDocs into a single text area, I would like them to be separated by lines.

Please let me know if there is a way for me to explore this.
Best,
Maher

@TomasMikula
Copy link
Member

Hi Maher,

this is not currently possible, but it is somewhat possible to add this functionality. TextFlow which is used by StyledTextArea and descendants does support adding arbitrary nodes in addition to text. The node, however, will be laid out to its preferred width, so it might be tricky to keep that preferred width in sync with text area's width.

Adding this feature to RichTextFX would certainly change some of the current APIs, but I don't see it as a problem. Someone else has asked about this feature before, when they wanted to insert emoticons in the text, but I haven't heard from them since.

@TomasMikula TomasMikula changed the title Setting a graphic for a line Inserting graphic in the text Oct 9, 2014
@ghost
Copy link
Author

ghost commented Oct 9, 2014

Thanks.

So in theory it would be possible to add labels or text fields to a
Text-Area. using the caret position?
If so, it would allow me then to do things like text-entities
(snippets--something I proposed as an enhancement sometime ago).

Would this be something that you can consider?

On Thu, Oct 9, 2014 at 1:48 PM, TomasMikula notifications@github.com
wrote:

Hi Maher,

this is not currently possible, but it is somewhat possible to add this
functionality. TextFlow
http://docs.oracle.com/javase/8/javafx/api/javafx/scene/text/TextFlow.html
which is used by StyledTextArea and descendants does support adding
arbitrary nodes in addition to text. The node, however, will be laid out to
its preferred width, so it might be tricky to keep that preferred width
in sync with text area's width.

Adding this feature to RichTextFX would certainly change some of the
current APIs, but I don't see it as a problem. Someone else has asked about
this feature before, when they wanted to insert emoticons in the text, but
I haven't heard from them since.


Reply to this email directly or view it on GitHub
#87 (comment)
.

@TomasMikula
Copy link
Member

Yes, it would then be possible to add labels, text fields and in theory even a whole another text area. But remember, that the whole nested node would count as one character, i.e. its range in the parent text area would be [n, n+1) for some integer n.

It is something that has been on my mind for a long time (it's noted as a possible enhancement in the README), but I personally haven't needed this myself, so I had little incentive to implement it.

@MewesK
Copy link
Contributor

MewesK commented Aug 20, 2015

I think this feature could be used to implement code folding since the inserted node could hold the text it has to replace and could be rendered as [...]
The difficult part in that case would be to change the delete behavior of the control to not just delete the whole node if the user presses backspace.

I guess this could be something I'll look into after the paragraph style feature.

@TomasMikula
Copy link
Member

I don't think this is a good way to implement code folding. For one, it would mess up text indices and line numbers.

I have another idea how to implement code folding in mind, using paragraph graphic and custom EditableStyledDocument. It will however require some preparatory refactoring first.

@JordanMartinez
Copy link
Contributor

This was implemented by #356

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

No branches or pull requests

3 participants