Commits

Rui Abreu Ferreira  committed c878577

Fix error in line background painting

- Also added debug operator for PaintOpType and cleanup the code
a good bit

  • Participants
  • Parent commits 5b0c905
  • Branches tb-gui

Comments (0)

Files changed (2)

File src/gui/windowwidget.cpp

 	setAttribute(Qt::WA_StaticContents, true);
 }
 
-void WindowWidget::insertLine(uint64_t row, uint64_t count)
-{
-	PaintOp p(INSERT_LINE);
-	p.rect = QRect(0, row*m_fm->height(),
-			m_cols*m_fm->width("W"), m_rows*m_fm->height());
-	p.pos = QPoint(0, count*m_fm->height());
-	queuePaintOp(p);
-}
-
 void WindowWidget::redrawCursor(uint64_t col, uint64_t row)
 {
 
 
 	PaintOp bgp(CLEAR_RECT);
 	bgp.rect = QRect(0, row*m_fm->height(),
-			m_cols*m_fm->width("W"), (row+1)*m_fm->height());
+			m_cols*m_fm->width("W"), m_fm->height());
 	queuePaintOp(bgp);
 
 	if (attrMap.isEmpty()) {
 	queuePaintOp(p);
 }
 
+void WindowWidget::insertLine(uint64_t row, uint64_t count)
+{
+	PaintOp p(INSERT_LINE);
+	p.rect = QRect(0, row*m_fm->height(),
+			m_cols*m_fm->width("W"), m_rows*m_fm->height());
+	p.pos = QPoint(0, count*m_fm->height());
+	queuePaintOp(p);
+}
+
 void WindowWidget::deleteLine(uint64_t row, uint64_t count)
 {
 	PaintOp p(DELETE_LINE);
 			painter.setFont(op.font);
 			painter.drawText( op.pos, op.text);
 			break;
+		case WINDOW_END:
 		case CLEAR_RECT:
 			painter.fillRect(op.rect, m_background);
 			break;
 	}
 	for (uint64_t i=row; i<endrow; i++) {
 		// FIXME: clean this up please
-		PaintOp bgp(CLEAR_RECT);
+		PaintOp bgp(WINDOW_END);
 		bgp.rect = QRect(0, i*m_fm->height(),
 				m_cols*m_fm->width("W"), (i+1)*m_fm->height());
 		queuePaintOp(bgp);
 
 } // Namespace
 
+
+QDebug operator<<(QDebug dbg, const NeovimQt::WindowWidget::PaintOpType t)
+{
+	switch(t) {
+	case NeovimQt::WindowWidget::DELETE_LINE:
+		dbg.space() << "DELETE_LINE";
+		break;
+	case NeovimQt::WindowWidget::INSERT_LINE:
+		dbg.space() << "INSERT_LINE";
+		break;
+	case NeovimQt::WindowWidget::UPDATE_LINE:
+		dbg.space() << "UPDATE_LINE";
+		break;
+	case NeovimQt::WindowWidget::CLEAR_RECT:
+		dbg.space() << "CLEAR_RECT";
+		break;
+	case NeovimQt::WindowWidget::WINDOW_END:
+		dbg.space() << "WINDOW_END";
+		break;
+	case NeovimQt::WindowWidget::NOOP:
+		dbg.space() << "NOOP";
+		break;
+	}
+	return dbg.maybeSpace();
+}
+
+

File src/gui/windowwidget.h

 public:
 	WindowWidget(Gui *g, uint64_t window_id, QWidget *parent=0);
 
-	enum PaintOpType {CLEAR_ALL, DELETE_LINE, INSERT_LINE, UPDATE_LINE, CLEAR_RECT, NOOP};
+	enum PaintOpType {DELETE_LINE, INSERT_LINE, UPDATE_LINE, CLEAR_RECT, WINDOW_END, NOOP};
 	class PaintOp {
 	public:
 		PaintOp(PaintOpType t=NOOP) {type=t;}
 		QString text;
 		QFont font;
 		QColor fg_color, bg_color;
+
 	};
 
 	virtual QSize sizeHint() const;
 	QFontMetrics *m_fm;
 	uint64_t m_rows, m_cols, m_window_id;
 	QColor m_foreground, m_background;
-	QPixmap m_canvas;
 };
 
 
 } // Namespace
 
+QDebug operator<<(QDebug dbg, const NeovimQt::WindowWidget::PaintOpType);
+
 #endif