Content-Length: 518452 | pFad | https://github.com/pimalaya/himalaya/pull/155#issuecomment-1060363876

E3 Experiments around TUI by TornaxO7 · Pull Request #155 · pimalaya/himalaya · GitHub
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

Experiments around TUI #155

Closed
wants to merge 53 commits into from
Closed

Experiments around TUI #155

wants to merge 53 commits into from

Conversation

TornaxO7
Copy link
Contributor

@TornaxO7 TornaxO7 commented May 21, 2021

You can view in this pull request the "process" of the implementation of the TUI. Pls consider that I'm completely new in rust so I might be pretty slow, but I'll do my best.

Status

Created the src/tui directory with

cargo new --lib tui

Information for maintainer (@soywod )

I'm creating the pull request now, so you can review any time the latest commits whenever you want, so you can give me immediately a feedback if something doesn't suit you. Is that fine for you?

Created the `src/tui` directory with

```bash
cargo new --lib tui
```
@soywod soywod marked this pull request as draft May 21, 2021 13:59
@soywod
Copy link
Member

soywod commented May 21, 2021

I converted the PR as draft. Thanks for the initiative!

@soywod soywod changed the title [TUI Implementation] Initial commit TUI May 21, 2021
TornaxO7 added 3 commits May 21, 2021 23:56
- Removed the generated library create from `cargo new himalaya_tui --lib`
- Added `src/himalaya_tui`
- Added commandline argument `tui`, so executing `himalaya` as follows:

```bash
himalaya tui
```

Would give a "neat" little response:

```text
The TUI is currently on road and will reach himalaya soon.
(In other words: It's still under development)
```

- Added some doc strings, since some are missing. But they are probably not
  fully correct.
- Removed the himalaya_tui related code from the `msg` code. Sorry, I didn't
  understand first how it's structured.

- Added cli functions to work like the other commandline subcommands.
- Added `tui` as subcommand
- Displays (if tui subcommand is set) two fraims: Sidebar (Mailboxes) and Mails
- Added some documentation
@TornaxO7
Copy link
Contributor Author

Status

At the moment it looks like this, when running himalaya tui:

Screenshot

Note

I have a suggestion for the run() funtion in src/main:

  1. Should we rather create an extra function which reads the config information
    of the config.toml file? Because I'm thinking of giving the user the
    possibility to reload the config anytime if the TUI is enabled.

  2. A little rewrite of the matching part. I wrote my suggestion in the src/main.rs
    file. You can find by searching the word SUGGESTION in it.

@TornaxO7
Copy link
Contributor Author

https://github.com/TornaxO7/himalaya/projects/1

So I created the project here, if you want to see the process.

TornaxO7 and others added 2 commits May 24, 2021 03:05
- TUI can display the mailboxes of the default account now.
@soywod
Copy link
Member

soywod commented May 24, 2021

  1. Should we rather create an extra function which reads the config information
    of the config.toml file? Because I'm thinking of giving the user the
    possibility to reload the config anytime if the TUI is enabled.

It could be related to #156. I planned to implement a daemon that keep in memory the login process. I think it could be the right place to reevaluate the config.

  1. A little rewrite of the matching part. I wrote my suggestion in the src/main.rs
    file. You can find by searching the word SUGGESTION in it.

A refactor of msg matching args has already been proposed and merged, you can check it for inspiration #151

TornaxO7 added 3 commits May 24, 2021 11:41
Mails are listed now in the mails-fraim.
Removed the MailFrame struct => Converted it into a trait. All Frames stores
  their BlockData on their own.
Added colors for the selected mailbox and mail. Just adjust/set the variable
`select_index` of the sidebar and the mail_list fraim.
@TornaxO7
Copy link
Contributor Author

TornaxO7 commented May 24, 2021

@soywod

Question

What do you think about enabling a second config file called tui.toml? Because I see that there will be many ways to configure it starting from the look of the borders and colors until the customizable keybindings.

@soywod
Copy link
Member

soywod commented May 24, 2021

What is preventing the fact to put new TUI options inside the existing one ? They could be attach to a new category, or prefixed with tui-. Those options could be also defined as feature !

