Recent

Author Topic: ATSynEdit questions  (Read 3146 times)

polpero

  • Full Member
  • ***
  • Posts: 116
ATSynEdit questions
« on: January 17, 2017, 11:17:29 pm »
Hey!

Is anyone using ATSynEdit?

I'm exploring ATSynEdit and am a bit confused...

what should be the correct way to get a selection and change it's content?

I know i could get the caret's position with

Code: Pascal  [Select][+][-]
  1. ed.Carets[0].PosY // curLine
  2. ed.Carets[0].PosX // position in line

but how do i get the length of the selection?

///

and then, how should i insert text inside a line?
(or replace the selection)?

Thanks...


AlexTP

  • Hero Member
  • *****
  • Posts: 2384
    • UVviewsoft
Re: ATSynEdit questions
« Reply #1 on: January 22, 2017, 11:13:05 pm »
@Moderator:
maybe move topic to Packages part?

About component
- get selection as: Carets[0]: it has PosX PosY (start of sel)+ EndX EndY (-1 if no selection, >=0 if selection)
- delete by using Strings.TextDeleteRange
- insert by Strngs.TextInsert

http://wiki.freepascal.org/ATSynEdit#How_to_manage_the_caret.2C_the_selection.3F
http://wiki.freepascal.org/ATSynEdit#How_to_modify_text.3F

polpero

  • Full Member
  • ***
  • Posts: 116
Re: ATSynEdit questions
« Reply #2 on: January 23, 2017, 03:37:54 pm »
Quote
@Moderator:
maybe move topic to Packages part?

Yes, it should...

Thanks Alex

i found a still simpler/elegant solution:
Code: Pascal  [Select][+][-]
  1. var tmp: string;
  2. begin
  3.  tmp := "<b>" + ed.textSelected + "</b>";
  4.  ed.doCommand(cCommand_TextInsert,tmp);
  5. end;
  6.  
« Last Edit: January 24, 2017, 03:28:10 pm by polpero »

AlexTP

  • Hero Member
  • *****
  • Posts: 2384
    • UVviewsoft
Re: ATSynEdit questions
« Reply #3 on: January 23, 2017, 03:54:47 pm »
It will do only insert; it cannot delete the range. It's little slower - "case" for many ids.

polpero

  • Full Member
  • ***
  • Posts: 116
Re: ATSynEdit questions
« Reply #4 on: January 24, 2017, 02:59:16 pm »
hmm

Quote
It will do only insert; it cannot delete the range.

but when issued an empty string
the selection does vanish:


Code: Pascal  [Select][+][-]
  1.  tmp := ed.TextSelected;  // tmp := a-non-empty-selection
  2.  ed.DoCommand(cCommand_TextInsert, ''); // result is empty (previous sel is gone)

or am i missing something?

AlexTP

  • Hero Member
  • *****
  • Posts: 2384
    • UVviewsoft
Re: ATSynEdit questions
« Reply #5 on: January 24, 2017, 03:03:06 pm »
Ah so it's replacing current sel. DoCommand cannot delete any text

 

TinyPortal © 2005-2018