🐝 I really like where this mua is(was?) headed, but it seems as though there has not been much activity recently.
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.

84 lines
2.1 KiB

  1. /*
  2. * meli - ui crate.
  3. *
  4. * Copyright 2017-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. /*! A parser module for user commands passed through the Ex mode.
  22. */
  23. pub use melib::mailbox::{SortField, SortOrder};
  24. use nom::{digit, not_line_ending};
  25. use std;
  26. pub mod actions;
  27. pub use actions::Action::{self, *};
  28. pub use actions::ListingAction::{self, *};
  29. pub use actions::TabAction::{self, *};
  30. named!(
  31. usize_c<usize>,
  32. map_res!(
  33. map_res!(ws!(digit), std::str::from_utf8),
  34. std::str::FromStr::from_str
  35. )
  36. );
  37. named!(
  38. sortfield<SortField>,
  39. map_res!(
  40. map_res!(take_until_s!(" "), std::str::from_utf8),
  41. std::str::FromStr::from_str
  42. )
  43. );
  44. named!(
  45. sortorder<SortOrder>,
  46. map_res!(
  47. map_res!(call!(not_line_ending), std::str::from_utf8),
  48. std::str::FromStr::from_str
  49. )
  50. );
  51. named!(close<Action>, map!(ws!(tag!("close")), |_| Tab(Close)));
  52. named!(
  53. goto<Action>,
  54. preceded!(tag!("b "), map!(call!(usize_c), Action::ViewMailbox))
  55. );
  56. named!(
  57. subsort<Action>,
  58. do_parse!(tag!("subsort ") >> p: pair!(sortfield, sortorder) >> (SubSort(p.0, p.1)))
  59. );
  60. named!(
  61. sort<Action>,
  62. do_parse!(
  63. tag!("sort ") >> p: separated_pair!(sortfield, tag!(" "), sortorder) >> (Sort(p.0, p.1))
  64. )
  65. );
  66. named!(
  67. threaded<Action>,
  68. map!(ws!(tag!("threaded")), |_| Listing(ToggleThreaded))
  69. );
  70. named!(
  71. toggle<Action>,
  72. preceded!(tag!("toggle "), alt_complete!(threaded))
  73. );
  74. named!(pub parse_command<Action>,
  75. alt_complete!( goto | toggle | sort | subsort | close)
  76. );