Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » Allow line-break after '-' sign within a word?
Allow line-break after '-' sign within a word? [message #40448] Fri, 02 August 2013 16:39 Go to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
My problem is, that I have some very long words with multiple '-' signs and I want to allow line breaking after '-' signs.

E. g. I have a word like this: this-is-a-long-word-with-a-lot-of-minus-signs and it would be at the end of a line like:

some text ........................... this-is-a-long-word-
with-a-lot-of-minus-signs


So is it possible to change line breaking somhow or is there a non printing character allowing line break within a word?

Or can I change the rendering code? Where can I find this line breaking logic in U++ code?
Re: Allow line-break after '-' sign within a word? [message #40450 is a reply to message #40448] Sat, 03 August 2013 08:38 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi zsolt,

If you talk about DocEdit, then the responsible code is in DocEdit::Format(const WString& text) const, in CtrlLib/DocEdit.cpp.

I think that you'd just need to add check for '-' in this part:
		if(*s == ' ' || *s == '\t') {
			space = s;
			spacex = x + cw;
			*s = ' ';
		}

I did not try it, but it should be quite straightforward Wink

Best regards,
Honza
Re: Allow line-break after '-' sign within a word? [message #40453 is a reply to message #40450] Sat, 03 August 2013 14:16 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
Hello Honza,

thanks for your answer, but I forgot to mention that I need this in Qtf-based printing (Report).
Re: Allow line-break after '-' sign within a word? [message #40473 is a reply to message #40453] Tue, 06 August 2013 14:36 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
As a workaround, I replaced every '-' characters to:
-[+1  ]

So after every '-' chars there are very small sized spaces and breaking words are correct now.
Re: Allow line-break after '-' sign within a word? [message #40474 is a reply to message #40448] Tue, 06 August 2013 19:21 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
Hello, Zsolt.
zsolt wrote on Fri, 02 August 2013 16:39

So is it possible to change line breaking somehow or is there a non printing character allowing line break within a word?

Or can I change the rendering code? Where can I find this line breaking logic in U++ code?

You could find "line breaking logic" for U++ RichText inside of RichPara::FormatLines method.
To allow line breaks for '-' character, it is possible to change (for your local copy of RichText package) following line of code:
		if(*s == ' ') {

to:
		if(*s == ' ' || *s == '-') {

The diff file attached, just in case.
Re: Allow line-break after '-' sign within a word? [message #40476 is a reply to message #40474] Tue, 06 August 2013 20:35 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
It is working. Thanks!

Maybe it would be a good idea to apply this change to the SVN version as well. Hm?
Re: Allow line-break after '-' sign within a word? [message #40477 is a reply to message #40476] Tue, 06 August 2013 22:03 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
zsolt wrote on Tue, 06 August 2013 20:35

Maybe it would be a good idea to apply this change to the SVN version as well. Hm?

As far as I know, not all words with hyphen character must be line-break, especially for languages different than english, while RichText is UTF-aware.
For example, for unicode character set there are:
- soft-hypen, to manually "hint" about line break.
- non-breaking hyphen and no-break-space, to forbid line break.
- etc.

Also, the Hyphen Wikipedia page mentions about "minus sign", which "should not be confused with" hyphen.

Not to mention about many hyphenation algorithms (e.g. "Liang-Knuth hyphenation algorithm", which uses specially created patterns for selected languages; algorithms, based on vowels, consonants, syllables, etc.).

[Updated on: Tue, 06 August 2013 22:26]

Report message to a moderator

Re: Allow line-break after '-' sign within a word? [message #40547 is a reply to message #40476] Sun, 11 August 2013 18:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
zsolt wrote on Tue, 06 August 2013 14:35

It is working. Thanks!

Maybe it would be a good idea to apply this change to the SVN version as well. Hm?


I think we should go with "real unicode" hyphen (I believe it should be 0x2010) there, no? Perhaps support soft hyphen in the process too (those would require to 'add' hyphen character.)

Mirek
Re: Allow line-break after '-' sign within a word? [message #40548 is a reply to message #40547] Sun, 11 August 2013 18:04 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Also, we might consider adding automated hyphenation too... (but that will have to have support in LanguageInfo).
Re: Allow line-break after '-' sign within a word? [message #40560 is a reply to message #40547] Tue, 13 August 2013 13:50 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
mirek wrote on Sun, 11 August 2013 18:03

zsolt wrote on Tue, 06 August 2013 14:35

It is working. Thanks!

Maybe it would be a good idea to apply this change to the SVN version as well. Hm?


I think we should go with "real unicode" hyphen (I believe it should be 0x2010) there, no? Perhaps support soft hyphen in the process too (those would require to 'add' hyphen character.)

Mirek


Yes, something should be done about it, because the current behaviour is not correct for a lot of languages.
Re: Allow line-break after '-' sign within a word? [message #41006 is a reply to message #40548] Sat, 19 October 2013 19:06 Go to previous message
wimpie is currently offline  wimpie
Messages: 46
Registered: March 2013
Location: holland
Member
mirek wrote on Sun, 11 August 2013 18:04

Also, we might consider adding automated hyphenation too... (but that will have to have support in LanguageInfo).

I think it's a good idea to support word-breaking at QTF level with invisible characters indicating where the words may break. (soft-hyphen)
But automation should be in the (word processing) editor where typed words may be inserted with the soft-hyphen. in my experience the computer is not always right, so you should be able to remove the soft-hyphen by hand if you like. (or add it...)
Previous Topic: Insert text data from file
Next Topic: Need help with setting RichEdit fonts in droplist [SOLVED]
Goto Forum:
  


Current Time: Thu Mar 28 20:06:30 CET 2024

Total time taken to generate the page: 0.01697 seconds