default_theme.rs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. use ansi_term::Style;
  2. use ansi_term::Colour::*;
  3. use crate::theme::ColourScale;
  4. use crate::theme::ui_styles::*;
  5. impl UiStyles {
  6. pub fn default_theme(scale: ColourScale) -> Self {
  7. Self {
  8. colourful: true,
  9. filekinds: FileKinds {
  10. normal: Style::default(),
  11. directory: Blue.bold(),
  12. symlink: Cyan.normal(),
  13. pipe: Yellow.normal(),
  14. block_device: Yellow.bold(),
  15. char_device: Yellow.bold(),
  16. socket: Red.bold(),
  17. special: Yellow.normal(),
  18. executable: Green.bold(),
  19. },
  20. perms: Permissions {
  21. user_read: Yellow.bold(),
  22. user_write: Red.bold(),
  23. user_execute_file: Green.bold().underline(),
  24. user_execute_other: Green.bold(),
  25. group_read: Yellow.normal(),
  26. group_write: Red.normal(),
  27. group_execute: Green.normal(),
  28. other_read: Yellow.normal(),
  29. other_write: Red.normal(),
  30. other_execute: Green.normal(),
  31. special_user_file: Purple.normal(),
  32. special_other: Purple.normal(),
  33. attribute: Style::default(),
  34. },
  35. size: Size::colourful(scale),
  36. users: Users {
  37. user_you: Yellow.bold(),
  38. user_someone_else: Style::default(),
  39. group_yours: Yellow.bold(),
  40. group_not_yours: Style::default(),
  41. },
  42. links: Links {
  43. normal: Red.bold(),
  44. multi_link_file: Red.on(Yellow),
  45. },
  46. git: Git {
  47. new: Green.normal(),
  48. modified: Blue.normal(),
  49. deleted: Red.normal(),
  50. renamed: Yellow.normal(),
  51. typechange: Purple.normal(),
  52. ignored: Style::default().dimmed(),
  53. conflicted: Red.normal(),
  54. },
  55. security_context: SecurityContext {
  56. none: Style::default(),
  57. selinux: SELinuxContext {
  58. colon: Style::default().dimmed(),
  59. user: Blue.normal(),
  60. role: Green.normal(),
  61. typ: Yellow.normal(),
  62. range: Cyan.normal(),
  63. },
  64. },
  65. punctuation: Fixed(244).normal(),
  66. date: Blue.normal(),
  67. inode: Purple.normal(),
  68. blocks: Cyan.normal(),
  69. octal: Purple.normal(),
  70. header: Style::default().underline(),
  71. symlink_path: Cyan.normal(),
  72. control_char: Red.normal(),
  73. broken_symlink: Red.normal(),
  74. broken_path_overlay: Style::default().underline(),
  75. }
  76. }
  77. }
  78. impl Size {
  79. pub fn colourful(scale: ColourScale) -> Self {
  80. match scale {
  81. ColourScale::Gradient => Self::colourful_gradient(),
  82. ColourScale::Fixed => Self::colourful_fixed(),
  83. }
  84. }
  85. fn colourful_fixed() -> Self {
  86. Self {
  87. major: Green.bold(),
  88. minor: Green.normal(),
  89. number_byte: Green.bold(),
  90. number_kilo: Green.bold(),
  91. number_mega: Green.bold(),
  92. number_giga: Green.bold(),
  93. number_huge: Green.bold(),
  94. unit_byte: Green.normal(),
  95. unit_kilo: Green.normal(),
  96. unit_mega: Green.normal(),
  97. unit_giga: Green.normal(),
  98. unit_huge: Green.normal(),
  99. }
  100. }
  101. fn colourful_gradient() -> Self {
  102. Self {
  103. major: Green.bold(),
  104. minor: Green.normal(),
  105. number_byte: Fixed(118).normal(),
  106. number_kilo: Fixed(190).normal(),
  107. number_mega: Fixed(226).normal(),
  108. number_giga: Fixed(220).normal(),
  109. number_huge: Fixed(214).normal(),
  110. unit_byte: Green.normal(),
  111. unit_kilo: Green.normal(),
  112. unit_mega: Green.normal(),
  113. unit_giga: Green.normal(),
  114. unit_huge: Green.normal(),
  115. }
  116. }
  117. }