Re-generate style definition from attributes.
(self)
| 292 | return self._link_id |
| 293 | |
| 294 | def __str__(self) -> str: |
| 295 | """Re-generate style definition from attributes.""" |
| 296 | if self._style_definition is None: |
| 297 | attributes: List[str] = [] |
| 298 | append = attributes.append |
| 299 | bits = self._set_attributes |
| 300 | if bits & 0b0000000001111: |
| 301 | if bits & 1: |
| 302 | append("bold" if self.bold else "not bold") |
| 303 | if bits & (1 << 1): |
| 304 | append("dim" if self.dim else "not dim") |
| 305 | if bits & (1 << 2): |
| 306 | append("italic" if self.italic else "not italic") |
| 307 | if bits & (1 << 3): |
| 308 | append("underline" if self.underline else "not underline") |
| 309 | if bits & 0b0000111110000: |
| 310 | if bits & (1 << 4): |
| 311 | append("blink" if self.blink else "not blink") |
| 312 | if bits & (1 << 5): |
| 313 | append("blink2" if self.blink2 else "not blink2") |
| 314 | if bits & (1 << 6): |
| 315 | append("reverse" if self.reverse else "not reverse") |
| 316 | if bits & (1 << 7): |
| 317 | append("conceal" if self.conceal else "not conceal") |
| 318 | if bits & (1 << 8): |
| 319 | append("strike" if self.strike else "not strike") |
| 320 | if bits & 0b1111000000000: |
| 321 | if bits & (1 << 9): |
| 322 | append("underline2" if self.underline2 else "not underline2") |
| 323 | if bits & (1 << 10): |
| 324 | append("frame" if self.frame else "not frame") |
| 325 | if bits & (1 << 11): |
| 326 | append("encircle" if self.encircle else "not encircle") |
| 327 | if bits & (1 << 12): |
| 328 | append("overline" if self.overline else "not overline") |
| 329 | if self._color is not None: |
| 330 | append(self._color.name) |
| 331 | if self._bgcolor is not None: |
| 332 | append("on") |
| 333 | append(self._bgcolor.name) |
| 334 | if self._link: |
| 335 | append("link") |
| 336 | append(self._link) |
| 337 | self._style_definition = " ".join(attributes) or "none" |
| 338 | return self._style_definition |
| 339 | |
| 340 | def __bool__(self) -> bool: |
| 341 | """A Style is false if it has no attributes, colors, or links.""" |