³ς ’υEc@s@dZd„Zd„Zd„Zd„Zd„Zd„ZdS(sς This module contains functions that perform word operations. The functions are designed to be generic and thus can be used accross this project or in any PyGTK+ project. For the purpose of this project, a word is a sequence of alphanumeric characters that, optionally, may contain an underscore ("_") or a dash ("-") character. @author: Lateef Alabi-Oki @organiation: The Scribes Project @copyright: Copyright Β© 2005 Lateef Alabi-Oki @license: GNU GPLv2 or Later @contact: mystilleef@gmail.com cCs΅|iƒp |iƒotSn|iƒ}|iƒtjo|djoqZtSn|iƒotSn|iƒ|iƒ}|iƒ|iƒp |djotSntS(s€ Check if the iterator is at the beginning of a word. For the purpose of this project, a word is a sequence of alphanumeric characters that, optionally, may contain an underscore ("_") or a dash ("-") character. @param iterator: A single position in a text buffer. @type iterator: A gtk.TextIter object. @return: True if the iterator is at the beginning of a word, false otherwise. @rtype: A Boolean object. t-t_(RR(RR( t ends_linet ends_wordtFalsetget_chartisalnumt starts_linetTruet backward_chart forward_char(titeratort character((splugins/Selection/word.pyt starts_word#s      cCs‰|iƒotSn|iƒ}|iƒp |djotSn|iƒ|iƒ}|iƒ|iƒp |djotSntS(s« Check if the iterator is at the end of a word in a text buffer. For the purpose of this project, a word is a sequence of alphanumeric characters that, optionally, may contain an underscore ("_") or a dash ("-") character. @param iterator: A single position in the text buffer. @type iterator: A gtk.TextIter object. @return: True if the iterator is at the end of a word, False otherwise. @rtype: A Boolean object. RR(RR(RR(RRRRR R R(R R ((splugins/Selection/word.pyRNs     cCsΜt|ƒp t|ƒotSn|iƒp |iƒotSn|iƒ}|iƒtjo|djoq|tSn|iƒ|iƒ}|iƒ|iƒtjo|djoqΘtSnt S(sŠ Check if the iterator is inside a word. For the purpose of this project, a word is a sequence of alphanumeric characters that, optionally, may contain an underscore ("_") or a dash ("-") character. @param iterator: A single position in a text buffer. @type iterator: A gtk.TextIter object. @return: True if the iterator is inside a word, false otherwise. @rtype: A Boolean object. RR(RR(RR( R RRRRRRR R R(R R ((splugins/Selection/word.pyt inside_wordls"      cCs%d}t|ƒoA|iƒ}x"t|ƒtjo|iƒq"W||f}nΞt|ƒor|iƒ}|iƒ}x"t|ƒtjo|iƒq|Wx"t|ƒtjo|iƒq‘W||f}nOt|ƒoA|iƒ}x"t|ƒtjo|iƒqοW||f}n|S(sΡ Retrieve the beginning and ending position of word. This function determines if an iterator is at the beginning of, end of, or within a word. If it is, the boundaries of the word are returned, otherwise, nothing is returned. @param iterator: A single position in a text buffer. @type iterator: A gtk.TextIter object. @return: The position of a word in a text buffer or None. @rtype: A Tuple object containing a pair of gtk.TextIter objects or or None. N(tNoneR tcopyRRR RR (R tvaluetnavigational_iteratortbegin_iteratort end_iterator((splugins/Selection/word.pytget_word_boundaryŽs(       cCs5t|ƒ}|o|i|d|dƒ}n|S(s{ Given a gtk.TextIter, get a word in a text buffer. @param textbuffer: A text buffer. @type textbuffer: A gtk.TextBuffer object. @param iterator: A single position in a text buffer. @type iterator: A gtk.TextIter object. @return: A word around the position specified by a gtk.TextIter, or None if no word was found around the gtk.TextIter. @rtype: A String object. ii(Rtget_text(t textbufferR tresult((splugins/Selection/word.pytget_word±s cCs9d}t|ƒ}|o|i|d|dƒn|S(sn Given a gtk.TextIter, select a word in a text buffer. @param textbuffer: A text buffer. @type textbuffer: A gtk.TextBuffer object. @param iterator: A single position in a text buffer. @type iterator: A gtk.TextIter object. @return: Return the position of the selected word, or none if no words were found for selection. @rtype: A Tuple object or None iiN(RRt select_range(RR R((splugins/Selection/word.pyt select_wordΕs  N(t__doc__R RRRRR(((splugins/Selection/word.pys!s  +  " #