Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi,

Here are two methods for navigating through sentences :

def select_next_sentence(event=None):
    doc = XSCRIPTCONTEXT.getDocument()
    controller = doc.CurrentController
    T = doc.Text
    cursor = T.createTextCursor()
    cursor.gotoRange(controller.ViewCursor.End, False)
    if cursor.isEndOfSentence():
        cursor.gotoNextSentence(False)
    else:
        cursor.gotoStartOfSentence(False)
    cursor.gotoEndOfSentence(True)
    controller.select(cursor)

def select_previous_sentence(event=None):
    doc = XSCRIPTCONTEXT.getDocument()
    controller = doc.CurrentController
    T = doc.Text
    cursor = T.createTextCursor()
    cursor.gotoRange(controller.ViewCursor.End, False)
    if cursor.isEndOfSentence():
        cursor.gotoPreviousSentence(False)
    else:
        cursor.gotoStartOfSentence(False)
    cursor.gotoEndOfSentence(True)
    controller.select(cursor)

Regards.

Hi,

Here are two methods for navigating through sentences :sentences, which you can assign to the control you want:

def select_next_sentence(event=None):
    doc = XSCRIPTCONTEXT.getDocument()
    controller = doc.CurrentController
    T = doc.Text
    cursor = T.createTextCursor()
    cursor.gotoRange(controller.ViewCursor.End, False)
    if cursor.isEndOfSentence():
        cursor.gotoNextSentence(False)
    else:
        cursor.gotoStartOfSentence(False)
    cursor.gotoEndOfSentence(True)
    controller.select(cursor)

def select_previous_sentence(event=None):
    doc = XSCRIPTCONTEXT.getDocument()
    controller = doc.CurrentController
    T = doc.Text
    cursor = T.createTextCursor()
    cursor.gotoRange(controller.ViewCursor.End, False)
    if cursor.isEndOfSentence():
        cursor.gotoPreviousSentence(False)
    else:
        cursor.gotoStartOfSentence(False)
    cursor.gotoEndOfSentence(True)
    controller.select(cursor)

Regards.