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

Add support for terminal like caret #1121

Open
PavelTurk opened this issue Jun 22, 2022 · 7 comments
Open

Add support for terminal like caret #1121

PavelTurk opened this issue Jun 22, 2022 · 7 comments

Comments

@PavelTurk
Copy link
Contributor

RichTextFX is also used for building terminal emulator applications. At the same time, currently it is not possible to style caret to look like in terminals. This problem was also discussed in #397 , but later the issue was closed without resolving.

I suggest to support the following caret features:

  1. width
  2. height
  3. shape
  4. color
  5. inverse color (for example, the color of the letter that the caret is on)
  6. caret position (it is necessary to set caret over letter)
@Jugen
Copy link
Collaborator

Jugen commented Jun 22, 2022

PRs are welcome for new features :-)

@PavelTurk
Copy link
Contributor Author

@Jugen I suggested to use RichTextFX for terminalFX - javaterminal/TerminalFX#58 It seems to me, that this issue (caret support absence) can be the only problem.

@Jugen
Copy link
Collaborator

Jugen commented May 27, 2024

I had a quick look at terminalFX and I don't think it'll be able to use RichTextFX because it just uses JavaFX as a view wrapper for the Javascript hterm library.

@PavelTurk
Copy link
Contributor Author

@Jugen Yes, you are right. I didn't expect that they use JavaScript. It seems that JS becomes more popular in Java project (for example https://github.com/nidi3/graphviz-java) but it is not what I like. Have you ever come across a JavaFX terminal with RichTextFX? It is what I need, and I don't want to do :)

@Jugen
Copy link
Collaborator

Jugen commented May 28, 2024

Sorry, haven't seen a JavaFX terminal :-(

@PavelTurk
Copy link
Contributor Author

PavelTurk commented Jul 3, 2024

@Jugen This is a link to a pure JavaFX terminal. But it wasn't made with RichTextFX as it was found out it was impossible. The main component is .. Canvas

But this issue is still actual because setting caret shape, color etc can be used in many other situations.

@Jugen
Copy link
Collaborator

Jugen commented Jul 3, 2024

For anyone interested RichTextFX currently gets its caret shape from the JavaFX TextFlow control via the caretShape method:

PathElement[] getCaretShape(int charIdx, boolean isLeading) {
return caretShape(charIdx, isLeading);
}

This is invoked for each caret in ParagraphText updateSingleCaret, where the RichTextFX CaretNode is an extension of Path:

private void updateSingleCaret(CaretNode caretNode) {
PathElement[] shape = getCaretShape(getClampedCaretPosition(caretNode), true);
caretNode.getElements().setAll(shape);
}

This the place where the caret's visible shape could be altered depending on any caret features added to CaretNode.

Note that doing this may have side affects to how RichTextFX behaves as the main caret's bounds are used in other places.

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

2 participants