News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Richedit wrap

Started by HSE, November 01, 2022, 04:19:33 AM

Previous topic - Next topic

HSE

Hi all!

   Is there a trick to make Richedit align wrap line like this?:

"list":[
             {
                "item": "this is the line
                wrapped"
             }
        ]


What I obtaining is:

"list":[
             {
                "item": "this is the line
wrapped"
             }
        ]


Thanks in advance, HSE.
Equations in Assembly: SmplMath

hutch--

Hector, the only thing I can think of is autoindent which you have to code yourself. I have done them in editors but they are no joy to code.

jj2007

It's possible with paragraph formatting, but I would have to look it up.

HSE

Quote from: hutch-- on November 01, 2022, 07:07:16 AM
the only thing I can think of is autoindent which you have to code yourself. I have done them in editors

Quote from: jj2007 on November 01, 2022, 07:15:33 AM
It's possible with paragraph formatting, but I would have to look it up.

Thanks Huth and JJ!!

Not successful yet, but I was beginning to try in that way  :thumbsup:
Equations in Assembly: SmplMath

jj2007

Here is a snippet from RichMasm:

  CASE PFM_STARTINDENT or PFM_RIGHTINDENT or PFM_OFFSET
mov pf2.dxOffset, eax ; twips, max 9999
mov pf2.dxRightIndent, edx ; twips
  ENDSW
  invoke SendMessage, hRE, EM_SETPARAFORMAT, 0, addr pf2

HSE

Excellent test JJ!

Must be obtained:\pard\fi-1980\li1980\tx0\tab"item": "this is the line wrapped"\par

Text is in first tab with position 0, but that position is displaced  :biggrin:

Curiously, you send distance from right margin, but because alignament is left you have li instead of ri.

Now I have to see to make that  :thumbsup:

Thanks, HSE.
Equations in Assembly: SmplMath

hutch--

Hi Hector,

I just tested a tweaked version of QE where I changed the riched to normal word wrap and the auto indent still worked correctly until you resize the window too narrow then the long lines are word wrapped in the normal manner.

I am not sure if that is what you are after but auto indent still works if the window is not too narrow,

zedd151

I'm wondering two things Hector...
Is the window/rich edit control sizable or fixed size? And, are you using auto horizontal scroll? I think either or both of them could change how what you propose should be approached. Do you want to wrap on window width, or upon pressing enter? Or both/either?

HSE

Hi Hutch!!

Quote from: hutch-- on November 01, 2022, 09:12:36 AM
I just tested a tweaked version of QE where I changed the riched to normal word wrap and the auto indent still worked correctly until you resize the window too narrow then the long lines are word wrapped in the normal manner.

I have a Wrap plugin with just one line: "invoke SendMessage,hEdit,EM_SETTARGETDEVICE, 0, 0", and an UnWrap plugin with only:"invoke SendMessage,hEdit,EM_SETTARGETDEVICE, 0, 1". That work perfectly in standard QE.

Quote from: hutch-- on November 01, 2022, 09:12:36 AM
I am not sure if that is what you are after but auto indent still works if the window is not too narrow,

No. I'm trying to make something like JJ's rtf file in any RichEdit. He post a picture above. The wrapped part of the line is aligned with first part of that line.


Equations in Assembly: SmplMath

HSE

Hi Zed!

Quote from: zedd151 on November 01, 2022, 09:25:15 AM
I'm wondering two things

I counted five.  :biggrin: :biggrin:

Anyway, is only one thing. Just test JJ's rtf file above to see what must be achieved.

Thanks, HSE.
Equations in Assembly: SmplMath

jj2007

Attached a beta (use at your own risk bla bla):
- extract to a folder, then drag the rtf over the exe.
- put the cursor in front of "item"
- press Ctrl G: the Goto edit field opens
- type e.g. ind=120/200

The first value is the indent from the left, the optional second one from the right. You can size the window horizontally to see what it means for the phrase, or use different values such as 150/150 etc.

Under the hood it's EM_SETPARAFORMAT, of course. Btw PFM_BORDER won't work; it's not documented properly, but it simply won't display with any RichEdit control, including the Office versions. However, if you copy the bold
Para with
borders

paragraph and paste it into MS Word, you'll see the beauty of PFM_BORDER - Microsoft at its best :tongue:

zedd151

Quote from: HSE on November 01, 2022, 10:58:08 AM
I counted five.  :biggrin:   :biggrin:
I thought of more as I typed.  :tongue: 


@jj2007, indent left and indent right? Who would have thunk?  :tongue:  As long as it works.  :biggrin:


zedd151

Quote from: HSE on November 01, 2022, 10:44:01 AM
The wrapped part of the line is aligned with first part of that line.
That sounds similar to the autoindent that qeditor uses (upon pressing ENTER) but I assume you want it to wrap automatically (without pressing ENTER)?

HSE

Quote from: jj2007 on November 01, 2022, 11:29:15 AM
Attached a beta (use at your own risk bla bla):

:thumbsup:

Quote from: jj2007 on November 01, 2022, 11:29:15 AM
The first value is the indent from the left,

Perfect. I have to see if that value can be detected with EM_POSFROMCHAR  :biggrin:

Quote from: zedd151 on November 01, 2022, 12:00:49 PM
(upon pressing ENTER)

If you press ENTER then you have a new line, not wrap  :biggrin:
Equations in Assembly: SmplMath

jj2007

Quote from: HSE on November 01, 2022, 11:03:59 PMI have to see if that value can be detected with EM_POSFROMCHAR  :biggrin:

Good idea, I might steal it :biggrin: