paul-nameless / tg

terminal telegram client
The Unlicense
943 stars 75 forks source link

FILE_PICKER_CMD not working #222

Open Galicarnax opened 3 years ago

Galicarnax commented 3 years ago

Hi there, and thanks for tg, looks very promising, even if still with some bugs ;) Probably, one of such bugs is that I cannot use ranger as file picker to send files to a peer. I have the line FILE_PICKER_CMD = "ranger --choosefile={file_path}" in my conf.py, and I have ranger installed. But upon pressing e.g. sd to send a document, the cursor appears at the bottom, seemingly waiting for me to input file path. I would expect ranger to be used instead. Is it a bug, or am I doing something wrong?

radio-van commented 3 years ago

Same issue, I use FILE_PICKER_CMD = "vifm --choose-files {file_path}". I've noticed that PgUp/PgDown keys involes file picker, so the setting is correct, but something related to keybindings is messed up.

paul-nameless commented 3 years ago

Hello, thanks for the comments) To call file chooser and send file need to press S. sd sends file as document (if you want to send image or audio as a file explicitly)

radio-van commented 3 years ago

@paul-nameless thanks, S works! Seems like I have read help not carefully enough) Now it's clear that S calls a file picker and sa/sd/sn/sp requires a path (btw, what it is relative for? I mean, if I start with ./ where this would be?). And it seems that file picker on PgUp is a kind of bug, at least it is not mentioned in help.

Galicarnax commented 3 years ago

In fact, all navigation keys, except for arrow keys, seem to cause unexpected behaviour, at least in CahtView, although there seem to be no bindings for them at all in the tg code. E.g., PgUp also acts as S for me (choose_and_send_file does get called when PgUp is pressed), PgDown in my case acts as pressing R (reply in editor), insert and delete make jumps like K and J.

Galicarnax commented 3 years ago

Another issue with input of text in the StatusView is that most non-character keys trigger unwanted handlers. For example, if I press the left arrow key when composing a message in a chat, the input is cleared, the current chat moves to the previous one and the status message appears that file cannot be downloaded. I have traced this to the fact that get_wch() in StatusView.get_input() method returns not 260 for left arrow, as it would if called on the stdscr, but instead it returns the string object with the escape sequence <esc>[D. So <esc> breaks the loop, and then the View.get_keys() propagates [ to go to previous chat and D to download the file...

@paul-nameless , any hint why StatusView.win.get_wch() does not return codes beyond 255, as it does normally when called on stdscr? I've experimented a bit and looked through curses docs, to no avail.

Galicarnax commented 3 years ago

Ok, I get it. Turns out I have to keypad(True) on each subwindow where I want get_wch() to return integer codes for arrow keys.

Galicarnax commented 3 years ago

Created PR to solve the issue with keys in the input filed.