default_theme.rs 4.4 KB

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