Popular recipes tagged "wrap"http://code.activestate.com/recipes/tags/wrap/2012-06-07T14:31:44-07:00ActiveState Code RecipesMinimalistic Word Wrap using Regex (Python) 2012-06-07T14:31:44-07:00Alfehttp://code.activestate.com/recipes/users/4182236/http://code.activestate.com/recipes/578162-minimalistic-word-wrap-using-regex/ <p style="color: grey"> Python recipe 578162 by <a href="/recipes/users/4182236/">Alfe</a> (<a href="/recipes/tags/minimalistic/">minimalistic</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/regex/">regex</a>, <a href="/recipes/tags/word/">word</a>, <a href="/recipes/tags/wrap/">wrap</a>). </p> <p>I know there is the module textwrap and other recipes like <a href="http://code.activestate.com/recipes/148061-one-liner-word-wrap-function/" rel="nofollow">http://code.activestate.com/recipes/148061-one-liner-word-wrap-function/</a></p> <p>But in some constellations my recipe for a very simple word wrap might come in handy nevertheless.</p> Komodo JS Macro: Real auto word-wrap (JavaScript) 2012-04-10T17:38:13-07:00Furlohttp://code.activestate.com/recipes/users/4180513/http://code.activestate.com/recipes/578099-komodo-js-macro-real-auto-word-wrap/ <p style="color: grey"> JavaScript recipe 578099 by <a href="/recipes/users/4180513/">Furlo</a> (<a href="/recipes/tags/auto/">auto</a>, <a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/word/">word</a>, <a href="/recipes/tags/wrap/">wrap</a>). </p> <p>This script will add real auto-wrap functionality to Komodo, ie. it will wrap text after reaching column 80 just in the same way as you would by pressing &lt;Enter&gt;.</p> <p>You can bind a keyboard shortcut to macro, or trigger it on Komodo startup, or both. Either way, repeated pressing of binded shortcut (or running the macro) will switch it off and on again.</p> <p>In fact, script only adds event listener, which fires a function (after each keypress), that checks if cursor position is not in column higher that 79 and, if needed, calls Komodo built-in function "Reflow paragraph" to reflow the paragraph.</p> <p>This recipe was not created by me from scratch. I have just read David Brewer's feature request at <a href="http://code.activestate.com/lists/komodo-discuss/4965/">komodo-discuss</a>, used <a href="http://www.openkomodo.com/blogs/troyt/revenge-auto-wrap-type-type-type-ding">troyt's original code</a> for autowrap and tweaked/simplified it a little.</p> Word Wrap for Proportional Fonts (Python) 2011-11-11T21:29:21-08:00Michael Foglemanhttp://code.activestate.com/recipes/users/4171845/http://code.activestate.com/recipes/577946-word-wrap-for-proportional-fonts/ <p style="color: grey"> Python recipe 577946 by <a href="/recipes/users/4171845/">Michael Fogleman</a> (<a href="/recipes/tags/fixed/">fixed</a>, <a href="/recipes/tags/font/">font</a>, <a href="/recipes/tags/proportional/">proportional</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/word/">word</a>, <a href="/recipes/tags/word_wrap/">word_wrap</a>, <a href="/recipes/tags/wrap/">wrap</a>). </p> <p>Word wrap function / algorithm for wrapping text using proportional (versus fixed-width) fonts.</p> <p><code>text</code>: a string of text to wrap <code>width</code>: the width in pixels to wrap to <code>extent_func</code>: a function that returns a (w, h) tuple given any string, to specify the size (text extent) of the string when rendered. the algorithm only uses the width.</p> <p>Returns a list of strings, one for each line after wrapping.</p> Komodo JavaScript Macro - wrap the current word under the cursor (JavaScript) 2011-02-02T23:28:37-08:00Todd Whitemanhttp://code.activestate.com/recipes/users/2666241/http://code.activestate.com/recipes/577561-komodo-javascript-macro-wrap-the-current-word-unde/ <p style="color: grey"> JavaScript recipe 577561 by <a href="/recipes/users/2666241/">Todd Whiteman</a> (<a href="/recipes/tags/komodo/">komodo</a>, <a href="/recipes/tags/macro/">macro</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/toddw/">toddw</a>, <a href="/recipes/tags/wrap/">wrap</a>). </p> <p>A <a href="http://www.activestate.com/komodo">Komodo</a> JavaScript macro that can be used to wrap the current word under the cursor position (or current selection) with arbitrary text.</p> <p>For example, if I'm editing a HTML file and have the selected text "This is my heading", I can quickly use this macro to wrap this text into "&lt;h1&gt;This is my heading&lt;/h1&gt;".</p> Align text filter (Python) 2010-03-09T07:34:43-08:00Denis Barmenkovhttp://code.activestate.com/recipes/users/57155/http://code.activestate.com/recipes/577093-align-text-filter/ <p style="color: grey"> Python recipe 577093 by <a href="/recipes/users/57155/">Denis Barmenkov</a> (<a href="/recipes/tags/align/">align</a>, <a href="/recipes/tags/pipe/">pipe</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/wrap/">wrap</a>). Revision 4. </p> <p>Python 2.3 module textwrap can justify text in three modes: left/right/center. Sometimes 'align' mode become more useful.</p>