summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2018-12-29 16:58:36 +0100
committerBoris Faure <billiob@gmail.com>2018-12-29 16:58:36 +0100
commit63911989fc12a9be9004295673a6c522531ead82 (patch)
treecb4fc0e9306754ed09eef7c349e9d06376f0e575 /src
parent9cb340e29f97f64af1146c426e14a6374d480110 (diff)
termptyesc: handle deccara in its rectangular form + tests
Diffstat (limited to 'src')
-rw-r--r--src/bin/termptyesc.c116
1 files changed, 115 insertions, 1 deletions
diff --git a/src/bin/termptyesc.c b/src/bin/termptyesc.c
index f4f5004..bfde79c 100644
--- a/src/bin/termptyesc.c
+++ b/src/bin/termptyesc.c
@@ -1551,6 +1551,117 @@ _handle_esc_csi_decfra(Termpty *ty, Eina_Unicode **b)
1551} 1551}
1552 1552
1553static void 1553static void
1554_handle_esc_csi_deccara(Termpty *ty, Eina_Unicode **ptr,
1555 const Eina_Unicode * const end)
1556{
1557 Eina_Unicode *b = *ptr;
1558 int top;
1559 int left;
1560 int bottom;
1561 int right;
1562 int i, len;
1563 Eina_Bool set_bold = EINA_FALSE, reset_bold = EINA_FALSE;
1564 Eina_Bool set_underline = EINA_FALSE, reset_underline = EINA_FALSE;
1565 Eina_Bool set_blink = EINA_FALSE, reset_blink = EINA_FALSE;
1566 Eina_Bool set_reverse = EINA_FALSE, reset_reverse = EINA_FALSE;
1567
1568 top = _csi_arg_get(ty, &b);
1569 left = _csi_arg_get(ty, &b);
1570 bottom = _csi_arg_get(ty, &b);
1571 right = _csi_arg_get(ty, &b);
1572
1573 DBG("DECCARA (%d;%d;%d;%d) Change Attributes in Rectangular Area",
1574 top, left, bottom, right);
1575 if ((top == -CSI_ARG_ERROR) ||
1576 (left == -CSI_ARG_ERROR) ||
1577 (bottom == -CSI_ARG_ERROR) ||
1578 (right == -CSI_ARG_ERROR))
1579 return;
1580
1581 while (b && b < end)
1582 {
1583 int arg = _csi_arg_get(ty, &b);
1584 switch (arg)
1585 {
1586 case -CSI_ARG_ERROR:
1587 return;
1588 case -CSI_ARG_NO_VALUE:
1589 EINA_FALLTHROUGH;
1590 case 0:
1591 set_bold = set_underline = set_blink = set_reverse = EINA_FALSE;
1592 reset_bold = reset_underline = reset_blink = reset_reverse = EINA_TRUE;
1593 break;
1594 case 1:
1595 set_bold = EINA_TRUE;
1596 reset_bold = EINA_FALSE;
1597 break;
1598 case 4:
1599 set_underline = EINA_TRUE;
1600 reset_underline = EINA_FALSE;
1601 break;
1602 case 5:
1603 set_blink = EINA_TRUE;
1604 reset_blink = EINA_FALSE;
1605 break;
1606 case 7:
1607 set_reverse = EINA_TRUE;
1608 reset_reverse = EINA_FALSE;
1609 break;
1610 case 22:
1611 set_bold = EINA_FALSE;
1612 reset_bold = EINA_TRUE;
1613 break;
1614 case 24:
1615 set_underline = EINA_FALSE;
1616 reset_underline = EINA_TRUE;
1617 break;
1618 case 25:
1619 set_blink = EINA_FALSE;
1620 reset_blink = EINA_TRUE;
1621 break;
1622 case 27:
1623 set_reverse = EINA_FALSE;
1624 reset_reverse = EINA_TRUE;
1625 break;
1626 default:
1627 WRN("Invalid change attribute [%i]", arg);
1628 ty->decoding_error = EINA_TRUE;
1629 return;
1630 }
1631 }
1632
1633 if (_clean_up_rect_coordinates(ty, &top, &left, &bottom, &right) < 0)
1634 return;
1635
1636 len = right - left;
1637
1638 for (; top <= bottom; top++)
1639 {
1640 Termcell *cells = &(TERMPTY_SCREEN(ty, left, top));
1641 for (i = 0; i < len; i++)
1642 {
1643 Termatt * att = &cells[i].att;
1644 if (set_bold)
1645 att->bold = 1;
1646 if (set_underline)
1647 att->underline = 1;
1648 if (set_blink)
1649 att->blink = 1;
1650 if (set_reverse)
1651 att->inverse = 1;
1652 if (reset_bold)
1653 att->bold = 0;
1654 if (reset_underline)
1655 att->underline = 0;
1656 if (reset_blink)
1657 att->blink = 0;
1658 if (reset_reverse)
1659 att->inverse = 0;
1660 }
1661 }
1662}
1663
1664static void
1554_handle_esc_csi_decera(Termpty *ty, Eina_Unicode **b) 1665_handle_esc_csi_decera(Termpty *ty, Eina_Unicode **b)
1555{ 1666{
1556 int top = _csi_arg_get(ty ,b); 1667 int top = _csi_arg_get(ty ,b);
@@ -2111,7 +2222,10 @@ HVP:
2111 } 2222 }
2112 break; 2223 break;
2113 case 'r': 2224 case 'r':
2114 _handle_esc_csi_decstbm(ty, &b); 2225 if (*(cc-1) == '$')
2226 _handle_esc_csi_deccara(ty, &b, be-1);
2227 else
2228 _handle_esc_csi_decstbm(ty, &b);
2115 break; 2229 break;
2116 case 's': 2230 case 's':
2117 if (ty->termstate.lr_margins) 2231 if (ty->termstate.lr_margins)