unset.go 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. package lipgloss
  2. // unset unsets a property from a style.
  3. func (s *Style) unset(key propKey) {
  4. s.props = s.props.unset(key)
  5. }
  6. // UnsetBold removes the bold style rule, if set.
  7. func (s Style) UnsetBold() Style {
  8. s.unset(boldKey)
  9. return s
  10. }
  11. // UnsetItalic removes the italic style rule, if set.
  12. func (s Style) UnsetItalic() Style {
  13. s.unset(italicKey)
  14. return s
  15. }
  16. // UnsetUnderline removes the underline style rule, if set.
  17. func (s Style) UnsetUnderline() Style {
  18. s.unset(underlineKey)
  19. return s
  20. }
  21. // UnsetStrikethrough removes the strikethrough style rule, if set.
  22. func (s Style) UnsetStrikethrough() Style {
  23. s.unset(strikethroughKey)
  24. return s
  25. }
  26. // UnsetReverse removes the reverse style rule, if set.
  27. func (s Style) UnsetReverse() Style {
  28. s.unset(reverseKey)
  29. return s
  30. }
  31. // UnsetBlink removes the blink style rule, if set.
  32. func (s Style) UnsetBlink() Style {
  33. s.unset(blinkKey)
  34. return s
  35. }
  36. // UnsetFaint removes the faint style rule, if set.
  37. func (s Style) UnsetFaint() Style {
  38. s.unset(faintKey)
  39. return s
  40. }
  41. // UnsetForeground removes the foreground style rule, if set.
  42. func (s Style) UnsetForeground() Style {
  43. s.unset(foregroundKey)
  44. return s
  45. }
  46. // UnsetBackground removes the background style rule, if set.
  47. func (s Style) UnsetBackground() Style {
  48. s.unset(backgroundKey)
  49. return s
  50. }
  51. // UnsetWidth removes the width style rule, if set.
  52. func (s Style) UnsetWidth() Style {
  53. s.unset(widthKey)
  54. return s
  55. }
  56. // UnsetHeight removes the height style rule, if set.
  57. func (s Style) UnsetHeight() Style {
  58. s.unset(heightKey)
  59. return s
  60. }
  61. // UnsetAlign removes the horizontal and vertical text alignment style rule, if set.
  62. func (s Style) UnsetAlign() Style {
  63. s.unset(alignHorizontalKey)
  64. s.unset(alignVerticalKey)
  65. return s
  66. }
  67. // UnsetAlignHorizontal removes the horizontal text alignment style rule, if set.
  68. func (s Style) UnsetAlignHorizontal() Style {
  69. s.unset(alignHorizontalKey)
  70. return s
  71. }
  72. // UnsetAlignVertical removes the vertical text alignment style rule, if set.
  73. func (s Style) UnsetAlignVertical() Style {
  74. s.unset(alignVerticalKey)
  75. return s
  76. }
  77. // UnsetPadding removes all padding style rules.
  78. func (s Style) UnsetPadding() Style {
  79. s.unset(paddingLeftKey)
  80. s.unset(paddingRightKey)
  81. s.unset(paddingTopKey)
  82. s.unset(paddingBottomKey)
  83. return s
  84. }
  85. // UnsetPaddingLeft removes the left padding style rule, if set.
  86. func (s Style) UnsetPaddingLeft() Style {
  87. s.unset(paddingLeftKey)
  88. return s
  89. }
  90. // UnsetPaddingRight removes the right padding style rule, if set.
  91. func (s Style) UnsetPaddingRight() Style {
  92. s.unset(paddingRightKey)
  93. return s
  94. }
  95. // UnsetPaddingTop removes the top padding style rule, if set.
  96. func (s Style) UnsetPaddingTop() Style {
  97. s.unset(paddingTopKey)
  98. return s
  99. }
  100. // UnsetPaddingBottom removes the bottom padding style rule, if set.
  101. func (s Style) UnsetPaddingBottom() Style {
  102. s.unset(paddingBottomKey)
  103. return s
  104. }
  105. // UnsetColorWhitespace removes the rule for coloring padding, if set.
  106. func (s Style) UnsetColorWhitespace() Style {
  107. s.unset(colorWhitespaceKey)
  108. return s
  109. }
  110. // UnsetMargins removes all margin style rules.
  111. func (s Style) UnsetMargins() Style {
  112. s.unset(marginLeftKey)
  113. s.unset(marginRightKey)
  114. s.unset(marginTopKey)
  115. s.unset(marginBottomKey)
  116. return s
  117. }
  118. // UnsetMarginLeft removes the left margin style rule, if set.
  119. func (s Style) UnsetMarginLeft() Style {
  120. s.unset(marginLeftKey)
  121. return s
  122. }
  123. // UnsetMarginRight removes the right margin style rule, if set.
  124. func (s Style) UnsetMarginRight() Style {
  125. s.unset(marginRightKey)
  126. return s
  127. }
  128. // UnsetMarginTop removes the top margin style rule, if set.
  129. func (s Style) UnsetMarginTop() Style {
  130. s.unset(marginTopKey)
  131. return s
  132. }
  133. // UnsetMarginBottom removes the bottom margin style rule, if set.
  134. func (s Style) UnsetMarginBottom() Style {
  135. s.unset(marginBottomKey)
  136. return s
  137. }
  138. // UnsetMarginBackground removes the margin's background color. Note that the
  139. // margin's background color can be set from the background color of another
  140. // style during inheritance.
  141. func (s Style) UnsetMarginBackground() Style {
  142. s.unset(marginBackgroundKey)
  143. return s
  144. }
  145. // UnsetBorderStyle removes the border style rule, if set.
  146. func (s Style) UnsetBorderStyle() Style {
  147. s.unset(borderStyleKey)
  148. return s
  149. }
  150. // UnsetBorderTop removes the border top style rule, if set.
  151. func (s Style) UnsetBorderTop() Style {
  152. s.unset(borderTopKey)
  153. return s
  154. }
  155. // UnsetBorderRight removes the border right style rule, if set.
  156. func (s Style) UnsetBorderRight() Style {
  157. s.unset(borderRightKey)
  158. return s
  159. }
  160. // UnsetBorderBottom removes the border bottom style rule, if set.
  161. func (s Style) UnsetBorderBottom() Style {
  162. s.unset(borderBottomKey)
  163. return s
  164. }
  165. // UnsetBorderLeft removes the border left style rule, if set.
  166. func (s Style) UnsetBorderLeft() Style {
  167. s.unset(borderLeftKey)
  168. return s
  169. }
  170. // UnsetBorderForeground removes all border foreground color styles, if set.
  171. func (s Style) UnsetBorderForeground() Style {
  172. s.unset(borderTopForegroundKey)
  173. s.unset(borderRightForegroundKey)
  174. s.unset(borderBottomForegroundKey)
  175. s.unset(borderLeftForegroundKey)
  176. return s
  177. }
  178. // UnsetBorderTopForeground removes the top border foreground color rule,
  179. // if set.
  180. func (s Style) UnsetBorderTopForeground() Style {
  181. s.unset(borderTopForegroundKey)
  182. return s
  183. }
  184. // UnsetBorderRightForeground removes the right border foreground color rule,
  185. // if set.
  186. func (s Style) UnsetBorderRightForeground() Style {
  187. s.unset(borderRightForegroundKey)
  188. return s
  189. }
  190. // UnsetBorderBottomForeground removes the bottom border foreground color
  191. // rule, if set.
  192. func (s Style) UnsetBorderBottomForeground() Style {
  193. s.unset(borderBottomForegroundKey)
  194. return s
  195. }
  196. // UnsetBorderLeftForeground removes the left border foreground color rule,
  197. // if set.
  198. func (s Style) UnsetBorderLeftForeground() Style {
  199. s.unset(borderLeftForegroundKey)
  200. return s
  201. }
  202. // UnsetBorderBackground removes all border background color styles, if
  203. // set.
  204. func (s Style) UnsetBorderBackground() Style {
  205. s.unset(borderTopBackgroundKey)
  206. s.unset(borderRightBackgroundKey)
  207. s.unset(borderBottomBackgroundKey)
  208. s.unset(borderLeftBackgroundKey)
  209. return s
  210. }
  211. // UnsetBorderTopBackgroundColor removes the top border background color rule,
  212. // if set.
  213. //
  214. // Deprecated: This function simply calls Style.UnsetBorderTopBackground.
  215. func (s Style) UnsetBorderTopBackgroundColor() Style {
  216. return s.UnsetBorderTopBackground()
  217. }
  218. // UnsetBorderTopBackground removes the top border background color rule,
  219. // if set.
  220. func (s Style) UnsetBorderTopBackground() Style {
  221. s.unset(borderTopBackgroundKey)
  222. return s
  223. }
  224. // UnsetBorderRightBackground removes the right border background color
  225. // rule, if set.
  226. func (s Style) UnsetBorderRightBackground() Style {
  227. s.unset(borderRightBackgroundKey)
  228. return s
  229. }
  230. // UnsetBorderBottomBackground removes the bottom border background color
  231. // rule, if set.
  232. func (s Style) UnsetBorderBottomBackground() Style {
  233. s.unset(borderBottomBackgroundKey)
  234. return s
  235. }
  236. // UnsetBorderLeftBackground removes the left border color rule, if set.
  237. func (s Style) UnsetBorderLeftBackground() Style {
  238. s.unset(borderLeftBackgroundKey)
  239. return s
  240. }
  241. // UnsetInline removes the inline style rule, if set.
  242. func (s Style) UnsetInline() Style {
  243. s.unset(inlineKey)
  244. return s
  245. }
  246. // UnsetMaxWidth removes the max width style rule, if set.
  247. func (s Style) UnsetMaxWidth() Style {
  248. s.unset(maxWidthKey)
  249. return s
  250. }
  251. // UnsetMaxHeight removes the max height style rule, if set.
  252. func (s Style) UnsetMaxHeight() Style {
  253. s.unset(maxHeightKey)
  254. return s
  255. }
  256. // UnsetTabWidth removes the tab width style rule, if set.
  257. func (s Style) UnsetTabWidth() Style {
  258. s.unset(tabWidthKey)
  259. return s
  260. }
  261. // UnsetUnderlineSpaces removes the value set by UnderlineSpaces.
  262. func (s Style) UnsetUnderlineSpaces() Style {
  263. s.unset(underlineSpacesKey)
  264. return s
  265. }
  266. // UnsetStrikethroughSpaces removes the value set by StrikethroughSpaces.
  267. func (s Style) UnsetStrikethroughSpaces() Style {
  268. s.unset(strikethroughSpacesKey)
  269. return s
  270. }
  271. // UnsetTransform removes the value set by Transform.
  272. func (s Style) UnsetTransform() Style {
  273. s.unset(transformKey)
  274. return s
  275. }
  276. // UnsetString sets the underlying string value to the empty string.
  277. func (s Style) UnsetString() Style {
  278. s.value = ""
  279. return s
  280. }