Oberon Community Platform Forum
October 23, 2019, 02:47:12 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: 1 [2] 3
  Print  
Author Topic: Word selection on double clicking  (Read 34823 times)
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #15 on: April 04, 2008, 01:53:36 PM »

I forgot to say, you must also change:
in PointerDown:
Code:
selection.SetFromTo(FindPosWordLeft(utilreader, pos),   FindPosWordRight(utilreader, pos))
and in PointerMove:
Code:
IF pos < selection.from.GetPosition() THEN pos := FindPosWordLeft(utilreader, pos);
ELSE pos := FindPosWordRight(utilreader, pos) END;
Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #16 on: April 04, 2008, 02:15:08 PM »

The code traps into an endless loop because you don't check for ~utilreader.eot (if at EOT, utilreader.Read(ch) returns a 0 which is considered as IsWhitespace(ch)).
It's definitely an improvement!
« Last Edit: April 04, 2008, 02:16:58 PM by staubesv » Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #17 on: April 04, 2008, 02:45:41 PM »

Quote
The code traps into an endless loop because you don't check for ~utilreader.eot
sorry, forgot  Roll Eyes
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #18 on: April 04, 2008, 08:28:38 PM »

Sorry, I do not want to start a new topic.
If this talk of the PET, I'm wanted to ask:
It may add to the autosave feature, before compiling?
Personally, I have already had many times suffer because of a lack of this feature...
    
To realize what it does not require complex logic, requires only a few lines of the code.
« Last Edit: April 04, 2008, 08:38:02 PM by BohdanT » Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #19 on: April 04, 2008, 11:28:21 PM »

PET can optionally store on compile since revision 1152. To enable this feature, set Applications.PET.General.BackupOnCompile to TRUE in AosConfig.XML. If enabled, PET will display an output on the kernel log that a backup has been created. Note that the file will always be encoded in the Oberon text format.
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #20 on: April 05, 2008, 01:41:13 AM »

Many thanks! Grin
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #21 on: April 07, 2008, 11:01:02 AM »

