Announcement

Collapse
No announcement yet.

Richedit wordwrap/linewrap question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Richedit wordwrap/linewrap question

    I'm looking for a way of detecting whether a given line in a richedit control has been wrapped, or is the result of wrapping. I had high hopes of both EM_FMTLINES and EM_*WORDBREAKPROC but neither appears to do the necessary. The alternative is to maintain an external buffer containing the text being edited, but that would have to be kept up to date with WM_GETTEXT ( in order to get the "soft" line feeds), which would slow the whole plot to a crawl. I hope I'm missing something obvious?

    #2
    Once you have determined the line you may consider looking 'backwards' using:
    EM_EXLINEFROMCHAR

    ??

    I am sure there is a faster way.. i am to lazy today..
    hellobasic

    Comment


      #3
      Chris,
      Do you mean a Richedit that the text changes and you update to show the new characters (or character) as it is typed?
      Engineer's Motto: If it aint broke take it apart and fix it

      "If at 1st you don't succeed... call it version 1.0"

      "Half of Programming is coding"....."The other 90% is DEBUGGING"

      "Document my code????" .... "WHYYY??? do you think they call it CODE? "

      Comment


        #4
        Originally posted by Cliff Nichols View Post
        Chris,
        Do you mean a Richedit that the text changes and you update to show the new characters (or character) as it is typed?
        Suppose you have some long lines and the RichEdit code editor control wraps these when they are loaded (or they get wrapped after resize). Imagine that one of them is a comment line, and that you color comments green. When you retreive the first wrapped line and discover the comment character, you will want to start coloring the following text green, and will continue to the end of line. However, the next line should also be green, because Richedit has wrapped the original comment line into two lines, but there is AFAICS no way of knowing if any line read from the control by this method (EM_GETTEXTRANGE) is a fragment of a wrapped line or not. Multiline comments are less of a problem because the delimiter is in the text itself, but with single line comments the delimiter is the end of line iteslf - oh, and in PB you can leave the trailing double-quote off a string literal, so the problem is simliar to the single-line comment one.

        Comment


          #5
          Chris,

          See thread: "Parse or Print textbox text with wordwrap"

          User to user discussions about the PB/Win (formerly PB/DLL) product line. Discussion topics include PowerBASIC Forms, PowerGEN and PowerTree for Windows.

          Comment


            #6
            Brent, thanks, that method would probably work if you were exporting all of the text, but not if you are just pulling out a line, unfortunately.

            Comment


              #7
              Problem solved - I was using %EM_LINELENGTH to get the length of each selected line. It doesn't include the line terminating characters! So a wrapped line (no line terminating chars) looks just like a non-wrapped line (with <CR><LF>). Onwards and upwards.

              Comment


                #8
                on knowing when to retreat...

                Unfortunately adding code to unwrap lines pushes the performance of the keyword highlighting just beyond acceptable limits. So I turned off wrapping by adding the horizontal scrollbar styles.

                Comment

                Working...
                X
                😀
                🥰
                🤢
                😎
                😡
                👍
                👎