Recent

Author Topic: SynEdit empty  (Read 447 times)

BubikolRamios

  • Full Member
  • ***
  • Posts: 240
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-2.0.12-fpc-3.2.0-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8481
  • 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: 943
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