mirror of
https://github.com/paul-nameless/tg
synced 2024-11-22 03:43:19 +00:00
Fallback to default open cmd
This commit is contained in:
parent
7307c80d33
commit
038b5a091a
3 changed files with 17 additions and 19 deletions
|
@ -46,9 +46,9 @@ else:
|
|||
DEFAULT_OPEN = "open '{file_path}'"
|
||||
|
||||
if _os_name == _linux:
|
||||
DEFAULT_COPY = "xclip -selection c"
|
||||
COPY_CMD = "xclip -selection c"
|
||||
else:
|
||||
DEFAULT_COPY = "pbcopy"
|
||||
COPY_CMD = "pbcopy"
|
||||
|
||||
|
||||
if os.path.isfile(DEFAULT_CONFIG):
|
||||
|
|
|
@ -46,7 +46,6 @@ class Controller:
|
|||
self.model = model
|
||||
self.view = view
|
||||
self.render_lock = threading.Lock()
|
||||
self.render_msgs_lock = threading.Lock()
|
||||
self.tg = tg
|
||||
self.chat_size = 0.5
|
||||
|
||||
|
@ -431,18 +430,17 @@ class Controller:
|
|||
self.view.status.draw()
|
||||
|
||||
def render_msgs(self) -> None:
|
||||
with self.render_msgs_lock:
|
||||
current_msg_idx = self.model.get_current_chat_msg_idx()
|
||||
if current_msg_idx is None:
|
||||
return
|
||||
msgs = self.model.fetch_msgs(
|
||||
current_position=current_msg_idx,
|
||||
page_size=self.view.msgs.h,
|
||||
msgs_left_scroll_threshold=MSGS_LEFT_SCROLL_THRESHOLD,
|
||||
)
|
||||
self.view.msgs.draw(
|
||||
current_msg_idx, msgs, MSGS_LEFT_SCROLL_THRESHOLD
|
||||
)
|
||||
current_msg_idx = self.model.get_current_chat_msg_idx()
|
||||
if current_msg_idx is None:
|
||||
return
|
||||
msgs = self.model.fetch_msgs(
|
||||
current_position=current_msg_idx,
|
||||
page_size=self.view.msgs.h,
|
||||
msgs_left_scroll_threshold=MSGS_LEFT_SCROLL_THRESHOLD,
|
||||
)
|
||||
self.view.msgs.draw(
|
||||
current_msg_idx, msgs, MSGS_LEFT_SCROLL_THRESHOLD
|
||||
)
|
||||
|
||||
def _notify_for_message(self, chat_id: int, msg: MsgProxy):
|
||||
# do not notify, if muted
|
||||
|
|
|
@ -32,14 +32,14 @@ emoji_pattern = re.compile(
|
|||
units = {"B": 1, "KB": 10 ** 3, "MB": 10 ** 6, "GB": 10 ** 9, "TB": 10 ** 12}
|
||||
|
||||
|
||||
def get_file_handler(file_name, default=None):
|
||||
mtype, _ = mimetypes.guess_type(file_name)
|
||||
def get_file_handler(file_path, default=None):
|
||||
mtype, _ = mimetypes.guess_type(file_path)
|
||||
if not mtype:
|
||||
return default
|
||||
caps = mailcap.getcaps()
|
||||
handler, view = mailcap.findmatch(caps, mtype, filename=file_name)
|
||||
handler, view = mailcap.findmatch(caps, mtype, filename=file_path)
|
||||
if not handler:
|
||||
return None
|
||||
return config.DEFAULT_OPEN.format(file_path=file_path)
|
||||
return handler
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue