Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Hardware & Devices
  4. how to identify the " selected text highlights" event ?

how to identify the " selected text highlights" event ?

Scheduled Pinned Locked Moved Hardware & Devices
questionlinuxhelptutorial
6 Posts 2 Posters 17 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Up front ( follow established rules and READ the post ) I am not sure this question belongs here and I am getting nowhere in other forums - so please no "try such and such..." If you do not know the answer , DO NOT reply, please. I am using Linux terminal to enter this command xterm -e bluetoothctl the result is a "window " where I can double click (anywhere) on selected text (word) and such text - entire word - will highlight. I like to further process the highlighted text and I am unable to find out HOW . Since the resulting "window" reacts to the mouse click I am guessing there is a process resulting in highlighting the entire word. Please help me to solve this, any help leading to solution will be appreciated.

    T L 3 Replies Last reply
    0
    • L Lost User

      Up front ( follow established rules and READ the post ) I am not sure this question belongs here and I am getting nowhere in other forums - so please no "try such and such..." If you do not know the answer , DO NOT reply, please. I am using Linux terminal to enter this command xterm -e bluetoothctl the result is a "window " where I can double click (anywhere) on selected text (word) and such text - entire word - will highlight. I like to further process the highlighted text and I am unable to find out HOW . Since the resulting "window" reacts to the mouse click I am guessing there is a process resulting in highlighting the entire word. Please help me to solve this, any help leading to solution will be appreciated.

      T Offline
      T Offline
      trønderen
      wrote on last edited by
      #2

      You'll probably hate me for answering to your post without giving you the answer you want. But it doesn't exist. When your application sends out some text on a serial line, going to a teletype or CRT or whatever, it sends that text away. The text on your screen is not the string in your application. It is a copy of a string in your application - a copy that has been sent away. Imagine yourself sending a letter (in the paper sense) to a friend. This friend picks up his yellow marker to highlight a couple words that you wrote; he might refer to those words when replying to you. You are asking for a way to change the letter you sent him a day or two ago, in the words that your friend highlighted. You can't. The words are no longer under your control. The xterm highlighting you see is completely independent of your application. xterm is like a remote friend of the application: The text(copy) belongs to xterm, and it is xterm doing the highlighting, completely out of the control of the application. Whatever your xterm wants to do with the highlighted word(s), it can do. Essentially, it can copy the word(s) into a copy/paste buffer and paste it in as part of the input so that you don't have to type it on the keyboard. The application knows nothing about this copy/paste business and sees the paste as if it was typed. If you want your application to be aware of highlighting done by the user, xterm is not the right tool You will have to write your own X11 client. It may look quite similar to that xterm client at the UI, but it will have a very different interface to your application, not trying to emulate an RS232 connected dumb terminal, the way xterm does.

      L 1 Reply Last reply
      0
      • L Lost User

        Up front ( follow established rules and READ the post ) I am not sure this question belongs here and I am getting nowhere in other forums - so please no "try such and such..." If you do not know the answer , DO NOT reply, please. I am using Linux terminal to enter this command xterm -e bluetoothctl the result is a "window " where I can double click (anywhere) on selected text (word) and such text - entire word - will highlight. I like to further process the highlighted text and I am unable to find out HOW . Since the resulting "window" reacts to the mouse click I am guessing there is a process resulting in highlighting the entire word. Please help me to solve this, any help leading to solution will be appreciated.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        "Selecting" is an illusion; screen coordinates interpreted by the OS, then the framework (which gives it context), and lastly the application. There's nothing to "grab" except pixels unless you have a hook into the framework or app. The "device" knows nothing of the software that drives it; and that's why you're in the wrong forum, again.

        "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

        1 Reply Last reply
        0
        • T trønderen

          You'll probably hate me for answering to your post without giving you the answer you want. But it doesn't exist. When your application sends out some text on a serial line, going to a teletype or CRT or whatever, it sends that text away. The text on your screen is not the string in your application. It is a copy of a string in your application - a copy that has been sent away. Imagine yourself sending a letter (in the paper sense) to a friend. This friend picks up his yellow marker to highlight a couple words that you wrote; he might refer to those words when replying to you. You are asking for a way to change the letter you sent him a day or two ago, in the words that your friend highlighted. You can't. The words are no longer under your control. The xterm highlighting you see is completely independent of your application. xterm is like a remote friend of the application: The text(copy) belongs to xterm, and it is xterm doing the highlighting, completely out of the control of the application. Whatever your xterm wants to do with the highlighted word(s), it can do. Essentially, it can copy the word(s) into a copy/paste buffer and paste it in as part of the input so that you don't have to type it on the keyboard. The application knows nothing about this copy/paste business and sees the paste as if it was typed. If you want your application to be aware of highlighting done by the user, xterm is not the right tool You will have to write your own X11 client. It may look quite similar to that xterm client at the UI, but it will have a very different interface to your application, not trying to emulate an RS232 connected dumb terminal, the way xterm does.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Thanks you for such nice contribution to the solution.
          I appreciate that.

          Your analogy is plausible, however , it does not explain how
          clicking on the text highlights it – if it is “gone” / does not exist per your explanation.
          It is physically there and mouse click “finds it” and highlights the entire word.

          I did not wanted to complicate things in my post, but
          I can enter this into terminal
          bluetotthctl

          and since my terminal code actually runs as a new , separate process , under running C++ application I can
          “capture “ the stdout. The “problem “ is it includes control characters and I really do not want to deal with removing them – BUT I have a code which does it. That is not the issue.

          My actually xterm command line includes many options, one of them being “tee” to temporary text file.

          I can analyze this temp file, but would prefer to use the existing graphical output to “drag and drop” the highlighted word selection.

          T 1 Reply Last reply
          0
          • L Lost User

            Up front ( follow established rules and READ the post ) I am not sure this question belongs here and I am getting nowhere in other forums - so please no "try such and such..." If you do not know the answer , DO NOT reply, please. I am using Linux terminal to enter this command xterm -e bluetoothctl the result is a "window " where I can double click (anywhere) on selected text (word) and such text - entire word - will highlight. I like to further process the highlighted text and I am unable to find out HOW . Since the resulting "window" reacts to the mouse click I am guessing there is a process resulting in highlighting the entire word. Please help me to solve this, any help leading to solution will be appreciated.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            That is just a feature of the Window that displays the text, and most Window types have that feature. So unless the window allows you to copy/cut the highlighted text you are out of luck.

            1 Reply Last reply
            0
            • L Lost User

              Thanks you for such nice contribution to the solution.
              I appreciate that.

              Your analogy is plausible, however , it does not explain how
              clicking on the text highlights it – if it is “gone” / does not exist per your explanation.
              It is physically there and mouse click “finds it” and highlights the entire word.

              I did not wanted to complicate things in my post, but
              I can enter this into terminal
              bluetotthctl

              and since my terminal code actually runs as a new , separate process , under running C++ application I can
              “capture “ the stdout. The “problem “ is it includes control characters and I really do not want to deal with removing them – BUT I have a code which does it. That is not the issue.

              My actually xterm command line includes many options, one of them being “tee” to temporary text file.

              I can analyze this temp file, but would prefer to use the existing graphical output to “drag and drop” the highlighted word selection.

              T Offline
              T Offline
              trønderen
              wrote on last edited by
              #6

              Member 14968771 wrote:

              Your analogy is plausible, however, it does not explain how clicking on the text highlights it – if it is "gone" / does not exist per your explanation.

              It does not exist in your application (well, your application may still have the original, from which a copy was sent to xterm, but that is a different object). But xterm saves in its own buffer the output it receives from the application. It uses the contents of the buffer to redraw the window, say, if you resize it, or scroll the text up and down. This text buffer belongs to xterm. It is not accessible to your application. The highlighting is done in this buffer, by xterm. All you input and output goes through xterm (as long as your focus is in the xterm window). xterm knows where you click your mouse, and knows the size of character cells in its window (they are all the same, at least in classic xterm). Calculating from the mouse coordinates which character cell was clicked is trivial. (If you use variable-width font, it is just semi-trivial.) xterm starts at from this character and looks at the preceding and following characters in its text buffer. As long as they are 'word characters', it adds highlight to it and searches forward, but stops on whitespace, punctuation etc. If you could monitor the connection between xterm and your application when you mark the word, you would see none. The marking is something xterm does for itself, alone. I haven't been working with xterm for a number of years, and don't remember all the details, but like most *nix-born applications, it has a ton of options. I guess that you can tell xterm to give you all the raw input - certainly from the keyboard, so that your application can interpret copy (mark) and paste keystrokes, but maybe even mouse input. Your problem is that xterm manages its own scrolling, word wrapping etc. and your application cannot know where it has placed the output text you gave it. So even if you get the mouse click position, you don't have the information to know which word the cursor was pointing at. If I understand your need correctly (and you do not want to give your application its own tailor made X-based user interface), the simple but somewhat pedal driven way to do it is to open a text editor with a new empty file (or one where you want to add another log record), mark the text in your xterm window, and then past them into the file in the text editor. There are multiple ways to mark

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups