def draw(self): minY = min(self.size.y, self.terminal.rows) minX = min(self.size.x, self.terminal.cols) for y in range(minY): buffer = DrawBuffer(True) for x in range(minX): cell = self.terminal.cells[y][x] attr = cell.attr c = cell.color if attr & curses.A_REVERSE: c = self.reverseColor(c) buffer.putAttribute(x, c) buffer.putChar(x, chr(cell.char)) self.writeLine(0, y, minX, 1, buffer) self.setCursor(self.terminal.currCol, self.terminal.currRow) if self.terminal.state & STATE_CURSOR_INVIS: self.hideCursor() else: self.showCursor() if self.terminal.state & STATE_TITLE_CHANGED: self.window.setTitle(self.terminal.title) self.terminal.state &= ~STATE_TITLE_CHANGED
def draw(self): """ Draws the `ListViewer` object with the default palette by repeatedly calling `getText()` for each visible item. Takes into account the `focused` and `selected` items and whether the view is `sfActive`. """ focusedColor = 0 b = DrawBuffer() active_ = (self.state & sfSelected | sfActive) == (sfSelected | sfActive) if active_: normalColor = self.getColor(1) focusedColor = self.getColor(3) selectedColor = self.getColor(4) else: normalColor = self.getColor(2) selectedColor = self.getColor(4) if self.hScrollBar: indent = self.hScrollBar.value else: indent = 0 colWidth = self.size.x // self.numCols + 1 for i in range(self.size.y): for j in range(self.numCols): item = j * self.size.y + i + self.topItem curCol = j * colWidth if active_ and (self.focused == item) and (self._range > 0): color = focusedColor self.setCursor(curCol + 1, i) scOff = 2 elif item < self._range and self.isSelected(item): color = selectedColor scOff = 2 else: color = normalColor scOff = 4 b.moveChar(curCol, ' ', color, colWidth) if item < self._range: text = self.getText(item, colWidth + indent)[indent:indent + colWidth] b.moveStr(curCol + 1, text, color) if showMarkers: b.putChar(curCol, SPECIAL_CHARS[scOff]) b.putChar(curCol + colWidth - 2, SPECIAL_CHARS[scOff + 1]) elif i == 0 and j == 0: b.moveStr(curCol + 1, self.emptyText, self.getColor(1)) b.moveChar(curCol + colWidth - 1, self.separatorChar, self.getColor(5), 1) self.writeLine(0, i, self.size.x, 1, b)
def draw(self): b = DrawBuffer() b.moveChar(0, ' ', 0x70, self.size.x) for y in range(self.size.y + 1): if y < 4: for x in range(4): c = y * 4 + x b.moveChar(x * 3, self.icon, c, 3) if c == self._color: b.putChar(x * 3 + 1, self.icon_reversed) if c == 0: b.putAttribute(x * 3 + 1, 0x70) self.writeLine(0, y, self.size.x, 1, b)
def draw(self): b = DrawBuffer() focusedColor = self.getColor(3) selectedColor = self.getColor(4) if self.headingMode: normalColor = self.getColor(6) elif self.state & (sfSelected | sfActive) == (sfSelected | sfActive): normalColor = self.getColor(1) else: normalColor = self.getColor(2) posColumn = 0 for column in range(self.leftColumn, self.numColumns + 1): if posColumn > self.size.x: break if column < self.numColumns: thisWidth = self.columnWidth[column] else: thisWidth = self.size.x - posColumn + 1 for i in range(self.size.y): row = i + self.topRow color = normalColor scOff = 0 if self.headingMode: scOff = 4 elif (self.state & (sfSelected | sfActive) == (sfSelected | sfActive) and self.focusedRow == row and self.focusedColumn == column and self.numRows): color = focusedColor self.setCursor(posColumn + 1, i) scOff = 0 elif column < self.numColumns and row < self.numRows and self.isSelected(column, row): color = selectedColor scOff = 4 b.moveChar(0, ' ', color, thisWidth) if column < self.numColumns and row < self.numRows: text = self.getText(column, row, thisWidth) b.moveStr(1, text, color) if self.showMarkers: b.putChar(0, SPECIAL_CHARS[scOff]) b.putChar(thisWidth - 2, SPECIAL_CHARS[scOff + 1]) elif not (i or column): b.moveStr(1, _('<empty>'), self.getColor(1)) if not self.headingMode and column < self.numColumns - 1 and row < self.numRows: b.moveChar(thisWidth - 1, '│', self.getColor(5), 1) self.writeLine(posColumn, i, thisWidth, 1, b) posColumn += thisWidth
def draw(self): b = DrawBuffer() if self._light: color = self.getColor(0x0402) scOff = 0 else: color = self.getColor(0x0301) scOff = 4 b.moveChar(0, ' ', color, self.size.x) if self._text: b.moveCStr(1, self._text, color) if self.showMarkers: b.putChar(0, SPECIAL_CHARS[scOff]) self.writeLine(0, 0, self.size.x, 1, b)
def draw(self): b = DrawBuffer() if not self.state & sfDragging: color = self.getColor(1) frame = self.dragFrame else: color = self.getColor(2) frame = self.normalFrame b.moveChar(0, frame, color, self.size.x) if self._modified: b.putChar(0, '☼') s = ' {:3d}:{:3d} '.format(self._location.y + 1, self._location.x + 1) b.moveCStr(8 - s.find(':'), s, color) self.writeBuf(0, 0, self.size.x, 1, b)
def drawState(self, down): b = DrawBuffer() ch = ' ' if self.state & sfDisabled: cButton = self.getColor(0x0404) else: cButton = self.getColor(0x0501) if self.state & sfActive: if self.state & sfSelected: cButton = self.getColor(0x0703) elif self._amDefault: cButton = self.getColor(0x0602) cShadow = self.getColor(8) s = self.size.x - 1 titleRow = self.size.y // 2 - 1 for y in range(self.size.y - 1): b.moveChar(0, ' ', cButton, self.size.x) b.putAttribute(0, cShadow) if down: b.putAttribute(1, cShadow) ch = ' ' i = 2 else: b.putAttribute(s, cShadow) if self.showMarkers: ch = ' ' else: if y == 0: b.putChar(s, self.shadows[0]) else: b.putChar(s, self.shadows[1]) ch = self.shadows[2] i = 1 if y == titleRow and self.title: self.__drawTitle(b, s, i, cButton, down) if self.showMarkers and down: b.putChar(1, self.markers[0]) b.putChar(s - 1, self.markers[1]) self.writeLine(0, y, self.size.x, 1, b) b.moveChar(0, ' ', cShadow, 2) b.moveChar(2, ch, cShadow, s - 1) self.writeLine(0, self.size.y - 1, self.size.x, 1, b)
def draw(self): """ Draws the framed menu box and associated menu items in the default colors. """ b = DrawBuffer() cSelect = self.getColor(0x0604) cNormDisabled = self.getColor(0x0202) cSelDisabled = self.getColor(0x0505) y = 0 color = self.cNormal self.__frameLine(b, 0, color) self.writeBuf(0, y, self.size.x, 1, b) y += 1 if self.menu: for p in self.menu.items: color = self.cNormal if not p.name: self.__frameLine(b, 15, color) else: if p.disabled: if p is self._current: color = cSelDisabled else: color = cNormDisabled elif p is self._current: color = cSelect self.__frameLine(b, 10, color) b.moveCStr(3, p.name, color) if not p.command: b.putChar(self.size.x - 4, self.subMenuIndicator) elif p.param: b.moveStr(self.size.x - 3 - len(p.param), p.param, color) self.writeBuf(0, y, self.size.x, 1, b) y += 1 color = self.cNormal self.__frameLine(b, 5, color) self.writeBuf(0, y, self.size.x, 1, b)
def drawMultiBox(self, icon, marker): b = DrawBuffer() cNorm = self.getColor(0x0301) cSel = self.getColor(0x0402) cDis = self.getColor(0x0505) for i in range(self.size.y): b.moveChar(0, ' ', cNorm, self.size.x) for j in range((len(self._strings) - 1) // self.size.y + 1): cur = j * self.size.y + i if cur < len(self._strings): col = self.__column(cur) if col < self.size.x: if not self.buttonState(cur): color = cDis elif (cur == self._sel) and (self.state & sfSelected): color = cSel else: color = cNorm b.moveChar(col, ' ', color, self.size.x - col) b.moveCStr(col, icon, color) b.putChar(col + 2, marker[self.multiMark(cur)]) b.moveCStr(col + 5, self._strings[cur], color) if (self.showMarkers and ((self.state & sfSelected) != 0 and cur == self._sel)): b.putChar(col, SPECIAL_CHARS[0]) b.putChar( self.__column(cur + self.size.y) - 1, SPECIAL_CHARS[1]) self.writeBuf(0, i, self.size.x, 1, b) self.setCursor(self.__column(self._sel) + 2, self.__row(self._sel))
def draw(self): """ Draws the frame with color attributes and icons appropriate to the current state flags: active, inactive, being dragged. Adds zoom, close and resize icons depending on the owner window's flags. Adds the title, if any, from the owning window's title data member. Active windows are drawn with a double-lined frame and any icons; inactive windows are drawn with a single-lined frame and no icons. """ f = 0 drawable = DrawBuffer() if self.state & sfDragging: cFrame = 0x0505 cTitle = 0x0005 elif not (self.state & sfActive): cFrame = 0x0101 cTitle = 0x0002 else: cFrame = 0x0503 cTitle = 0x0004 f = 9 cFrame = self.getColor(cFrame) cTitle = self.getColor(cTitle) width = self.size.x lineLength = width - 10 if self.owner.flags & (wfClose | wfZoom): lineLength -= 6 self.__frameLine(drawable, 0, f, cFrame & 0xFF) if self.owner.number != wnNoNumber and self.owner.number < 10: lineLength -= 4 if self.owner.flags & wfZoom: i = 7 else: i = 3 drawable.putChar(width - i, chr(self.owner.number + ord('0'))) if self.owner: title = self.owner.getTitle(lineLength) if title: lineLength = min(len(title), width - 10) # min(nameLength(title), width - 10) lineLength = max(lineLength, 0) i = (width - lineLength) >> 1 drawable.putChar(i - 1, ' ') drawable.moveBuf(i, title, cTitle, lineLength) drawable.putChar(i + lineLength, ' ') if self.state & sfActive: if self.owner.flags & wfClose: drawable.moveCStr(2, self.closeIcon, cFrame) if self.owner.flags & wfZoom: minSize = Point() maxSize = Point() self.owner.sizeLimits(minSize, maxSize) if self.owner.size == maxSize: drawable.moveCStr(width - 5, self.unZoomIcon, cFrame) else: drawable.moveCStr(width - 5, self.zoomIcon, cFrame) self.writeLine(0, 0, self.size.x, 1, drawable) for i in range(1, self.size.y - 1): self.__frameLine(drawable, i, f + 3, cFrame) self.writeLine(0, i, self.size.x, 1, drawable) self.__frameLine(drawable, self.size.y - 1, f + 6, cFrame) if self.state & sfActive: if self.owner.flags & wfGrow: drawable.moveCStr(width - 2, self.dragIcon, cFrame) self.writeLine(0, self.size.y - 1, self.size.x, 1, drawable)