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

bugfix: boxes/ui: Display mouse selection_hint for entire View. #1085

Merged
merged 1 commit into from
Jul 18, 2021
Merged
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
22 changes: 22 additions & 0 deletions zulipterminal/ui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import random
import re
import time
from sys import platform
from typing import Any, List, Optional

import urwid
Expand Down Expand Up @@ -39,6 +40,7 @@ def __init__(self, controller: Any) -> None:
self.search_box = SearchBox(self.controller)

self.message_view: Any = None
self.displaying_selection_hint = False

super().__init__(self.main_window())

Expand Down Expand Up @@ -297,6 +299,26 @@ def keypress(self, size: urwid_Box, key: str) -> Optional[str]:
key = "end"
return super().keypress(size, key)

def mouse_event(
self, size: urwid_Box, event: str, button: int, col: int, row: int, focus: bool
) -> bool:
if event == "mouse drag":
selection_key = "Fn + Alt" if platform == "darwin" else "Shift"
self.model.controller.view.set_footer_text(
[
"Try pressing ",
("footer_contrast", f" {selection_key} "),
" and dragging to select text.",
],
"task:warning",
)
self.displaying_selection_hint = True
elif event == "mouse release" and self.displaying_selection_hint:
self.model.controller.view.set_footer_text()
self.displaying_selection_hint = False

return super().mouse_event(size, event, button, col, row, focus)


class Screen(urwid.raw_display.Screen):
def write(self, data: Any) -> None:
Expand Down
18 changes: 0 additions & 18 deletions zulipterminal/ui_tools/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import unicodedata
from collections import Counter, OrderedDict, defaultdict
from datetime import date, datetime, timedelta
from sys import platform
from time import sleep, time
from typing import Any, Callable, Dict, List, NamedTuple, Optional, Tuple, Union
from urllib.parse import urljoin, urlparse
Expand Down Expand Up @@ -837,9 +836,6 @@ def __init__(self, message: Message, model: "Model", last_message: Any) -> None:
if recipient["id"] != self.model.user_id
]

# mouse_event helper variable
self.displaying_selection_hint = False

super().__init__(self.main_view())

def need_recipient_header(self) -> bool:
Expand Down Expand Up @@ -1575,20 +1571,6 @@ def mouse_event(
return True
self.keypress(size, primary_key_for_command("ENTER"))
return True
elif event == "mouse drag":
selection_key = "Fn + Alt" if platform == "darwin" else "Shift"
self.model.controller.view.set_footer_text(
[
"Try pressing ",
("footer_contrast", f" {selection_key} "),
" and dragging to select text.",
],
"task:warning",
)
self.displaying_selection_hint = True
elif event == "mouse release" and self.displaying_selection_hint:
self.model.controller.view.set_footer_text()
self.displaying_selection_hint = False

return super().mouse_event(size, event, button, col, row, focus)

Expand Down