Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of pressing Esc during message compose #1362

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions zulipterminal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ def stream_muting_confirmation_popup(
mute_this_stream = partial(self.model.toggle_stream_muted_status, stream_id)
self.loop.widget = PopUpConfirmationView(self, question, mute_this_stream)

def exit_compose_confirmation_popup(self, draft: Composition) -> None:
question = urwid.Text(("bold", f"Save composed message as a draft?"))
save_draft = partial(self.model.save_draft, draft)
self.loop.widget = PopUpConfirmationView(self, question, save_draft)

def copy_to_clipboard(self, text: str, text_category: str) -> None:
try:
pyperclip.copy(text)
Expand Down
23 changes: 23 additions & 0 deletions zulipterminal/ui_tools/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,29 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
)
elif is_command_key("GO_BACK", key):
self.send_stop_typing_status()
if len(self.msg_write_box.edit_text) > 10:
if self.compose_box_status == "open_with_private":
all_valid = self._tidy_valid_recipients_and_notify_invalid_ones(
self.to_write_box
)
if not all_valid:
return key
self.update_recipients(self.to_write_box)
draft: Composition = PrivateComposition(
type="private",
to=self.recipient_user_ids,
content=self.msg_write_box.edit_text,
)
elif self.compose_box_status == "open_with_stream":
draft = StreamComposition(
type="stream",
to=self.stream_write_box.edit_text,
content=self.msg_write_box.edit_text,
subject=self.title_write_box.edit_text,
)
self.view.controller.exit_compose_confirmation_popup(
draft,
)
self._set_compose_attributes_to_defaults()
self.view.controller.exit_editor_mode()
self.main_view(False)
Expand Down