Code:
PROCEDURE FindPosWordLeft*(utilreader: AosTexts.TextReader; pos : LONGINT) : LONGINT;
VAR ch : AosTexts.Char32;
BEGIN
utilreader.SetPosition(pos); utilreader.SetDirection(-1);utilreader.ReadCh(ch);
IF (ch = AosTexts.NewLineChar) THEN utilreader.ReadCh(ch);END;
IF AosTextUtilities.IsAlphaNum(ch)OR(ch=ORD("_")) THEN
REPEAT utilreader.ReadCh(ch) UNTIL (~AosTextUtilities.IsAlphaNum(ch))&(ch#ORD("_"));
ELSIF AosTextUtilities.IsWhiteSpace(ch) THEN
REPEAT utilreader.ReadCh(ch) UNTIL (utilreader.eot)OR(~AosTextUtilities.IsWhiteSpace(ch));
ELSE   
REPEAT  utilreader.ReadCh(ch) UNTIL (ch=ORD("_"))OR(AosTextUtilities.IsAlphaNum(ch))OR(AosTextUtilities.IsWhiteSpace(ch));
END;
IF utilreader.eot THEN RETURN 0;END;
RETURN utilreader.GetPosition() + 2
END FindPosWordLeft;

PROCEDURE FindPosWordRight*(utilreader: AosTexts.TextReader; pos : LONGINT) : LONGINT;
VAR ch : AosTexts.Char32;
BEGIN
utilreader.SetPosition(pos); utilreader.SetDirection(1);utilreader.ReadCh(ch);
IF (ch = AosTexts.NewLineChar) THEN utilreader.SetPosition(pos-1); utilreader.ReadCh(ch);END;
IF AosTextUtilities.IsAlphaNum(ch)OR(ch=ORD("_")) THEN
REPEAT utilreader.ReadCh(ch) UNTIL (~AosTextUtilities.IsAlphaNum(ch))&(ch#ORD("_"));
ELSIF AosTextUtilities.IsWhiteSpace(ch) THEN
REPEAT utilreader.ReadCh(ch) UNTIL (utilreader.eot)OR(~AosTextUtilities.IsWhiteSpace(ch));
ELSE
REPEAT  utilreader.ReadCh(ch) UNTIL (ch=ORD("_"))OR(AosTextUtilities.IsAlphaNum(ch))OR(AosTextUtilities.IsWhiteSpace(ch));
END;
IF utilreader.eot THEN RETURN utilreader.GetPosition();END;
RETURN utilreader.GetPosition() - 1
END FindPosWordRight;


also change:
in PointerDown:
Code:
selection.SetFromTo(FindPosWordLeft(utilreader, pos),   FindPosWordRight(utilreader, pos))
and in PointerMove:
Code:
IF pos < selection.from.GetPosition() THEN pos := FindPosWordLeft(utilreader, pos);
ELSE pos := FindPosWordRight(utilreader, pos) END;
« Last Edit: April 07, 2008, 11:03:49 AM by BohdanT » Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #22 on: April 16, 2008, 07:15:43 PM »

I'm going to merge the suggestions here into the development trunk. For now, I'm quite busy with other things so that will take some time...
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #23 on: June 17, 2008, 09:08:31 PM »

Quote
For now, I'm quite busy with other things so that will take some time...
   
Sven, already have a bit more time? Smiley

I wanted to give an example.
Let the symbol "|" will show the cursor.
Now if double-click in such a situation
Code:
my|var:= value;
then selected appears "myvar"
if
Code:
myva|r:= value;
then selected appears "myvar:"
Such a result is it good? Wink
Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #24 on: June 18, 2008, 12:48:36 PM »

In revision 1286, you'll find a first try to implement the double-click-thing.

Now...
- double-clicking a word selects the word (underscore considered a legal letter)
- double-clicking after end-of-line selects the line
- double-clicking whitespace selects the whitespace

Issues:
- Does not work correctly at the first word of a text (bug in AosTexts.TextReader)
- Cannot select last line of text
- Is not consistent with CTRL-SHIRT-Cursor selecting and CTRL-Cursor movement

What do you think?
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #25 on: June 18, 2008, 01:48:03 PM »

Wow how much the new code!

1. Navigation is not working in PET.    
When clicking in the "Program Structure" on the element, in the editor selected the entire text, beginning with the required element Smiley
2.
Quote
Does not work correctly at the first word of a text (bug in AosTexts.TextReader)
Strangely, I have no this error  Huh.
« Last Edit: June 18, 2008, 02:52:45 PM by BohdanT » Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #26 on: June 18, 2008, 02:47:59 PM »

Yes, it's quite a lot code because it haven't reused the FindPosWordX procedures in AosTextUtilities. The idea is that other editors (e.g. Eclipse) also use different behaviour for mouse/keyboard word selection. For me, I don't use that feature often so I'm not really sure whether this is a good or bad idea...
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #27 on: June 18, 2008, 03:31:33 PM »

Quote
Cannot select last line of text

Because the condition is not fulfilled
Code:
IF pos = cursor.GetPosition() THEN
   
   
I made a test before condition:
Quote
AosOut.String("DKL:");AosOut.Int(pos,5);AosOut.String("-");AosOut.Int(cursor.GetPosition(),5);AosOut.Ln;
and received the result:
Quote
DKL:103761-103760
DKL:103761-103760
DKL:103761-103760
i.e. it is changing variable pos  Roll Eyes
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #28 on: June 18, 2008, 04:22:56 PM »

Quote
- Is not consistent with CTRL-SHIRT-Cursor selecting and CTRL-Cursor movement
   
I did not understand the question. The handler PointerMove still uses AosTextUtilities.FindPosWordLeft and AosTextUtilities.FindPosWordRight.
Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #29 on: June 18, 2008, 04:25:07 PM »

Fixed last-line issue in revision 1294. For some unknown reasons, TextView.LayoutLine sets pos to text.GetLength()+1 but does not work anymore when restricting the value to text.GetLength()... Workaround: Check this case in TextView.PointerDown (sorry the workaround, but it would take too much time do understand all the layouting in full details). Thanks for your help!
Logged
Pages: 1 [2] 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!