mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-20 07:01:12 +00:00
vim table containing emoji (#122)
This commit is contained in:
parent
2d299e1d42
commit
17df485e19
|
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Improve config compatibility on Windows [#111](https://github.com/soywod/himalaya/pull/111)
|
- Improve config compatibility on Windows [#111](https://github.com/soywod/himalaya/pull/111)
|
||||||
|
- Vim table containing emoji [#122]
|
||||||
|
|
||||||
## [0.2.6] - 2021-04-17
|
## [0.2.6] - 2021-04-17
|
||||||
|
|
||||||
|
@ -198,5 +199,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
[#89]: https://github.com/soywod/himalaya/issues/89
|
[#89]: https://github.com/soywod/himalaya/issues/89
|
||||||
[#96]: https://github.com/soywod/himalaya/issues/96
|
[#96]: https://github.com/soywod/himalaya/issues/96
|
||||||
[#100]: https://github.com/soywod/himalaya/issues/100
|
[#100]: https://github.com/soywod/himalaya/issues/100
|
||||||
|
[#122]: https://github.com/soywod/himalaya/issues/122
|
||||||
[#125]: https://github.com/soywod/himalaya/issues/125
|
[#125]: https://github.com/soywod/himalaya/issues/125
|
||||||
[#126]: https://github.com/soywod/himalaya/issues/126
|
[#126]: https://github.com/soywod/himalaya/issues/126
|
||||||
|
|
|
@ -9,6 +9,7 @@ use serde::{
|
||||||
};
|
};
|
||||||
use std::{borrow::Cow, fmt, fs, path::PathBuf, result};
|
use std::{borrow::Cow, fmt, fs, path::PathBuf, result};
|
||||||
use tree_magic;
|
use tree_magic;
|
||||||
|
use unicode_width::UnicodeWidthStr;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -196,19 +197,37 @@ impl<'a> ReadableMsg {
|
||||||
|
|
||||||
// Message
|
// Message
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug)]
|
||||||
pub struct Msg<'m> {
|
pub struct Msg<'m> {
|
||||||
pub uid: u32,
|
pub uid: u32,
|
||||||
pub flags: Flags<'m>,
|
pub flags: Flags<'m>,
|
||||||
pub subject: String,
|
pub subject: String,
|
||||||
pub sender: String,
|
pub sender: String,
|
||||||
pub date: String,
|
pub date: String,
|
||||||
#[serde(skip_serializing)]
|
|
||||||
pub attachments: Vec<String>,
|
pub attachments: Vec<String>,
|
||||||
#[serde(skip_serializing)]
|
|
||||||
pub raw: Vec<u8>,
|
pub raw: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Serialize for Msg<'a> {
|
||||||
|
fn serialize<T>(&self, serializer: T) -> result::Result<T::Ok, T::Error>
|
||||||
|
where
|
||||||
|
T: ser::Serializer,
|
||||||
|
{
|
||||||
|
let mut state = serializer.serialize_struct("Msg", 7)?;
|
||||||
|
state.serialize_field("uid", &self.uid)?;
|
||||||
|
state.serialize_field("flags", &self.flags)?;
|
||||||
|
state.serialize_field("subject", &self.subject)?;
|
||||||
|
state.serialize_field(
|
||||||
|
"subject_len",
|
||||||
|
&UnicodeWidthStr::width(self.subject.as_str()),
|
||||||
|
)?;
|
||||||
|
state.serialize_field("sender", &self.sender)?;
|
||||||
|
state.serialize_field("sender_len", &UnicodeWidthStr::width(self.sender.as_str()))?;
|
||||||
|
state.serialize_field("date", &self.date)?;
|
||||||
|
state.end()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'m> From<Vec<u8>> for Msg<'m> {
|
impl<'m> From<Vec<u8>> for Msg<'m> {
|
||||||
fn from(raw: Vec<u8>) -> Self {
|
fn from(raw: Vec<u8>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -229,7 +229,7 @@ function! s:get_max_widths(msgs, columns)
|
||||||
let max_widths = map(copy(a:columns), "strlen(s:config.labels[v:val])")
|
let max_widths = map(copy(a:columns), "strlen(s:config.labels[v:val])")
|
||||||
|
|
||||||
for msg in a:msgs
|
for msg in a:msgs
|
||||||
let widths = map(copy(a:columns), "strlen(msg[v:val])")
|
let widths = map(copy(a:columns), "has_key(msg, v:val . '_len') ? msg[v:val . '_len'] : strlen(msg[v:val])")
|
||||||
call map(max_widths, "max([widths[v:key], v:val])")
|
call map(max_widths, "max([widths[v:key], v:val])")
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue