<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace;font-size:small;color:rgb(68,68,68)">It's working now. Thanks for your help with that. It was what Thomas said.</div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small;color:rgb(68,68,68)"><br></div><div class="gmail_default" style="font-family:monospace,monospace;font-size:small;color:rgb(68,68,68)">Looking through the IPython repo, it turns out there's already a commit that added a couple of examples of how to do this, so maybe just need to move some existing stuff around. If I'd found those examples, and the link Thomas suggested (to the default class definition), it would have been easy to figure out from there.</div><div class="gmail_default" style=""><br></div><div class="gmail_default" style=""><font color="#444444" face="monospace, monospace">The commit that adds the examples:</font></div><div class="gmail_default" style=""><font color="#444444" face="monospace, monospace"><a href="https://github.com/ipython/ipython/commit/95ed0855ae23e55c10b46903db911265aa1cdd58#diff-c5d5abe11d1c298906cb121c45eb12e2">https://github.com/ipython/ipython/commit/95ed0855ae23e55c10b46903db911265aa1cdd58#diff-c5d5abe11d1c298906cb121c45eb12e2</a></font><br></div><div class="gmail_default" style=""><font color="#444444" face="monospace, monospace"><br></font></div><div class="gmail_default" style=""><font color="#444444" face="monospace, monospace">I did put a simple example together before I saw those, and you're welcome to use it too. It just creates more minimal versions of the standard prompts to save some space:</font></div><div class="gmail_default" style=""><br></div><div class="gmail_default" style=""><div><font face="monospace, monospace"><font color="#0b5394">[<b>1</b>]</font><b><font color="#0b5394"> $</font><font color="#444444"> </font><font color="#b45f06">def</font></b><font color="#444444"> </font><font color="#ff00ff"><b>inc</b></font><font color="#444444">(x):</font></font></div><div><font face="monospace, monospace"><font color="#444444">    </font><b><font color="#0b5394">$</font></b><font color="#444444">     </font><b><font color="#b45f06">return</font></b><font color="#444444"> x + </font><font color="#990000">1</font></font></div><div><font face="monospace, monospace" color="#0b5394">    <b>$</b></font></div><div><font color="#444444" face="monospace, monospace"><br></font></div><div><font color="#444444" face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><font color="#0b5394">[<b>2</b>] <b>$</b></font><font color="#444444"> inc </font><font color="#990000">1</font></font></div><div><font face="monospace, monospace"><b><font color="#0b5394">----></font></b><font color="#444444"> inc(1)</font></font></div><div><font face="monospace, monospace"><font color="#741b47">[<b>2] :</b></font><font color="#444444"> 2</font></font></div></div><div class="gmail_default" style=""><font color="#444444" face="monospace, monospace"><br></font></div><div class="gmail_default" style=""><font color="#444444" face="monospace, monospace">The code is pretty compact too:</font></div><div class="gmail_default" style=""><br></div><div class="gmail_default" style=""><font face="monospace, monospace"><div class="gmail_default"><b><font color="#b45f06">from</font><font color="#444444"> IPython.terminal.prompts </font><font color="#b45f06">import</font><font color="#444444"> Prompts, Token</font></b></div><div class="gmail_default" style="color:rgb(68,68,68)"><b><br></b></div><div class="gmail_default"><b><font color="#b45f06">class</font><font color="#444444"> CustomPrompts(<i>Prompts</i>):</font></b></div><div class="gmail_default" style="color:rgb(68,68,68)"><b><br></b></div><div class="gmail_default"><b><font color="#444444">    </font><font color="#b45f06">def</font><font color="#444444"> in_prompt_tokens(</font><i><font color="#0b5394">self</font></i><font color="#444444">, </font><i><font color="#444444">cli=</font><font color="#0b5394">None</font></i><font color="#444444">): </font><font color="#b45f06">return</font><font color="#444444"> [</font></b></div><div class="gmail_default"><b><font color="#444444">        (Token.Prompt, </font><font color="#38761d">"["</font><font color="#444444">),</font></b></div><div class="gmail_default"><b><font color="#444444">        (Token.PromptNum, str(</font><i><font color="#0b5394">self</font></i><font color="#444444">.shell.execution_count)),</font></b></div><div class="gmail_default"><b><font color="#444444">        (Token.Prompt, </font><font color="#38761d">"] $ "</font><font color="#444444">)</font></b></div><div class="gmail_default" style="color:rgb(68,68,68)"><b>        ]</b></div><div class="gmail_default" style="color:rgb(68,68,68)"><b><br></b></div><div class="gmail_default"><b><font color="#444444">    </font><font color="#b45f06">def</font><font color="#444444"> out_prompt_tokens(</font><i><font color="#0b5394">self</font></i><font color="#444444">): </font><font color="#b45f06">return</font><font color="#444444"> [</font></b></div><div class="gmail_default"><b><font color="#444444">        (Token.OutPrompt, </font><font color="#38761d">"["</font><font color="#444444">),</font></b></div><div class="gmail_default"><b><font color="#444444">        (Token.OutPromptNum, str(</font><i><font color="#0b5394">self</font></i><font color="#444444">.shell.execution_count)),</font></b></div><div class="gmail_default"><b><font color="#444444">        (Token.OutPrompt, </font><font color="#38761d">"] : "</font><font color="#444444">)</font></b></div><div class="gmail_default" style="color:rgb(68,68,68)"><b>        ]</b></div><div class="gmail_default" style="color:rgb(68,68,68)"><b><br></b></div><div class="gmail_default"><b><font color="#444444">    </font><font color="#b45f06">def</font><font color="#444444"> continuation_prompt_tokens(</font><font color="#0b5394"><i>self</i></font><font color="#444444">, </font><i><font color="#444444">cli=</font><font color="#0b5394">None</font></i><font color="#444444">, </font><i style="color:rgb(68,68,68)">width=</i><i><font color="#0b5394">None</font></i><font color="#444444">):</font></b></div><div class="gmail_default"><b><font color="#444444">        </font><font color="#b45f06">if</font><font color="#444444"> width </font><font color="#b45f06">is</font><font color="#444444"> </font><font color="#0b5394">None</font><font color="#444444">: width = </font><i><font color="#0b5394">self</font></i><font color="#444444">._width()</font></b></div><div class="gmail_default"><b><font color="#444444">        </font><font color="#b45f06">return</font><font color="#444444"> [(Token.Prompt, </font><font color="#38761d">" "</font><font color="#444444"> * (width - 5) + </font><font color="#38761d">"   $ "</font><font color="#444444">)]</font></b></div><div class="gmail_default" style="color:rgb(68,68,68)"><b><br></b></div><div class="gmail_default" style="color:rgb(68,68,68)"><b>ip = get_ipython()</b></div><div class="gmail_default" style="color:rgb(68,68,68)"><b>ip.prompts = CustomPrompts(ip)</b></div><div style="color:rgb(68,68,68)"><br></div><div style="color:rgb(68,68,68)">One thing I found buggy was the rewrite prompt. If you inherit from `Prompt` and redefine some of the prompt methods in the derived class, as you're meant to do, any prompts that you inherit from `Prompt` will pad themselves out to keep everything aligned. This works well except when you have a multiline prompt.</div><div style="color:rgb(68,68,68)"><br></div><div style="color:rgb(68,68,68)">Prompts can get pretty lengthy, and you don't really want multiline inputs starting at column 50, so two-line prompts with a really short second line will be fairly common.</div><div style="color:rgb(68,68,68)"><br></div><div style="color:rgb(68,68,68)">If you create a multiline Input prompt, the rewrite prompt will end up being too long. The math in the token assumes the Input prompt is all on one line.</div><div style="color:rgb(68,68,68)"><br></div><div style="color:rgb(68,68,68)"><table class="" style="border-spacing:0px;border-collapse:collapse;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px;line-height:21px"><tbody style=""><tr style=""><td id="LC32" class="" style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre;line-height:20px">    <span class="" style="color:rgb(167,29,93)">def</span> <span class="" style="color:rgb(121,93,163)">rewrite_prompt_tokens</span>(<span class="" style="">self</span>):
        width <span class="" style="color:rgb(167,29,93)">=</span> <span class="" style="color:rgb(237,106,67)">self</span>._width()
        <span class="" style="color:rgb(167,29,93)">return</span> [
            (Token.Prompt, (<span class="" style="color:rgb(24,54,145)"><span class="">'</span>-<span class="">'</span></span> <span class="" style="color:rgb(167,29,93)">*</span> (width <span class="" style="color:rgb(167,29,93)">-</span> <span class="" style="color:rgb(0,134,179)">2</span>)) <span class="" style="color:rgb(167,29,93)">+</span> <span class="" style="color:rgb(24,54,145)"><span class="">'</span>> <span class="">'</span></span>),
        ]
