@@ -223,29 +223,17 @@ void QLightTerminal::paintEvent(QPaintEvent *event) {
223223
224224 font = painter.font ();
225225
226- if ((g.mode & ATTR_BOLD) && !font.bold ()) {
227- font.setBold (true );
228- } else if (!(g.mode & ATTR_BOLD) && font.bold ()) {
229- font.setBold (false );
230- }
226+ bool bold = g.mode & ATTR_BOLD;
227+ if (bold != font.bold ()) font.setBold (bold);
231228
232- if ((g.mode & ATTR_ITALIC) && !font.italic ()) {
233- font.setItalic (true );
234- } else if (!(g.mode & ATTR_ITALIC) && font.italic ()) {
235- font.setItalic (false );
236- }
229+ bool italic = g.mode & ATTR_ITALIC;
230+ if (italic != font.italic ()) font.setItalic (italic);
237231
238- if ((g.mode & ATTR_UNDERLINE) && !font.underline ()) {
239- font.setUnderline (true );
240- } else if (!(g.mode & ATTR_UNDERLINE) && font.underline ()) {
241- font.setUnderline (false );
242- }
232+ bool underline = g.mode & ATTR_UNDERLINE;
233+ if (underline != font.underline ()) font.setUnderline (underline);
243234
244- if ((g.mode & ATTR_STRUCK) && !font.strikeOut ()) {
245- font.setStrikeOut (true );
246- } else if (!(g.mode & ATTR_STRUCK) && font.strikeOut ()) {
247- font.setStrikeOut (false );
248- }
235+ bool strikethrough = g.mode & ATTR_STRUCK;
236+ if (strikethrough != font.strikeOut ()) font.setStrikeOut (strikethrough);
249237 }
250238
251239 // draw current line state and change color
@@ -260,7 +248,8 @@ void QLightTerminal::paintEvent(QPaintEvent *event) {
260248 }
261249
262250 if (IS_TRUECOL (bgColor)) {
263- painter.setBackground (QBrush (QColor (RED_FROM_TRUE (bgColor), GREEN_FROM_TRUE (bgColor), BLUE_FROM_TRUE (bgColor))));
251+ painter.setBackground (
252+ QBrush (QColor (RED_FROM_TRUE (bgColor), GREEN_FROM_TRUE (bgColor), BLUE_FROM_TRUE (bgColor))));
264253 } else {
265254 painter.setBackground (QBrush (colors[bgColor]));
266255 }
@@ -290,7 +279,8 @@ void QLightTerminal::paintEvent(QPaintEvent *event) {
290279 }
291280 bgColor = st->term .c .attr .fg ;
292281 if (IS_TRUECOL (bgColor)) {
293- painter.setBackground (QBrush (QColor (RED_FROM_TRUE (bgColor), GREEN_FROM_TRUE (bgColor), BLUE_FROM_TRUE (bgColor))));
282+ painter.setBackground (
283+ QBrush (QColor (RED_FROM_TRUE (bgColor), GREEN_FROM_TRUE (bgColor), BLUE_FROM_TRUE (bgColor))));
294284 } else {
295285 painter.setBackground (QBrush (colors[bgColor]));
296286 }
@@ -458,7 +448,7 @@ void QLightTerminal::mouseMoveEvent(QMouseEvent *event) {
458448 int col = (pos.x () - win.hPadding ) / win.charWith ;
459449 double row = (pos.y () - win.vPadding ) / win.lineheight ;
460450
461- if (row >= this ->win .viewPortHeight ) {
451+ if (row >= this ->win .viewPortHeight ) {
462452 return ;
463453 }
464454
0 commit comments