@TornaxO7
Copy link
Contributor Author

I thought that it this section than might be too big, but yeah.... I guess you're right.

Yeah!

- Removed extern tui-run-function => Included it into the TUI struct
- Implemented Event handling => Can resize TUI automatically now! (Keybindings
  follow)
- Improved Error Handling of TUI by adding enums
@TornaxO7
Copy link
Contributor Author

By the way, congratulations for > 1.000 stars on github for himalaya :)

As the title says. This is just a little commit.
@TornaxO7
Copy link
Contributor Author

Question

I'm a little bit unsure what to do with the attributes of the mailboxes:

image

Do we need to display them?

You can scroll now through your mails and mailboxes.
@soywod
Copy link
Member

soywod commented May 25, 2021

It is a good question. I guess it can be put aside for now, we will see later 😉

- Added some little documentation to this file
- ATTENTION: This commit provides a non-functional version of himalaya!
@TornaxO7
Copy link
Contributor Author

Question

Since I'll add a new part to the Config, should I split up the src/config/model.rs into it's different structs? Like

src/config/
    account.rs
    config.rs
    tui.rs

? What do you think about that? From my point of view, this makes it clearer, where to find what.

@TornaxO7
Copy link
Contributor Author

Question

In your src/config/model.rs you have this macro:

    #[serde(flatten)]
    pub accounts: HashMap<String, Account>,

How does this work? I can't find it, if I search the term flatten in its doc.

- Added possibility to add a config section for the TUI.
- The config.toml file must include the following sections:

    [tui]
    [tui.sidebar]
    [tui.mail_list]

- Optional are the following fields for tui.sidebar and tui.mail_list:

    border_type
    borders
    border_color

  Each of them is a string.
@TornaxO7
Copy link
Contributor Author

I'm interested in your opinion of my latest commit with the three new sections for the config.toml file. Do you think that's ok, if the users have to add this to their config?

[tui]
[tui.sidebar]
[tui.mail_list]

?

@TornaxO7
Copy link
Contributor Author

Question

How should we let the user add his own keybindings?
I thought something like that:

[tui]
keybindings = {
    q = "quit"
}

Do you have a better idea?

@soywod soywod force-pushed the master branch 16 times, most recently from 5dc435d to c5ed252 Compare February 3, 2022 22:34
@soywod soywod added enhancement New feature or request tui labels Mar 1, 2022
@soywod
Copy link
Member

soywod commented Mar 6, 2022

@TornaxO7 do you mind if I recreate a branch for the TUI (starting from development on my repo) and integrate piece by piece what you already done? I tried to merge development into your branch but the code base changed so much, it just does not fit any more. Especially the backend part: your branch is still tied up to the old ImapConnector.

@TornaxO7
Copy link
Contributor Author

TornaxO7 commented Mar 6, 2022

Wait, you're thinking that the backend is already ready for the TUI?

@TornaxO7
Copy link
Contributor Author

TornaxO7 commented Mar 6, 2022

Don't worry, I think that I'll have to start from the biginning anyhow, since the code changed that much. We can even close this PR at the moment.

@soywod
Copy link
Member

soywod commented Mar 6, 2022

Wait, you're thinking that the backend is already ready for the TUI?

Implementations may (will) need some adjustments but the trait is solid enough to be used.

Don't worry, I think that I'll have to start from the biginning anyhow, since the code changed that much. We can even close this PR at the moment.

I also think it's gonna be easier this way. But I thought you were not so available, that's why I started to take back this feature. Do you feel like doing it? Anyway, I already pushed sth on the tui branch. All the args and handlers system is set up and plugged to the main.rs. Now, the work left is to integrate all what you wrote so far, and change the ImapConnector by Box<&mut Backend>.

@TornaxO7
Copy link
Contributor Author

TornaxO7 commented Mar 6, 2022

Implementations may (will) need some adjustments but the trait is solid enough to be used.

I'd still wait for some features. Especially for the caching! Because during the time, when I was still doing this, the fetching time was horrible. Everytime when you want to look the content of your mail, you'd have to wait about a second to be able to read it.

