Recent

Author Topic: Memo1 Inquiry  (Read 2884 times)

dbannon

  • Hero Member
  • *****
  • Posts: 1165
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Memo1 Inquiry
« Reply #15 on: December 26, 2018, 08:00:33 am »
I suspect that  lucamar forgot SelLength := 0; So, Jurassic Pork (great avatar!) version is correct -

Code: Pascal  [Select][+][-]
  1. Memo1.SelStart := 0;
  2. Memo1.SelLength:=0;

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

lucamar

  • Hero Member
  • *****
  • Posts: 3077
Re: Memo1 Inquiry
« Reply #16 on: December 26, 2018, 08:27:21 am »
I suspect that  lucamar forgot SelLength := 0; So, Jurassic Pork (great avatar!) version is correct -
Code: Pascal  [Select][+][-]
  1. Memo1.SelStart := 0;
  2. Memo1.SelLength:=0;

Davo

Not really forgot, but deemed it unnecessary since we had just loaded the file. But yes, for general use it's more correct to set both, although in the inverse order: first SelLength := 0 and then SelStart := whatever :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

dbannon

  • Hero Member
  • *****
  • Posts: 1165
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Memo1 Inquiry
« Reply #17 on: December 26, 2018, 10:05:11 am »
......although in the inverse order: first SelLength := 0 and then SelStart := whatever :)

Interesting. I call that pair 20 times in my current project and I always SelStart then SelLength and never had an issue. Admittedly many are called on TKMemo rather than TMemo but very similar.

David
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

lucamar

  • Hero Member
  • *****
  • Posts: 3077
Re: Memo1 Inquiry
« Reply #18 on: December 26, 2018, 11:14:07 am »
Interesting. I call that pair 20 times in my current project and I always SelStart then SelLength and never had an issue. Admittedly many are called on TKMemo rather than TMemo but very similar.

David

It's really nitpicking :) If SelLength is not zero and you set SelStart you force the memo to initiate a selection update. By first setting SelLength to zero you avoid it.

It's not very important unless you have a really long text with a really long selection.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

dbannon

  • Hero Member
  • *****
  • Posts: 1165
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Memo1 Inquiry
« Reply #19 on: December 26, 2018, 12:00:44 pm »
It's really nitpicking :) If SelLength is not zero and you set SelStart you force the memo to initiate a selection update. By first setting SelLength to zero you avoid it.

It's not very important unless you have a really long text with a really long selection.

Yeah, interesting. in TKMemo (where my interests lie) there is a SelStart, SelEnd and a Sellength. Now, obviously, given any two, you calc the third. But I'd have to dig through the src to understand the significance. TKMemo understands negative selection, if you wipe with mouse right to left you get a different result than visa versa.

So, if SelStart is, say 1000 and selLength is 0, SelEnd is also 1000. If I then set SelStart to zero, I think SelEnd remains at 1000 and, of course, so is SelLength. I think......

An experiment for when i have nothing better to do ....

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

 

TinyPortal © 2005-2018