</td></tr></tbody></table></div><div style="color:rgb(68,68,68)"><span style="color:rgb(51,51,51);font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;line-height:20px;white-space:pre"><br></span></div></font></div><div class="gmail_default" style=""><font color="#444444" face="monospace, monospace">I'm happy to do some work on the docs, but not sure what should be done exactly. It's g</font><span style="color:rgb(68,68,68);font-family:monospace,monospace">etting late here again (1:30am), so it'll have to be tomorrow now anyway.</span></div><div class="gmail_default" style=""><span style="color:rgb(68,68,68);font-family:monospace,monospace"><br></span></div><div class="gmail_default" style=""><span style="color:rgb(68,68,68);font-family:monospace,monospace">Best,</span></div><div class="gmail_default" style=""><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><span style="color:rgb(115,115,115);font-style:italic;line-height:18px"><font size="1" face="monospace, monospace">-- Carl Smith</font></span><br></div></div><div><span style="color:rgb(115,115,115);font-style:italic;line-height:18px"><font size="1" face="monospace, monospace"><a href="mailto:carl.input@gmail.com" target="_blank">carl.input@gmail.com</a></font></span></div></div></div></div></div></div>
<br><div class="gmail_quote">On 11 July 2016 at 21:20, Thomas Kluyver <span dir="ltr"><<a href="mailto:takowl@gmail.com" target="_blank">takowl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class=""><div class="gmail_extra"><div class="gmail_quote">On 11 July 2016 at 21:12, Carl Smith <span dir="ltr"><<a href="mailto:carl.input@gmail.com" target="_blank">carl.input@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On the PR, should I put the example code right there in the docs, where the API is explained, or is there a wiki or something? Happy either way. Just unsure what's correct these days. </blockquote></div><br></div></span><div class="gmail_extra">In the docs themselves would be great - thanks!<br></div></div>
<br>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/ipython-dev" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div><br></div>