B
?H°çãTã @ sØ d Z ddlZddlmZ ddlmZ ddlmZ G dd„ dƒZe ¡ dd „ Z
d
d„ Zdd
„ Zdd„ Z
dd„ Zdd„ Ze d¡Zdd„ ZG dd„ dƒZG dd„ dƒZG dd„ dƒZedkrÔddlmZ edd d!d" dS )#zíFormat all or a selected region (line slice) of text.
Region formatting options: paragraph, comment block, indent, deindent,
comment, uncomment, tabify, and untabify.
File renamed from paragraph.py with functions added from editor.py.
é N)Úaskyesno)Ú
askinteger)ÚidleConfc @ s6 e Zd ZdZdd„ Zedd„ ƒZdd„ Zdd d
„ZdS )ÚFormatParagrapha Format a paragraph, comment block, or selection to a max width.
Does basic, standard text formatting, and also understands Python
comment blocks. Thus, for editing Python source code, this
extension is really only suitable for reformatting these comment
blocks or triple-quoted strings.
Known problems with comment reformatting:
* If there is a selection marked, and the first line of the
selection is not complete, the block will probably not be detected
as comments, and will have the normal "text formatting" rules
applied.
* If a comment block has leading whitespace that mixes tabs and
spaces, they will not be considered part of the same block.
* Fancy comments, like this bulleted list, aren't handled :-)
c C s
|| _ d S )N)Úeditwin)Úselfr © r ú3/opt/alt/python37/lib64/python3.7/idlelib/format.pyÚ__init__ s zFormatParagraph.__init__c C s t jdddddd| _d S )NÚ
extensionsr z max-widthÚintéH )ÚtypeÚdefault)r Z GetOptionÚ max_width)Úclsr r r Úreload" s zFormatParagraph.reloadc C s
d | _ d S )N)r )r r r r Úclose' s zFormatParagraph.closeNc C sà |dkr| j n|}| jj}| j ¡ \}}|rF|rF| ||¡}t|ƒ}nt|| d¡ƒ\}}}}|rpt|||ƒ}n
t ||ƒ}|
ddd¡ ||krÆ| d|¡ | ¡ |
||¡ | ||¡ | ¡ n| d|¡ | d¡ dS )aÕ Formats paragraph to a max width specified in idleConf.
If text is selected, format_paragraph_event will start breaking lines
at the max width, starting from the beginning selection.
If no text is selected, format_paragraph_event uses the current
cursor location to determine the paragraph (lines of text surrounded
by blank lines) and formats it.
The length limit parameter is for testing with a known value.
NÚinsertÚselz1.0ÚendÚbreak)r r ÚtextÚget_selection_indicesÚgetÚget_comment_headerÚfind_paragraphÚindexÚreformat_commentÚreformat_paragraphÚ
tag_removeÚmark_setÚundo_block_startÚdeleter Úundo_block_stopZsee) r ÚeventÚlimitr ÚfirstÚlastÚdataÚcomment_headerÚnewdatar r r Úformat_paragraph_event* s(
z&FormatParagraph.format_paragraph_event)N) Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
Úclassmethodr r r, r r r r r s
r c
C sF t t| d¡ƒ\}}| d| d| ¡}x:| d| dd¡rbt|ƒrb|d }| d| d| ¡}q*W |}t|ƒ}t|ƒ}x