Recent

Author Topic: SynEdit Questions  (Read 8672 times)

captian jaster

  • Guest
SynEdit Questions
« on: August 14, 2010, 01:33:13 am »
Whats the property name for the strings highlited?
I checked the LCL site but i cant find it :\
http://lazarus-ccr.sourceforge.net/docs/lcl/

And for my second question..
The Undo Procedure in lazarus Undos all of the things i backspaced.
The TSynEdit.Undo does it Char By Char
Or should i use a SynMemo?
Thanks  ;)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8462
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit Questions
« Reply #1 on: August 14, 2010, 02:02:42 am »
eoGroupUndo in Synedit.Options

Which Highlight you mean?
- Selection?
BlockBegin, BlockEnd, SelAvail,
    property DefaultSelectionMode;
    property SelectionMode;
    property SelectedColor;

- color for same word as word under caret
    property HighlightAllColor;

captian jaster

  • Guest
Re: SynEdit Questions
« Reply #2 on: August 14, 2010, 03:21:07 am »
The eoGroup thing works :D
By Highlight i mean the selected Strings yes
But how do you use SelAvail?
I did it with a basic IF NOT Code And IF  code and nothing worked ;_;

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8462
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit Questions
« Reply #3 on: August 14, 2010, 12:23:07 pm »
By Highlight i mean the selected Strings yes

I am still unsure what you mean? "selected Strings" is plural. There is only one selection?

SelAvail is boolean, so
  "if not SelAvail then raise exception('no selection made');
should work (but is a bit of an overreaction)

You get the text via  SynEdit.SelText

Search the unit ide/SourceEditor.pp for examples

captian jaster

  • Guest
Re: SynEdit Questions
« Reply #4 on: August 15, 2010, 01:39:53 am »
Sorry for not being clear before..
By select I mean when you click and then highlight a text  :P
(For copying etc,etc).

I never found the SelText which is odd...
I know selAvail is boolean but i did a basic code with a
Code: Pascal  [Select][+][-]
  1. IF NOT(SynEdit.SelAvail)Then
  2. begin
  3.    MyDropItem.Enabled := False;
  4. end;
  5.  
But even when i did Highlight a text it wouldn't Enabled itself :p
(Tried it with the NOT code but not with the Else yet.. That could be the problem) Maybe its not what im looking for.
Thanks again Martin :D

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8462
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit Questions
« Reply #5 on: August 15, 2010, 01:57:39 am »
Well you need to show more of your code.

Where (in which event) to you do the "if", maybe you check at a time where it hasn't been changed yet?

Also you only pasted code, to set enabled to False? I assume you also have a line to set it to True?

why not
xxx.Enabled := {not} Synedit.selavail;
?


There is an event Synedit.OnStatusChange
    property OnStatusChange: TStatusChangeEvent

  TStatusChangeEvent = procedure(Sender: TObject; Changes: TSynStatusChanges)
    of object;

  TSynStatusChange = (scCaretX, scCaretY,
    scLeftChar, scTopLine, scLinesInWindow,
    scInsertMode, scModified, scSelection, scReadOnly
   );
  TSynStatusChanges = set of TSynStatusChange;


if the reason is scSelection then the selection changed (either on, off or content)

you can also do
    procedure RegisterStatusChangedHandler(AStatusChangeProc: TStatusChangeEvent; AChanges: TSynStatusChanges);
    procedure UnRegisterStatusChangedHandler(AStatusChangeProc: TStatusChangeEvent);

in which case you only get called for the events in your filter/mask

captian jaster

  • Guest
Re: SynEdit Questions
« Reply #6 on: August 15, 2010, 01:59:14 am »
TI fixed just now using the SelText code
Turns out i did need the Else code.
Code: Pascal  [Select][+][-]
  1. procedure TMainForm.EditDropClick(Sender: TObject);
  2. begin
  3.   IF(EditBox.SelText = '')Then
  4.   begin
  5.     CopyItem.Enabled := False;
  6.     CutItem.Enabled := False;
  7.   end Else
  8.   begin
  9.     CopyItem.Enabled := True;
  10.     CutItem.Enabled := True;
  11.   end;
  12. end;  
  13.  
  14.  
« Last Edit: August 15, 2010, 02:15:59 am by captain jaster »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8462
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit Questions
« Reply #7 on: August 15, 2010, 02:05:31 am »
ok I mis-assumed ...

in the OnSynEditStatuschanged

if scSelection in Changes then begin
  CopyItem.Enabled := SynEdit.SelAvail;
  CutItem.Enabled := SynEdit.SelAvail;
end;

much shorter.
and faster too.

captian jaster

  • Guest
Re: SynEdit Questions
« Reply #8 on: August 15, 2010, 02:16:30 am »
Cool..
Ill work on the soon ;D
Thanks

 

TinyPortal © 2005-2018