Recent

Author Topic: SynEdit empty  (Read 1019 times)

BubikolRamios

  • Sr. Member
  • ****
  • Posts: 267
SynEdit empty
« on: February 10, 2022, 04:29:54 pm »
1. create
Lines.count = 0;
text = '';
ALL OK

2. Put some text in it, delete all
Lines count = 1 // appears that is logical
text <> ''// as it seems as if sentence does not see empty SynAdit as ''

How to tell there is nothing in SynEdit ?
lazarus 3.2-fpc-3.2.2-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: SynEdit empty
« Reply #1 on: February 10, 2022, 04:45:20 pm »
SynEdit does currently not store line endings.
But, if you retrieve the text, it will add a line ending to each line. So if Lines.Count=1 (with one empty line) then you get a line-ending back in the Text.

As for the "how to test", good question.
Maybe
   (Lines.Count=0) or ( (Lines.Count=1) and (Lines[0]='') )
Not great, but...

Warfley

  • Hero Member
  • *****
  • Posts: 1499
Re: SynEdit empty
« Reply #2 on: February 10, 2022, 04:54:28 pm »
If you don't care for spaces (which as synedit has arbitrary cursor positions you probably won't), this is the easiest:
Code: Pascal  [Select][+][-]
  1. SynEdit1.Text.Trim.IsEmpty

 

TinyPortal © 2005-2018