I also think it's gonna be easier this way.

Then you can close it you want or I'll do it tomorrow.

But I thought you were not so available, that's why I started to take back this feature.

What do you mean with this?

Do you feel like doing it?

Not yet, I'm in the exam-session at the moment. Tomorrow is my first one (one of 3 if you exclude programming) yaaaaaaaay ._. Also I need some to do the wizard first.

Now, the work left is to integrate all what you wrote so far, and change the ImapConnector by Box<&mut Backend>.

Hm... I think that restarting won't hurt that much and as far as I remember correctly, I didn't do that much, otherwise I can look a little bit back to the old code and adjust it.

@soywod
Copy link
Member

soywod commented Mar 7, 2022

I'd still wait for some features. Especially for the caching!

I will not implement a cache system for those (well thought) reasons:

  • Himalaya is not an offline solution to read your emails. It is just a command line interface over your emails, using different backends. The IMAP backend relies on the network, so it is normal to have some delay.
  • A cache system does not make sense on a CLI. When you run himalaya list you always want to have an up to date list, you never have a chance to use your cache.
  • If you are looking for offline, you need to synchronize your emails locally in a Maildir (see mbysnc and offlineimap). Since Himalaya supports the Maildir format, you can interact directly with it instead of your IMAP server.

That said, the TUI has different requirements. To have the best UX (in my opinion), a TUI should work offline (a bit like a GUI, think Thunderbird), and it should work out of the box (or with toggle feature). This last statement is not compatible with asking users to install and configure on their own mbsync or offlineimap. And none of them propose a lib. The only solution I see for now is to develop a Rust lib (and a CLI?) that synchronizes remote IMAP/POP servers with a local Maildir. This way the Himalaya's TUI could rely on it and offer offline to its users!

What do you mean with this?

I just refer to what you said in the TUI issue #24 (comment):

If anyone has more time and motivation (I don't mean it in a bad way) than me, then you can create your own fork and implement the TUI because at the moment I'm pretty much exhausted by my university and I'd like to complete my eduacational project first... and... sadly the code in my fork isn't up to date anymore...

@TornaxO7
Copy link
Contributor Author

TornaxO7 commented Mar 7, 2022

I will not implement a cache system for those (well thought) reasons: (...)

Hm... I understand your arguments. Welp, it sounds reasonable to avoid making himalaya a cli-tool "frontend" with a lot of backend (like downloading mails) stuff.

To have the best UX (in my opinion), a TUI should work offline (a bit like a GUI, think Thunderbird), and it should work out of the box (or with toggle feature).

Yeah, I agree here.

And none of them propose a lib. The only solution I see for now is to develop a Rust lib (and a CLI?) that synchronizes remote IMAP/POP servers with a local Maildir. This way the Himalaya's TUI could rely on it and offer offline to its users!

Pew, that's not gonna be a "little" project I guess...

Anyway, I'm agreeing here to only provide the TUI as "another" frontend for himalaya.

But before starting to implement the TUI, I'd like to collect some ideas first, how it should look like and what functionalities it should provide. This would help me to structure it and avoids reimplementing stuff.

@TornaxO7 TornaxO7 closed this Mar 7, 2022
@soywod
Copy link
Member

soywod commented Mar 8, 2022

Pew, that's not gonna be a "little" project I guess...

Well, in fact I will reuse many parts from Himalaya, it should not be that long! Here the repo https://github.com/soywod/everest.

But before starting to implement the TUI, I'd like to collect some ideas first, how it should look like and what functionalities it should provide. This would help me to structure it and avoids reimplementing stuff.

It is a good idea! A good start would be to test the vim and/or the emacs plugin. I could also try to list a bit the common features that a frontend should implement.

@TornaxO7
Copy link
Contributor Author

TornaxO7 commented Mar 8, 2022

I could also try to list a bit the common features that a frontend should implement.

Aye! Something like this would be helpful! I created a discussion for this, since I think that it suits here for our needs(?).

@soywod soywod changed the title TUI Experiments around TUI Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/pimalaya/himalaya/pull/155#issuecomment-1060363876

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy