Recent

Author Topic: Help with moving Cursor, not mouse, in memo box.  (Read 5360 times)

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Help with moving Cursor, not mouse, in memo box.
« on: August 04, 2011, 08:16:53 pm »
I have a memo box that I'm using as the screen for a term emulator.  I'm parsing the incoming text and adding it to the box.  The problem I'm having is that I need to move the cursor, not the mouse one the text one, so that I can read it after each text addition to determine where I am on the screen.  I'm using Memo1.Perform(EM_LINEINDEX,XX,YY) where XX is the Row and YY is the Column but it doesn't seem to actually move the cursor so when I go back into the routine that read the cursor position and adds the text I write over the same line.  I guess I could keep track of the cursor in my code but I thought using the memo controls themselves would be simpler.

What am I missing  :-[

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12109
  • Debugger - SynEdit - and more
    • wiki
Re: Help with moving Cursor, not mouse, in memo box.
« Reply #1 on: August 04, 2011, 08:55:52 pm »
Use SynEdit instead?

It doesn' habve line wrapping, which for a terminal should be correct.

synEdit has
CaretX: integer
CaretY: integer
CaretXY :Point
properties, which can be read and written

It also has
LogicalCaretX, LogicalCaretY, LogicalCaretXY

Where the x position, is the 1 based byte index into the string for the line. This differs because some chars (utf8) take 2 or more byte.

aä1

The ä has 2 bytes: so the Caret can go to pos 1, 2, 3 or 4 (behind the "1"
The LogicalCaret will be 1, 2, 4, or 5

SynEdit also has
TextBetweenPoints[p1, p2] to read/write text.

and you can set the shape of the caret or insert and overwrite mode. (vert-line, underline, block, halfblock)






wpflum

  • Sr. Member
  • ****
  • Posts: 287
Re: Help with moving Cursor, not mouse, in memo box.
« Reply #2 on: August 05, 2011, 04:07:57 am »
SynEdit looks promising, I like the fact that I can make the caret a block.  Is there anyway to make it blink other than with some code to make the caret visible/invisible based on a timer??

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12109
  • Debugger - SynEdit - and more
    • wiki
Re: Help with moving Cursor, not mouse, in memo box.
« Reply #3 on: August 05, 2011, 12:26:12 pm »
It should blink on it's own?

It does certainly for me (Win Vista, Fedora, Ubuntu)

wpflum

  • Sr. Member
  • ****
  • Posts: 287
Re: Help with moving Cursor, not mouse, in memo box.
« Reply #4 on: August 05, 2011, 05:38:41 pm »
Found it, I must have been zombie programming last night, I think I used the overwrite instead of insert caret and didn't see the other option.  :-[

I was able to basically drop it a synedit into my form to replace the memo so I'll go from here.

Thanks.

 

TinyPortal © 2005-2018