Skip to content

Commit

Permalink
Ensure prompt is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
joouha committed May 14, 2021
1 parent 9baabcd commit fac516b
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions euporie/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from prompt_toolkit.lexers import DynamicLexer, PygmentsLexer
from prompt_toolkit.mouse_events import MouseEvent, MouseEventType
from prompt_toolkit.search import start_search
from prompt_toolkit.widgets import Label, SearchToolbar, TextArea
from prompt_toolkit.widgets import SearchToolbar, TextArea
from pygments.lexers import get_lexer_by_name

from euporie.box import Border
Expand Down Expand Up @@ -449,7 +449,7 @@ def load(self):
self.control,
ConditionalContainer(
content=fill(
char=Border.HORIZONTAL, width=len(self.prompt), height=1
char=Border.HORIZONTAL, width=lambda: len(self.prompt), height=1
),
filter=self.show_prompt,
),
Expand All @@ -467,9 +467,11 @@ def load(self):
[
fill(width=1, char=Border.VERTICAL),
ConditionalContainer(
content=Label(
self.prompt,
width=len(self.prompt),
content=Window(
FormattedTextControl(
lambda: self.prompt,
),
width=lambda: len(self.prompt),
style="class:cell-input-prompt",
),
filter=self.show_prompt,
Expand All @@ -489,7 +491,9 @@ def load(self):
[
fill(width=1, height=1, char=Border.SPLIT_LEFT),
ConditionalContainer(
content=fill(char=Border.HORIZONTAL, width=len(self.prompt)),
content=fill(
char=Border.HORIZONTAL, width=lambda: len(self.prompt)
),
filter=self.show_prompt,
),
ConditionalContainer(
Expand All @@ -508,9 +512,11 @@ def load(self):
[
fill(width=1, char=Border.VERTICAL),
ConditionalContainer(
content=Label(
self.prompt,
width=len(self.prompt),
content=Window(
FormattedTextControl(
lambda: self.prompt,
),
width=lambda: len(self.prompt),
style="class:cell-output-prompt",
),
filter=self.show_prompt,
Expand All @@ -535,7 +541,9 @@ def load(self):
[
fill(width=1, height=1, char=Border.BOTTOM_LEFT),
ConditionalContainer(
content=fill(char=Border.HORIZONTAL, width=len(self.prompt)),
content=fill(
char=Border.HORIZONTAL, width=lambda: len(self.prompt)
),
filter=self.show_prompt,
),
ConditionalContainer(
Expand Down Expand Up @@ -600,13 +608,21 @@ def prompt(self):
if self.state in ("busy", "queued"):
prompt = "*"
else:
prompt = self.json.get("execution_count", "")
prompt = self.execution_count
if prompt is None:
prompt = " "
if prompt:
prompt = f"[{prompt}]"
return prompt

@property
def execution_count(self):
return self.json.get("execution_count", " ")

@execution_count.setter
def execution_count(self, value):
self.json["execution_count"] = value

@property
def input(self):
return self.json.get("source", "")
Expand Down

0 comments on commit fac516b

Please sign in to comment.