³ò àB[Fc@sšdZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd „Z d „Z d „Z d „Z d „Z d„Zd„Zd„ZdS(sý This module documents functions that implement line operations in gtk.TextBuffer. @author: Lateef Alabi-Oki @organization: The Scribes Project @copyright: Copyright (c) 2005 Lateef Alabi-Oki @license: GNU GPLv2 or Later @contact: mystilleef@gmail.com cCs·ddkl}||ƒ}|iƒ}t|ƒ\}}|iƒ}d|i||ƒ}|iƒ|i||ƒ|iƒ|i |ƒ}|i ƒ|i |ƒ|i |ƒdS(s} Duplicate line or selected lines. @param textbuffer: Reference to a buffer. @type textbuffer: A gtk.TextBuffer object. iÿÿÿÿ(tget_cursor_iterators N( tSCRIBES.cursorRtget_line_offsett__get_boundariest get_offsettget_texttbegin_user_actiontinserttend_user_actiontget_iter_at_offsett forward_linetset_line_offsett place_cursor(t textbufferRtiteratort cursor_offsettstarttendt end_offsetttext((splugins/Lines/lines.pytduplicate_line s        cCsi|iƒo|iƒ\}}n)ddkl}||ƒ}|iƒ}t|ƒ|iƒ||fS(sÐ Get start and end of a line or selection. @param textbuffer: Reference to a buffer. @type textbuffer: A gtk.TextBuffer object. @return: Start and end of line(s) to be copied. @rtype: A Tuple object. iÿÿÿÿ(R(tget_has_selectiontget_selection_boundsRRtcopyt__backward_to_line_starttforward_to_line_end(R RRR((splugins/Lines/lines.pyR6s     cCs2x+to#|iƒodSn|iƒqWdS(N(tTruet starts_linet backward_char(R((splugins/Lines/lines.pyRJs cCsKddkl}||ƒ}|i|ƒ}|iƒ}|iƒ||fS(s Get the beginning and end position of a line in a gtk.TextBuffer. @param textbuffer: The textbuffer to operate on. @type textbuffer: A gtk.TextBuffer object. @return: The beginning and end position of a line. @rtype: A Tuple object containing a pair of gtk.TextIter. iÿÿÿÿ(tget_cursor_line(RRtget_iter_at_lineRR(R Rt cursor_linetbegin_positiont end_position((splugins/Lines/lines.pytget_line_boundsPs    cCsP|i|ƒ}|iƒodSn|iƒ}|iƒ|i||ƒ}|S(sÔ Get the text on a line in the editor's buffer. @param line: A line in the text editor's buffer. @type line: An Integer object. @param text: The text on a line in the buffer. @type text: A String object. t(Rt ends_lineRRR(R tlineR R!R((splugins/Lines/lines.pytget_text_on_lineas    cCsAt|ƒ\}}|iƒdjotSn|i||ƒtS(s Select the current line in a gtk.TextBuffer. The current line is the line the cursor is on. @param textbuffer: The textbuffer to operate on. @type textbuffer: A gtk.TextBuffer object. @return: Return True if the operation is successful. @rtype: A Boolean object. s t(s R'(R"tget_chartFalset select_rangeR(R R R!((splugins/Lines/lines.pyt select_liness cCst|ƒ\}}|iƒdjo%|iƒdjot|ƒdSn|iƒdjo%|iƒdjot|ƒdSn|iƒdjo%|iƒd jot|ƒdSn|iƒo%|iƒd jot|ƒdSn|iƒ|iƒ|i||ƒ|iƒdS( s‘ Delete a the cursor line in a gtk.TextBuffer. @param textbuffer: The text buffer to operate on. @type textbuffer: A gtk.TextBuffer object. s NR'(s (s (s (s(s(s(s( R"R(tdelete_empty_linetdelete_empty_last_linetdelete_last_linet forward_charRtdeleteR(R R R!((splugins/Lines/lines.pyt delete_line…s$& & &      cCsiddkl}||ƒ}|i|ƒ}|iƒ}|iƒ|iƒ|i||ƒ|iƒdS(s€ Delete an empty cursor line. @param textbuffer: The text buffer to operate on. @type textbuffer: A gtk.TextBuffer object. iÿÿÿÿ(RN(RRRRR/RR0R(R RRR R!((splugins/Lines/lines.pyR,¤s     cCs¨t|ƒ\}}|iƒ}|o|iƒdjo|iƒ}|iƒn+|iƒ}|iƒ|iƒ|iƒ|iƒ|i||ƒ|iƒn|S(s… Delete an empty last cursor line. @param textbuffer: The text buffer to operate on. @type textbuffer: A gtk.TextBuffer object. s (s ( R"t backward_lineR(RR/RRR0R(R R R!tresult((splugins/Lines/lines.pyR-µs       cCsNt|ƒ\}}|iƒ|iƒ|i||ƒt|ƒ|iƒdS(s” Delete the last cursor line if it contains text. @param textbuffer: The text buffer to operate on. @type textbuffer: A gtk.TextBuffer object. N(R"R/RR0R-R(R R R!((splugins/Lines/lines.pyR.Ìs    cCs§yPd}t|ƒ\}}ddkl}|id|ƒ\}}|id|tƒ}|iƒ|i||ƒ|i |ƒ}|i ƒ}|i ƒo3x"|i ƒdjo|i ƒqW|i ƒnx"|i ƒdjo|i ƒqÐW|i||ƒ|i |ƒ}|i|dƒ|iƒtjo|i|ƒn|iƒWnPtj oD|djotSn|iƒtjo|i|ƒntSnXtS( sæ Join next line in the buffer to the current one. @param textbuffer: The text buffer to operate on. @type textbuffer: A gtk.TextBuffer object. @return: Return True if the operation is successful. @rtype: A Boolean object. iÿÿÿÿ(tTEXT_SEARCH_VISIBLE_ONLYs t s N(R5s (R5s (tNoneR"tgtkR4tforward_searcht create_markRRR0tget_iter_at_markRRR(R/Rt get_deletedR)t delete_markRt TypeError(R tmarkR R!R4t begin_matcht end_match((splugins/Lines/lines.pyt join_lineÛs:      cCsÀd}t|ƒ}|odi|ƒ}nt|ƒ\}}|iƒ|i|dƒt|ƒ\}}|iƒ|i|ƒ|o|i||ƒn|iƒddk l }||ƒS(sÐ Shift the text on current line to the next one. @param textbuffer: The text buffer to operate on. @type textbuffer: A gtk.TextBuffer object. @return: Return the line freed. @rtype: A Integer object. R#s iÿÿÿÿ(RN( R6tget_beginning_spacestjoinR"RRR2R RRR(R tstringtspacesR R!R((splugins/Lines/lines.pytfree_line_aboves      cCsûd}t|ƒ}|odi|ƒ}nt|ƒ\}}|iƒ|iƒdjo|iƒ|i|dƒn|iƒ|i|dƒt|ƒ\}}|iƒ|i |ƒ|o|i||ƒn|i ƒddk l }||ƒS(sÅ Free the line below the current one. @param textbuffer: The text buffer to operate on. @type textbuffer: A gtk.TextBuffer object. @return: Return the line freed. @rtype: A Integer object. R#s R'iÿÿÿÿ(RN(s s( R6RBRCR"RR(R/RR R RRR(R RDRER R!R((splugins/Lines/lines.pytfree_line_belows&        cCs{t|ƒ\}}|iƒdjodSng}|iƒ}x5|iƒdjo!|i|iƒƒ|iƒqBW|S(s# Get the spaces at the beginning of the current line. Spaces constitute either space or tab characters. @param textbuffer: The text buffer to operate on. @type textbuffer: A gtk.TextBuffer object. @return: Return a list of spaces at the beginning of a line. @rtype: A List object. s R'R5s (s sN(R5s (R"R(R6RtappendR/(R R R!REttransition_position((splugins/Lines/lines.pyRB<s  cCsŒt|ƒ\}}|iƒdjotSnddkl}||ƒ}|iƒdjotSn|iƒ|i||ƒ|iƒtS(Ns R'iÿÿÿÿ(R(s s(s s( R"R(R)RRRR0RR(R R R!Rtcursor_position((splugins/Lines/lines.pytdelete_cursor_to_line_endRs   cCs‰t|ƒ\}}|iƒdjotSnddkl}||ƒ}|i|ƒotSn|iƒ|i||ƒ|iƒt S(Ns R'iÿÿÿÿ(R(s s( R"R(R)RRtequalRR0RR(R R R!RRJ((splugins/Lines/lines.pytdelete_cursor_to_line_begin_s   N(t__doc__RRRR"R&R+R1R,R-R.RARFRGRBRKRM(((splugins/Lines/lines.pyss            (