Render the Glyph at this position.
(self, window, state)
| 144 | session.add(self) |
| 145 | |
| 146 | def render(self, window, state): |
| 147 | """Render the Glyph at this position.""" |
| 148 | |
| 149 | col = 0 |
| 150 | row = 0 |
| 151 | glyph = self.glyph |
| 152 | data = glyph.glyph_for_state(self, state) |
| 153 | for color, char in [ |
| 154 | (data[i], data[i + 1]) for i in range(0, len(data), 2) |
| 155 | ]: |
| 156 | x = self.x + col |
| 157 | y = self.y + row |
| 158 | if 0 <= x <= MAX_X and 0 <= y <= MAX_Y: |
| 159 | window.addstr( |
| 160 | y + VERT_PADDING, |
| 161 | x + HORIZ_PADDING, |
| 162 | char, |
| 163 | _COLOR_PAIRS[color], |
| 164 | ) |
| 165 | col += 1 |
| 166 | if col == glyph.width: |
| 167 | col = 0 |
| 168 | row += 1 |
| 169 | if self.label: |
| 170 | self._render_label(window, False) |
| 171 | |
| 172 | def _render_label(self, window, blank): |
| 173 | label = self.label if not blank else " " * len(self.label) |
no test coverage detected