³ò ¡õEc@sdZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd „Z d „Z d „Z d „Z d „Z dS(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 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(tSCRIBES.cursorRtget_iter_at_linetcopytforward_to_line_end(t textbufferRt cursor_linetbegin_positiont end_position((s plugins/BookmarkBrowser/lines.pytget_line_bounds s    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_lineRRtget_text(RtlineRRttext((s plugins/BookmarkBrowser/lines.pytget_text_on_line1s    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_rangetTrue(RRR((s plugins/BookmarkBrowser/lines.pyt select_lineCs 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 Rtdelete_empty_linetdelete_empty_last_linetdelete_last_linet forward_chartbegin_user_actiontdeletetend_user_action(RRR((s plugins/BookmarkBrowser/lines.pyt delete_lineUs$& & &      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(RRRRRRRR(RRRRR((s plugins/BookmarkBrowser/lines.pyRts     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_lineRRRRRRR(RRRtresult((s plugins/BookmarkBrowser/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 RRRRR(RRR((s plugins/BookmarkBrowser/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(R!s (R!s (tNoneR tgtkR tforward_searcht create_markRRRtget_iter_at_markRt backward_charRRtinsertt get_deletedRt delete_markRt TypeError(RtmarkRRR t begin_matcht end_match((s plugins/BookmarkBrowser/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( R"tget_beginning_spacestjoinR RR(Rt place_cursorRRR(RtstringtspacesRRR((s plugins/BookmarkBrowser/lines.pytfree_line_aboveÓs      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 Riÿÿÿÿ(RN(s s( R"R0R1R RRRR(t forward_lineR2RRR(RR3R4RRR((s plugins/BookmarkBrowser/lines.pytfree_line_belowís&        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 RR!s (s sN(R!s (R RR"RtappendR(RRRR4ttransition_position((s plugins/BookmarkBrowser/lines.pyR0 s  cCsŒt|ƒ\}}|iƒdjotSnddkl}||ƒ}|iƒdjotSn|iƒ|i||ƒ|iƒtS(Ns Riÿÿÿÿ(tget_cursor_iterator(s s(s s( R RRRR:RRRR(RRRR:tcursor_position((s plugins/BookmarkBrowser/lines.pytdelete_cursor_to_line_end"s   cCs‰t|ƒ\}}|iƒdjotSnddkl}||ƒ}|i|ƒotSn|iƒ|i||ƒ|iƒt S(Ns Riÿÿÿÿ(R:(s s( R RRRR:tequalRRRR(RRRR:R;((s plugins/BookmarkBrowser/lines.pytdelete_cursor_to_line_begin/s   N(t__doc__R RRRRRRR/R5R7R0R<R>(((s plugins/BookmarkBrowser/lines.pyss        (