Boost C++ Libraries: Ticket #3703: Request for ability to specify description column width https://svn.boost.org/trac10/ticket/3703 <p> I see that the version of options_description.cpp on the trunk has been modified to address the issue where long options cause the description text to be bunched up on the right. </p> <p> The trunk version is using the (sensible assumption) of the (line_length / 2) as the threshold. </p> <p> This is a request to expose this <em>threshold</em> position by providing another constructor (or mutator); the programmer may want a different ratio between the option:description columns. </p> <p> Patches are included that demonstrate one possible approach (using another constructor). </p> <p> Notes: </p> <p> The original constructors were modified to use the (line_length / 2) threshold. It could be argued that the default should be 1; to preserve current (1.41) display behaviour. </p> <p> The original code has a constant of 23 in the code, for the minimum description column start position. In the patch this <em>wins</em> even if the min_description_length would encroach into this area. I wasn't sure whether this should be asserted in the constructor, i.e. assert(min_description_length &lt; m_lineLength - (23U + 1U)). </p> <p> There is also an options_description_test.cpp patch to demonstrate the behaviour. </p> <p> (Also: are you aware that test_long_default_value() asserts?) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3703 Trac 1.4.3 Chard Tue, 01 Dec 2009 10:26:03 GMT attachment set https://svn.boost.org/trac10/ticket/3703 https://svn.boost.org/trac10/ticket/3703 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">Ticket_#3703.zip</span> </li> </ul> <p> example specifying description column width; <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3703" title="#3703: Feature Requests: Request for ability to specify description column width (closed: fixed)">#3703</a> </p> Ticket Sascha Ochsenknecht Tue, 01 Dec 2009 14:06:10 GMT cc set https://svn.boost.org/trac10/ticket/3703#comment:1 https://svn.boost.org/trac10/ticket/3703#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">s.ochsenknecht@…</span> added </li> </ul> Ticket Sascha Ochsenknecht Tue, 01 Dec 2009 14:51:52 GMT <link>https://svn.boost.org/trac10/ticket/3703#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3703#comment:2</guid> <description> <p> Hi Chad, </p> <p> thanks for submitting the ticket+patch. I'll have a look to it. </p> <p> Replying to <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3703" title="#3703: Feature Requests: Request for ability to specify description column width (closed: fixed)">Chard</a>: </p> <blockquote class="citation"> <p> (Also: are you aware that test_long_default_value() asserts?) </p> </blockquote> <p> Hm, not on my platform (g++ 4.0.2, x86_64) with current trunk version. What is the output? </p> <p> Thanks, Sascha </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Chard</dc:creator> <pubDate>Tue, 01 Dec 2009 23:52:45 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/3703 https://svn.boost.org/trac10/ticket/3703 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">Ticket_#3703.2.zip</span> </li> </ul> <p> Update for <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3703" title="#3703: Feature Requests: Request for ability to specify description column width (closed: fixed)">#3703</a> </p> Ticket Chard Tue, 01 Dec 2009 23:53:29 GMT severity changed https://svn.boost.org/trac10/ticket/3703#comment:3 https://svn.boost.org/trac10/ticket/3703#comment:3 <ul> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Cosmetic</span> </li> </ul> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/3703#comment:2" title="Comment 2">s_ochsenknecht</a>: </p> <blockquote class="citation"> <p> thanks for submitting the ticket+patch. I'll have a look to it. </p> </blockquote> <p> Actually, that demo code was a mess. I've attached an updated version that is much <em>cleaner</em>. </p> <p> The new version shows that the only change required is the introduction of the constructor (or we could have a mutating method), and a one-line change to the trunk code where it calculates the column width. </p> <blockquote class="citation"> <blockquote class="citation"> <p> (Also: are you aware that test_long_default_value() asserts?) </p> </blockquote> <p> Hm, not on my platform (g++ 4.0.2, x86_64) with current trunk version. What is the output? </p> </blockquote> <p> My bad, sorry. This doesn't occur with the update, hopefully ;-). </p> Ticket Sascha Ochsenknecht Wed, 02 Dec 2009 12:12:34 GMT owner, status changed https://svn.boost.org/trac10/ticket/3703#comment:4 https://svn.boost.org/trac10/ticket/3703#comment:4 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Vladimir Prus</span> to <span class="trac-author">Sascha Ochsenknecht</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> I like the parameter to configure the space for the description text. I already thought about when fixing <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2613" title="#2613: Bugs: Default arguments break word-wrapping. (closed: fixed)">#2613</a>, but didn't commit it. </p> <p> I think I'll add the patch with some slight modifications. </p> <p> But one question, I saw you added a 'caption' parameter? What is the usage of this parameter? I would remove it, specially for the checkin for this ticket. </p> Ticket Sascha Ochsenknecht Wed, 02 Dec 2009 12:16:45 GMT <link>https://svn.boost.org/trac10/ticket/3703#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3703#comment:5</guid> <description> <p> ups sorry, the caption parameter was there before ... </p> <p> Maybe can you add patch as one single text file? The we can see the diffs directly in trac system. Use <code>svn diff</code>. Thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Sascha Ochsenknecht</dc:creator> <pubDate>Wed, 02 Dec 2009 13:35:56 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3703#comment:6 https://svn.boost.org/trac10/ticket/3703#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/58095" title="Additional parameter to allow user to specify width of column for ...">[58095]</a>) Additional parameter to allow user to specify width of column for description text, patch from Chard, Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3703" title="#3703: Feature Requests: Request for ability to specify description column width (closed: fixed)">#3703</a> </p> Ticket Sascha Ochsenknecht Wed, 02 Dec 2009 13:37:02 GMT <link>https://svn.boost.org/trac10/ticket/3703#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3703#comment:7</guid> <description> <p> I just added the patch with some small modifications. </p> <p> Please review! </p> <p> Thanks, SAscha </p> </description> <category>Ticket</category> </item> <item> <author>Chard <boost@…></author> <pubDate>Wed, 02 Dec 2009 15:36:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3703#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3703#comment:8</guid> <description> <p> Nice one. </p> <p> Modifying the original constructors is much better; it allows us to use default args so the user gets visibility of the default behaviour. I wasn't sure if I was allowed to touch them! </p> <p> Thanks... </p> </description> <category>Ticket</category> </item> <item> <author>Chard <boost@…></author> <pubDate>Thu, 03 Dec 2009 10:05:49 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3703#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3703#comment:9</guid> <description> <p> Hi Sascha </p> <p> I've had a bit more of a look at the changes, and there's a couple of points to note: </p> <ol><li>I had called the original description length variable: <code>min_description_length</code>, this has been renamed to <code>description_length</code>. The "<code>min_</code>" part does add some semantic meaning to the usage because the length that is specified is not an absolute. </li></ol><p> For example, if the user specifies 10 as the description length, he may be expecting the description column to occupy <em>exactly</em> 10 spaces. But the available distance is still determined by the length of the option column, as demonstrated by this test case: </p> <pre class="wiki"> { options_description desc("", options_description::m_default_line_length, 10U); desc.add_options() ("lt-23-chars", new untyped_value(), "this shows that more space is given to the description column when possible") ; stringstream ss; ss &lt;&lt; desc; BOOST_CHECK_EQUAL(ss.str(), //123456789_123456789_1234 " --lt-23-chars arg this shows that more space is given to the description \n" " column when possible\n"); } </pre><ol start="2"><li>By tying the default argument for the description length to <code>(default_line_length / 2)</code> it does mean that existing code that specifies the <code>line_length</code> argument will still compile, but with a potentially different display. The minimum description width will still be 40, regardless of the specified <code>line_length</code>. However, I suspect this is a minor point because for most cases the output should look <em>better</em>. </li></ol><p> Regards, Chard. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Sascha Ochsenknecht</dc:creator> <pubDate>Thu, 03 Dec 2009 10:42:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3703#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3703#comment:10</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/3703#comment:9" title="Comment 9">Chard &lt;boost@…&gt;</a>: </p> <blockquote class="citation"> <p> Hi Sascha </p> <p> I've had a bit more of a look at the changes, and there's a couple of points to note: </p> <ol><li>I had called the original description length variable: <code>min_description_length</code>, this has been renamed to <code>description_length</code>. The "<code>min_</code>" part does add some semantic meaning to the usage because the length that is specified is not an absolute. </li></ol></blockquote> <p> Yes, you're right. I agree that <code>min_description_length</code> might be the better name here. I wasn't 100% aware that the description could be longer. I'll change that. </p> <blockquote class="citation"> <ol start="2"><li>By tying the default argument for the description length to <code>(default_line_length / 2)</code> it does mean that existing code that specifies the <code>line_length</code> argument will still compile, but with a potentially different display. The minimum description width will still be 40, regardless of the specified <code>line_length</code>. However, I suspect this is a minor point because for most cases the output should look <em>better</em>. </li></ol></blockquote> <p> Yes, I wouldn't change it now since it can not be detected within the constructor if the default parameter was used or not. Or we end up with 1 or more constructor overloads, which I would like to avoid. Most likely the user will specify all parameters or none, I guess. </p> <p> Thanks &amp; regards, Sascha </p> </description> <category>Ticket</category> </item> </channel> </rss>