Repository: ipython/ipython

Issue:
pdb completion menu not honouring prompt_toolkit style
The menu colors look different when inside pdb (after %debug) than when outside it.
In particular, neither of:

```
Token.Menu.Completions
Token.Menu.Completions.Completion
Token.Menu.Completions.Completion.Current
Token.Menu.Completions.Meta
Token.Menu.Completions.Meta.Current
Token.Menu.Completions.MultiColumnMeta
```

is taken into account.


Discussion:
Well `create_prompt_application` in `debugger.py` is not using the style at all, I will try to fix this and let you know.
Well, this was easier than I thought, here is a simple fix:

```
@@ -17,6 +17,7 @@ from prompt_toolkit.token import Token
 from prompt_toolkit.shortcuts import create_prompt_application
 from prompt_toolkit.interface import CommandLineInterface
 from prompt_toolkit.enums import EditingMode
+from prompt_toolkit.styles import DynamicStyle
 
 
 class TerminalPdb(Pdb):
@@ -63,6 +64,7 @@ class TerminalPdb(Pdb):
                             mouse_support=self.shell.mouse_support,
                             get_prompt_tokens=get_prompt_tokens,
                             display_completions_in_columns=multicolumn,
+                            style=DynamicStyle(lambda: self.shell._style)
         )
         self.pt_cli = CommandLineInterface(self._pt_app, eventloop=self.shell._eventloop)
```

---

Problem is `shell._style` is "private", so wouldn't it be desirable to expose `shell.style` as `DynamicStyle(lambda:...)`? I mean, first:

```
--- /tmp/interactiveshell.py	2017-04-22 20:50:30.740261882 -0300
+++ terminal/interactiveshell.py	2017-04-22 20:50:38.807746481 -0300
@@ -235,7 +235,7 @@ class TerminalInteractiveShell(Interacti
                 last_cell = cell
 
         self._style = self._make_style_from_name_or_cls(self.highlighting_style)
-        style = DynamicStyle(lambda: self._style)
+        self.style = DynamicStyle(lambda: self._style)
 
         editing_mode = getattr(EditingMode, self.editing_mode.upper())
 
@@ -249,7 +249,7 @@ class TerminalInteractiveShell(Interacti
                             completer=IPythonPTCompleter(shell=self,
                                                     patch_stdout=patch_stdout),
                             enable_history_search=True,
-                            style=style,
+                            style=self.style,
                             mouse_support=self.mouse_support,
                             **self._layout_options()
```

and then just

```
--- /tmp/debugger.py	2017-04-22 20:45:05.810699332 -0300
+++ terminal/debugger.py	2017-04-22 20:49:32.444350980 -0300
@@ -63,6 +63,7 @@ class TerminalPdb(Pdb):
                             mouse_support=self.shell.mouse_support,
                             get_prompt_tokens=get_prompt_tokens,
                             display_completions_in_columns=multicolumn,
+                            style=self.shell.style
         )
         self.pt_cli = CommandLineInterface(self._pt_app, eventloop=self.shell._eventloop)
```

This looks much cleaner to me. Which one do you prefer? Do you want me to submit a PR or is it ok?
I don't have particular preference. Feel free to send a PR :-) 
Also, I'm not really sure keeping `shell._style` as an attribute has any point.
> lso, I'm not really sure keeping shell._style as an attribute has any point.

Maybe not, there've been a lot of refactor. It's still half a mess and need a lot of cleaning.
It still might be useful as a cache, I guess.

Resolving patch:
diff --git a/IPython/terminal/debugger.py b/IPython/terminal/debugger.py
--- a/IPython/terminal/debugger.py
+++ b/IPython/terminal/debugger.py
@@ -64,6 +64,7 @@ def patch_stdout(**kwargs):
                             mouse_support=self.shell.mouse_support,
                             get_prompt_tokens=get_prompt_tokens,
                             display_completions_in_columns=multicolumn,
+                            style=self.shell.style
         )
         self.pt_cli = CommandLineInterface(self._pt_app, eventloop=self.shell._eventloop)
 
diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py
--- a/IPython/terminal/interactiveshell.py
+++ b/IPython/terminal/interactiveshell.py
@@ -243,7 +243,7 @@ def prompt():
                 last_cell = cell
 
         self._style = self._make_style_from_name_or_cls(self.highlighting_style)
-        style = DynamicStyle(lambda: self._style)
+        self.style = DynamicStyle(lambda: self._style)
 
         editing_mode = getattr(EditingMode, self.editing_mode.upper())
 
@@ -257,7 +257,7 @@ def patch_stdout(**kwargs):
                             completer=IPythonPTCompleter(shell=self,
                                                     patch_stdout=patch_stdout),
                             enable_history_search=True,
-                            style=style,
+                            style=self.style,
                             mouse_support=self.mouse_support,
                             **self._layout_options()
         )


Test patch: