Forward DEL

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Forward DEL

Post by Klaus » Thu Jul 23, 2020 5:20 pm

Please read my first posting again (or at all), everything is in there!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Forward DEL

Post by richmond62 » Thu Jul 23, 2020 5:31 pm

Result with NO text selected in a field: char 2 to 1 of field 1 -> word 2 > word 4!
Um . . . well, yes, possibly.

But still bloody bad logic.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Forward DEL

Post by dunbarx » Thu Jul 23, 2020 5:47 pm

Because the selectedChunk returns:

Code: Select all

char 5 to 4 of field 1
for a blinking cursor, and a range if an actual selection of multiple chars.

But it is word 2 that matters

Klaus had this as well.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Forward DEL

Post by dunbarx » Thu Jul 23, 2020 5:48 pm

Will work with parens:
Will work without as well. Parens likely more readable.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Forward DEL

Post by richmond62 » Thu Jul 23, 2020 5:52 pm

Because the selectedChunk returns:

char 5 to 4 of field 1
So it does.

Daft logic whichever way you slice things. :D

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Forward DEL

Post by dunbarx » Thu Jul 23, 2020 6:26 pm

Richmond.

For the selectedChunk in a fld 1:

If you have selected char 4 to 7 of "123456789", you get "char 4 to 7 of field 1".

If you have selected char 4 of "123456789", you get "char 4 to 4 of field 1".

Now say you only have the insertion point after char 4. By "daft", do you mean why don't you get "char 4.5 to 4.5 of field 1", instead of what you do get, which is "char 5 to 4 of field 1"?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Forward DEL

Post by richmond62 » Thu Jul 23, 2020 6:32 pm

No: by daft I mean that 'char 5 to 4' goes backwards, and
neither char 4 nor char 5 are selected.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Forward DEL

Post by dunbarx » Thu Jul 23, 2020 6:44 pm

By "daft" I mean everybody here, especially me.

You must:

Code: Select all

on rawkeyDown tKey
   if tKey = 65535 then delete char word 4 of the selectedChunk + 1 of fld 1
end rawkeyDown
NOT word 2.

It is just the way the selectedChunk works.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Forward DEL

Post by dunbarx » Thu Jul 23, 2020 6:45 pm

So, and I am only partly serious, and only mostly daft, would you do the "char 4.5" thing?

What else would do?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Forward DEL

Post by richmond62 » Thu Jul 23, 2020 7:58 pm

What else would do?
I'd do the Hokey-Cokey:

https://youtu.be/ufndD8lq95E

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Forward DEL

Post by dunbarx » Thu Jul 23, 2020 11:16 pm

Hokey. Period.
No: by daft I mean that 'char 5 to 4' goes backwards, and
neither char 4 nor char 5 are selected.
If they weren't backward, you would be talking about char 4 to 5, no? A simple chunk.

So how do you identify the position of a blinking cursor? It is indeed between 4 and 5, but not exactly either, eh?, and so, decimals (4.5) notwithstanding, it was decided to run the char positions backward.

Craig

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Forward DEL

Post by AxWald » Fri Jul 24, 2020 10:20 am

Hi,

try this:

Code: Select all

on mouseUp
   get the selectedchunk
   if it is empty then exit mouseUp
   put word 2 of it into myStart
   put word 4 of it into myEnd
   put word 6 to -1 of it into myTarget
   
   if myStart > myEnd then
      put "delete char " & myStart & " of " & myTarget into myCmd
   else
      put "delete char " & myStart & " to " & myEnd & " of " & myTarget into myCmd
   end if
   do myCmd
end mouseUp
Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Forward DEL

Post by jacque » Fri Jul 24, 2020 4:56 pm

richmond62 wrote:
Thu Jul 23, 2020 6:32 pm
No: by daft I mean that 'char 5 to 4' goes backwards, and
neither char 4 nor char 5 are selected.
This is a direct port of HC syntax, so blame Apple. It allows you to determine whether an actual selection exists or just a cursor insertion.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bwmilby
Posts: 462
Joined: Wed Jun 07, 2017 5:37 am
Contact:

Re: Forward DEL

Post by bwmilby » Sat Jul 25, 2020 12:04 am

Think of it this way:
The first number indicates the start of the selection highlight (i.e. the left of the indicated character)
The second number indicates the end of the selection highlight (i.e. the right of the indicated character)

So with that definition, the cursor (selection) is precisely defined by those 2 positions as being between the characters.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Forward DEL

Post by dunbarx » Sat Jul 25, 2020 1:47 pm

Brian.

Richmond was on about the order of start and finish values in the selectedChunk (for a blinking cursor) being backwards. Where:

Code: Select all

the length of the selection
equals "0", This is yet another way to determine whether one or more actual chars are selected, or only a blinking cursor lives in the text.

The start and finish values, as you posted, are reversed in this case. They would only apply to actual selected chars, not a cursor. He thinks this is daft.

Craig
Last edited by dunbarx on Sat Jul 25, 2020 6:13 pm, edited 1 time in total.

Post Reply