Page 2 of 3

Re: Forward DEL

Posted: Thu Jul 23, 2020 5:20 pm
by Klaus
Please read my first posting again (or at all), everything is in there!

Re: Forward DEL

Posted: Thu Jul 23, 2020 5:31 pm
by richmond62
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.

Re: Forward DEL

Posted: Thu Jul 23, 2020 5:47 pm
by dunbarx
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

Re: Forward DEL

Posted: Thu Jul 23, 2020 5:48 pm
by dunbarx
Will work with parens:
Will work without as well. Parens likely more readable.

Craig

Re: Forward DEL

Posted: Thu Jul 23, 2020 5:52 pm
by richmond62
Because the selectedChunk returns:

char 5 to 4 of field 1
So it does.

Daft logic whichever way you slice things. :D

Re: Forward DEL

Posted: Thu Jul 23, 2020 6:26 pm
by dunbarx
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

Re: Forward DEL

Posted: Thu Jul 23, 2020 6:32 pm
by richmond62
No: by daft I mean that 'char 5 to 4' goes backwards, and
neither char 4 nor char 5 are selected.

Re: Forward DEL

Posted: Thu Jul 23, 2020 6:44 pm
by dunbarx
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

Re: Forward DEL

Posted: Thu Jul 23, 2020 6:45 pm
by dunbarx
So, and I am only partly serious, and only mostly daft, would you do the "char 4.5" thing?

What else would do?

Craig

Re: Forward DEL

Posted: Thu Jul 23, 2020 7:58 pm
by richmond62
What else would do?
I'd do the Hokey-Cokey:

https://youtu.be/ufndD8lq95E

Re: Forward DEL

Posted: Thu Jul 23, 2020 11:16 pm
by dunbarx
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

Re: Forward DEL

Posted: Fri Jul 24, 2020 10:20 am
by AxWald
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!

Re: Forward DEL

Posted: Fri Jul 24, 2020 4:56 pm
by jacque
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.

Re: Forward DEL

Posted: Sat Jul 25, 2020 12:04 am
by bwmilby
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.

Re: Forward DEL

Posted: Sat Jul 25, 2020 1:47 pm
by dunbarx
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