You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.2 KiB

  1. /*
  2. * meli - pager conf module
  3. *
  4. * Copyright 2018 Manos Pitsidianakis
  5. *
  6. * This file is part of meli.
  7. *
  8. * meli is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * meli is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with meli. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. //! Settings for the pager function.
  22. use super::default_vals::*;
  23. use super::deserializers::*;
  24. use melib::ToggleFlag;
  25. /// Settings for the pager function.
  26. #[derive(Debug, Deserialize, Clone, Serialize)]
  27. pub struct PagerSettings {
  28. /// Number of context lines when going to next page.
  29. /// Default: 0
  30. #[serde(default = "zero_val", alias = "pager-context")]
  31. pub pager_context: usize,
  32. /// Stop at the end instead of displaying next mail.
  33. /// Default: false
  34. #[serde(default = "false_val", alias = "pager-stop")]
  35. pub pager_stop: bool,
  36. /// Always show headers when scrolling.
  37. /// Default: true
  38. #[serde(default = "true_val", alias = "headers-sticky")]
  39. pub headers_sticky: bool,
  40. /// The height of the pager in mail view, in percent.
  41. /// Default: 80
  42. #[serde(default = "eighty_val", alias = "pager-ratio")]
  43. pub pager_ratio: usize,
  44. /// A command to pipe mail output through for viewing in pager.
  45. /// Default: None
  46. #[serde(default = "none", deserialize_with = "non_empty_string")]
  47. pub filter: Option<String>,
  48. /// A command to pipe html output before displaying it in a pager
  49. /// Default: None
  50. #[serde(
  51. default = "none",
  52. deserialize_with = "non_empty_string",
  53. alias = "html-filter"
  54. )]
  55. pub html_filter: Option<String>,
  56. /// Respect "format=flowed"
  57. /// Default: true
  58. #[serde(default = "true_val", alias = "format-flowed")]
  59. pub format_flowed: bool,
  60. /// Split long lines that would overflow on the x axis.
  61. /// Default: true
  62. #[serde(default = "true_val", alias = "split-long-lines")]
  63. pub split_long_lines: bool,
  64. /// Minimum text width in columns.
  65. /// Default: 80
  66. #[serde(default = "eighty_val", alias = "minimum-width")]
  67. pub minimum_width: usize,
  68. /// Choose `text/html` alternative if `text/plain` is empty in `multipart/alternative`
  69. /// attachments.
  70. /// Default: true
  71. #[serde(
  72. default = "internal_value_true",
  73. alias = "auto-choose-multipart-alternative"
  74. )]
  75. pub auto_choose_multipart_alternative: ToggleFlag,
  76. }
  77. impl Default for PagerSettings {
  78. fn default() -> Self {
  79. Self {
  80. pager_context: 0,
  81. pager_stop: false,
  82. headers_sticky: true,
  83. pager_ratio: 80,
  84. filter: None,
  85. html_filter: None,
  86. format_flowed: true,
  87. split_long_lines: true,
  88. minimum_width: 80,
  89. auto_choose_multipart_alternative: ToggleFlag::InternalVal(true),
  90. }
  91. }
  92. }