Forward DEL
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Forward DEL
Please read my first posting again (or at all), everything is in there!
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Forward DEL
Um . . . well, yes, possibly.Result with NO text selected in a field: char 2 to 1 of field 1 -> word 2 > word 4!
But still bloody bad logic.
Re: Forward DEL
Because the selectedChunk returns:
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
Code: Select all
char 5 to 4 of field 1
But it is word 2 that matters
Klaus had this as well.
Craig
Re: Forward DEL
Will work without as well. Parens likely more readable.Will work with parens:
Craig
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Forward DEL
So it does.Because the selectedChunk returns:
char 5 to 4 of field 1
Daft logic whichever way you slice things.

Re: Forward DEL
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
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
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Forward DEL
No: by daft I mean that 'char 5 to 4' goes backwards, and
neither char 4 nor char 5 are selected.
neither char 4 nor char 5 are selected.
Re: Forward DEL
By "daft" I mean everybody here, especially me.
You must:
NOT word 2.
It is just the way the selectedChunk works.
Craig
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
It is just the way the selectedChunk works.
Craig
Re: Forward DEL
So, and I am only partly serious, and only mostly daft, would you do the "char 4.5" thing?
What else would do?
Craig
What else would do?
Craig
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Forward DEL
Hokey. Period.
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
If they weren't backward, you would be talking about char 4 to 5, no? A simple chunk.No: by daft I mean that 'char 5 to 4' goes backwards, and
neither char 4 nor char 5 are selected.
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
Re: Forward DEL
Hi,
try this:
Have fun!
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
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!
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!
Re: Forward DEL
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.richmond62 wrote: ↑Thu Jul 23, 2020 6:32 pmNo: by daft I mean that 'char 5 to 4' goes backwards, and
neither char 4 nor char 5 are selected.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Forward DEL
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.
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.
Re: Forward DEL
Brian.
Richmond was on about the order of start and finish values in the selectedChunk (for a blinking cursor) being backwards. Where:
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
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
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.