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

Paragraph Questions. #41

Closed
ghost opened this issue Apr 16, 2014 · 9 comments
Closed

Paragraph Questions. #41

ghost opened this issue Apr 16, 2014 · 9 comments
Labels

Comments

@ghost
Copy link

ghost commented Apr 16, 2014

Hi Tomas,

To confirm, a paragraph is collection of styled texts that is separated from others by a new line before it and after it. right?

Would it be possible to provide a method to get Paragraph at caret?

Probably outside your scope, not sure. but do you plan to provide paragraph alignment options?

Thanks,
Maher

@TomasMikula
Copy link
Member

To confirm, a paragraph is collection of styled texts that is separated
from others by a new line before it and after it. right?

Yes, basically. More precisely, a paragraph is a sequence of styled texts
and an optional line terminator. All paragraphs in a StyledDocument except
the last one do have a line terminator.

Would it be possible to provide a method to get Paragraph at caret?

You can already do that:

area.getParagraphs().get(area.getCurrentParagraph());

Probably outside your scope, not sure. but do you plan to provide
paragraph alignment options?

I don't have any concrete plans, but this falls under issue #6.

@ghost
Copy link
Author

ghost commented Apr 16, 2014

Thanks. How about the start and end of a paragraph? or set style for a
whole paragraph?

On Wed, Apr 16, 2014 at 11:36 AM, TomasMikula notifications@github.comwrote:

Closed #41 #41.


Reply to this email directly or view it on GitHubhttps://github.com//issues/41
.

@ghost
Copy link
Author

ghost commented Apr 16, 2014

just found a "restyle" ! thanks that shoul ddo it :)

On Wed, Apr 16, 2014 at 11:46 AM, Maher Elkhaldi m.s.khaldi@gmail.comwrote:

Thanks. How about the start and end of a paragraph? or set style for a
whole paragraph?

On Wed, Apr 16, 2014 at 11:36 AM, TomasMikula notifications@github.comwrote:

Closed #41 #41.


Reply to this email directly or view it on GitHubhttps://github.com//issues/41
.

@TomasMikula
Copy link
Member

Just note that paragraph.restyle(newStyle) doesn't change the paragraph in the text area. It creates and returns a new one. To change the style of a paragraph in a text area, you use area.setStyle(paragraphIndex, newStyle).

@ghost
Copy link
Author

ghost commented Apr 16, 2014

Hmm OK. And to get the index of the paragraph at caret I would do indexOf
right?
On Apr 16, 2014 11:53 AM, "TomasMikula" notifications@github.com wrote:

Just note that paragraph.restyle(newStyle) doesn't change the paragraph
in the text area. It creates and returns a new one. To change a style of a
paragraph in a text area, you use area.setStyle(paragraphIndex, newStyle).


Reply to this email directly or view it on GitHubhttps://github.com//issues/41#issuecomment-40637475
.

@ghost
Copy link
Author

ghost commented Apr 16, 2014

I got the paragraph with currentParagrapht.
Is there a way to get its indexRange from the area?

@ghost
Copy link
Author

ghost commented Apr 16, 2014

The reason I need this is that I am applying a size change to a paragraph, but it it has different styled texts. so I only want to update the size. so I am using the styles.map method. for that, I need to set styleSpans to the range, where the paragraph starts and ends.

I found a full length method, but trying to figure out a way to get the start location of a paragraph.

@ghost
Copy link
Author

ghost commented Apr 16, 2014

moved this to another issue an enhancement request :)

@TomasMikula
Copy link
Member

Per-paragraph alignment is now supported with the latest SNAPSHOT.

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

No branches or pull requests

1 participant