Announcement

Collapse
No announcement yet.

How to select a block within a textbox

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

  • How to select a block within a textbox

    Hi @all

    In order to design an individual editor I am trying to figure out a way to multi-select some parts of lines in a multiline textbox. Something similiar to Microsoft Word: (Alt-key and mouse movement)



    I am looking for a way to "clone" this feature.

    The %EM_SETSEL method selects a full range past the $crlf delims, so this won't be the way to go. Any ideas where to start with?

    Many thanks for a suggestion!

    Regards
    Albert
    „Let the machine do the dirty work.“
    The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978

  • #2
    In zip file in this thread is a program called AreaClip that you might be able to adapt the code to suit your purpose. It's not difficult to use once you get yourself accustomed to it, but the help is wanting.
    http://www.powerbasic.com/support/pb...ies+collection
    Rod
    "To every unsung hero in the universe
    To those who roam the skies and those who roam the earth
    To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

    Comment


    • #3
      Originally posted by Rodney Hicks View Post
      In zip file in this thread is a program called AreaClip that you might be able to adapt the code to suit your purpose.
      Thanks for your reply, Rodney. Perhaps it's only me that I don't see any relation to my textbox issue.
      „Let the machine do the dirty work.“
      The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978

      Comment


      • #4
        Perhaps I misunderstood what you were seeking, but it was a similar problem that I used this to solve by copying from an editor to the clipboard, pasting in the app and cutting/copying the block I was after, albeit with a fixed width font.
        I didn't feel a need to create another editor for this one feature.
        Rod
        "To every unsung hero in the universe
        To those who roam the skies and those who roam the earth
        To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

        Comment


        • #5
          I'd probably look at using a multi-line edit control, then assuming I can define the area to be clipped, individually extracting the selected text from each affected line. There are messages you can send to a control to find the text position based on a point. If not with a regular edit control, I'm positive you can do this with a richedit control.

          But for all I know that's exactly what Rodney Hicks has done.

          Comment


          • #6
            Hi Albert!
            Neither the TextBox nor RichEdit control support block selections.

            However, Scintilla does:

            Comment


            • #7
              I've put about 60 Scintilla code examples online here. They're also in the gbSnippets library.

              Comment


              • #8
                Originally posted by Gary Beene View Post
                I've put about 60 Scintilla code examples online here. They're also in the gbSnippets library.
                Hi Gary - aah thanks, this looks very promising. I believe I've got a lot to read. :-)

                I am trying ro re-program my trusted CE (PBCC Console Editor), which natively has got block copy functions, thus creating a GUI clone of it.

                Will get back to you all, including source code, when/if I am coming up with something useful.

                Cheers
                Albert
                „Let the machine do the dirty work.“
                The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978

                Comment


                • #9
                  Now, nearly a year's gone, but I am still happily developing my programmer's tool using the Scintilla DLL. Sometimes there are so many other tasks to do, so that the leisure programming has to be deferred. Anyway, so many thanks for the really fine hint, Gary Beene!

                  Something I quite didn't get - perhaps you or some other kind chap at PB forums can give me some help...

                  Scintilla supports multiple selections - the block selection (Alt-mouse move) is just a special case of this feature. How do I enum and retrieve the selected parts?

                  Thanks for any hint!
                  Cheers, Albert
                  „Let the machine do the dirty work.“
                  The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978

                  Comment


                  • #10
                    Hi Albert,

                    Not Scintilla but a simple MS edit control, maybe the text retrieval algo could give some hint... TextBox Column Selection

                    Pierre

                    Comment


                    • #11
                      Hello Pierre
                      Originally posted by Pierre Bellisle View Post
                      Not Scintilla but a simple MS edit control, maybe the text retrieval algo could give some hint... TextBox Column Selection
                      This is really nifty code, thanks! A kind of handmade selection... :-)

                      I am under the impression that Scintilla already would handle this properly, but I didn't find the proper API call to retrieve the selection coordinates. As far as I can tell Gary's fine examples don't cover this particular part of Scintilla.


                      Albert
                      „Let the machine do the dirty work.“
                      The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978

                      Comment


                      • #12
                        For once, quoting myself, in order to help others who might encounter the same need:

                        Originally posted by Albert Richheimer View Post
                        Scintilla supports multiple selections - the block selection (Alt-mouse move) is just a special case of this feature. How do I enum and retrieve the selected parts?
                        I have found the solution: The relevant Scintilla API functions are
                        Code:
                        %SCI_GetSelections
                        %SCI_GetSelectionNStart
                        %SCI_GetSelectionNEnd
                        Used in context, this would be something like this:
                        Code:
                                case %IDM_HELP_TEST
                                    lTemp1 = SendMessage(gSciHand,%SCI_GetSelections,0,0)
                                    sTemp  = format$(lTemp1) + " Selections:"
                                    for lTemp2 = 0 to lTemp1-1
                                        lTemp3 = SendMessage(gSciHand,%SCI_GetSelectionNStart,lTemp2,0)
                                        lTemp4 = SendMessage(gSciHand,%SCI_GetSelectionNEnd,lTemp2,0)
                                        sTemp  = sTemp+$cr+format$(lTemp2)+": "+format$(lTemp3) + " to "+format$(lTemp4)
                                    next lTemp2
                                    msgbox sTemp
                        „Let the machine do the dirty work.“
                        The Elements of Programming Style, Brian W. Kernighan, P. J. Plauger 1978

                        Comment

                        Working...
                        X