Re: [orca-list] I need help



Hey JosÃ.

I'm going to take these in reverse order:

do not know if I could explain clearly because my English is not very
good.

Your English is awesome. And every day I am grateful to be part of such
an amazing, international community filled with folks who have excellent
skills with English because my ability to write in any other language
than English does not exist. And we've all seen me not even get English
right on a number of occasions. <shrugs and smiles>

Having gotten that out of the way....

When I press the F11 key eclipse starts my application,  suspends the 
execution in the first line of the main method and put the cursor in 
that line.

So the caret is in an object we'll call Foo. Foo is an accessible of
pyatspi.ROLE_TEXT if memory about Eclipse objects' roles serves me. And
let's give Foo a caret offset while we're at it. How about 500?

At that moment orca receives an event of object:text-caret and the 
function _presentTextAtNewCaretPosition is executed.

And what gets passed along to your function is the event.source which
emitted the caret-moved event, in other words Foo.

Inside this function I have the following sequence of statements:
             obj = otherObj or event.source

My guess is that otherObj is None. So obj winds up being the
event.source, i.e. obj is now Foo.

             [line, caretOffset, startOffset] = self.getTextLineAtCaret(obj)

getTextLineAtCaret() basically does a queryText(). From the resulting
accessible text interface, it asks for the caretOffset. (Foo's text
interface returns an offset of 500) Then we ask for the line at the
caret (Foo's text interface returns the line at the caret offset of
500).

             print "obj = ", line, caretOffset, startOffset

Looks like the line at the offset of 500 in Foo is
'boolean restart = true;'

             if self._lastTextCaretMoved:

Doesn't exist, so this doesn't happen:

                 [line, caretOffset, startOffset] = self.getTextLineAtCaret(self._lastTextCaretMoved)
                 print "self._lastTextCaretMoved = ", line, caretOffset, startOffset

Moving on....

             self.sayLine(obj)
             self._lastTextCaretMoved = obj

You speak the line and (here's the important bit)
self._lastTextCaretMoved becomes obj, which means
self._lastTextCaretMoved becomes our friend Foo.

[...]

Now I press the F6 key.

Okay.

Eclipse executes the first line of the main method,  suspends the 
execution and put the cursor in the second line of the main method.

If you've gone from the first line of the main method (which lives in
the text object we're calling Foo) to the second line of the main
method, my guess is that you're still in Foo. You've only moved a line,
so let's make the caret offset be 550.

Again orca receives an event of object:text-caret and the function 
_presentTextAtNewCaretPosition is executed.

Right. So let me copy and paste those lines from your script.

obj = otherObj or event.source

I'm guessing otherObj is still None. Therefore obj becomes the
event.source. The event.source is the thing which emitted the
caret-moved event. If you're in the second line of the main method, the
event.source should be Foo. Thus obj becomes Foo.

[line, caretOffset, startOffset] = self.getTextLineAtCaret(obj)

getTextLineAtCaret() queries the text interface of Foo. Asks Foo's text
interface what the offset is. Foo's text interface claims 550. Great, we
get the line of text at offset 550 which is apparently
'System.out.println("line 1");'

print "obj = ", line, caretOffset, startOffset

So you print out 'System.out.println("line 1");'

if self._lastTextCaretMoved:

This time we have self._lastTextCaretMoved. As you'll recall from above,
when we processed the event at caretOffset 500 we set
self._lastTextCaretMoved to obj, and obj was Foo. So
self._lastTextCaretMoved is Foo.

[line, caretOffset, startOffset] = self.getTextLineAtCaret(self._lastTextCaretMoved)

So you call getTextLineAtCaret() with Foo as the argument.
getTextLineAtCaret() queries the accessible text interface for Foo. We
ask it for the caret offset. Foo's accessible text interface says 550.
We get the line of text at the offset of 550 and as you probably guessed
already, the text at the offset of 550 is still
'System.out.println("line 1");'

<smile>

I think I should see the following:
     System.out.println("line 1");
         boolean restart = true;

If that's what you want to see, try saving line in
self._lastTextCaretMoved instead of obj.

In other words, Foo is just an accessible object. It's not a snapshot in
time with a preserved caret offset or string or anything.

Does this make sense?
--joanie




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]