diff options
Diffstat (limited to 'apps/gui/gwps-common.c')
-rw-r--r-- | apps/gui/gwps-common.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 694bc2a2c8..ab53fe95cc 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -1658,9 +1658,9 @@ static void write_line(struct screen *display, | |||
1658 | bool scroll) | 1658 | bool scroll) |
1659 | { | 1659 | { |
1660 | 1660 | ||
1661 | int left_width, left_xpos; | 1661 | int left_width = 0; /* left_xpos would always be 0 */ |
1662 | int center_width, center_xpos; | 1662 | int center_width = 0, center_xpos; |
1663 | int right_width, right_xpos; | 1663 | int right_width = 0, right_xpos; |
1664 | int ypos; | 1664 | int ypos; |
1665 | int space_width; | 1665 | int space_width; |
1666 | int string_height; | 1666 | int string_height; |
@@ -1671,27 +1671,19 @@ static void write_line(struct screen *display, | |||
1671 | display->getstringsize((unsigned char *)format_align->left, | 1671 | display->getstringsize((unsigned char *)format_align->left, |
1672 | &left_width, &string_height); | 1672 | &left_width, &string_height); |
1673 | } | 1673 | } |
1674 | else { | ||
1675 | left_width = 0; | ||
1676 | } | ||
1677 | left_xpos = 0; | ||
1678 | 1674 | ||
1679 | if (format_align->center != 0) { | 1675 | if (format_align->center != 0) { |
1680 | display->getstringsize((unsigned char *)format_align->center, | 1676 | display->getstringsize((unsigned char *)format_align->center, |
1681 | ¢er_width, &string_height); | 1677 | ¢er_width, &string_height); |
1682 | } | 1678 | } |
1683 | else { | 1679 | |
1684 | center_width = 0; | ||
1685 | } | ||
1686 | center_xpos=(display->width - center_width) / 2; | 1680 | center_xpos=(display->width - center_width) / 2; |
1687 | 1681 | ||
1688 | if (format_align->right != 0) { | 1682 | if (format_align->right != 0) { |
1689 | display->getstringsize((unsigned char *)format_align->right, | 1683 | display->getstringsize((unsigned char *)format_align->right, |
1690 | &right_width, &string_height); | 1684 | &right_width, &string_height); |
1691 | } | 1685 | } |
1692 | else { | 1686 | |
1693 | right_width = 0; | ||
1694 | } | ||
1695 | right_xpos = (display->width - right_width); | 1687 | right_xpos = (display->width - right_width); |
1696 | 1688 | ||
1697 | /* Checks for overlapping strings. | 1689 | /* Checks for overlapping strings. |
@@ -1701,24 +1693,22 @@ static void write_line(struct screen *display, | |||
1701 | /* CASE 1: left and centered string overlap */ | 1693 | /* CASE 1: left and centered string overlap */ |
1702 | /* there is a left string, need to merge left and center */ | 1694 | /* there is a left string, need to merge left and center */ |
1703 | if ((left_width != 0 && center_width != 0) && | 1695 | if ((left_width != 0 && center_width != 0) && |
1704 | (left_xpos + left_width + space_width > center_xpos)) { | 1696 | (left_width + space_width > center_xpos)) { |
1705 | /* replace the former separator '\0' of left and | 1697 | /* replace the former separator '\0' of left and |
1706 | center string with a space */ | 1698 | center string with a space */ |
1707 | *(--format_align->center) = ' '; | 1699 | *(--format_align->center) = ' '; |
1708 | /* calculate the new width and position of the merged string */ | 1700 | /* calculate the new width and position of the merged string */ |
1709 | left_width = left_width + space_width + center_width; | 1701 | left_width = left_width + space_width + center_width; |
1710 | left_xpos = 0; | ||
1711 | /* there is no centered string anymore */ | 1702 | /* there is no centered string anymore */ |
1712 | center_width = 0; | 1703 | center_width = 0; |
1713 | } | 1704 | } |
1714 | /* there is no left string, move center to left */ | 1705 | /* there is no left string, move center to left */ |
1715 | if ((left_width == 0 && center_width != 0) && | 1706 | if ((left_width == 0 && center_width != 0) && |
1716 | (left_xpos + left_width > center_xpos)) { | 1707 | (left_width > center_xpos)) { |
1717 | /* move the center string to the left string */ | 1708 | /* move the center string to the left string */ |
1718 | format_align->left = format_align->center; | 1709 | format_align->left = format_align->center; |
1719 | /* calculate the new width and position of the string */ | 1710 | /* calculate the new width and position of the string */ |
1720 | left_width = center_width; | 1711 | left_width = center_width; |
1721 | left_xpos = 0; | ||
1722 | /* there is no centered string anymore */ | 1712 | /* there is no centered string anymore */ |
1723 | center_width = 0; | 1713 | center_width = 0; |
1724 | } | 1714 | } |
@@ -1755,24 +1745,22 @@ static void write_line(struct screen *display, | |||
1755 | was one or it has been merged in case 1 or 2 */ | 1745 | was one or it has been merged in case 1 or 2 */ |
1756 | /* there is a left string, need to merge left and right */ | 1746 | /* there is a left string, need to merge left and right */ |
1757 | if ((left_width != 0 && center_width == 0 && right_width != 0) && | 1747 | if ((left_width != 0 && center_width == 0 && right_width != 0) && |
1758 | (left_xpos + left_width + space_width > right_xpos)) { | 1748 | (left_width + space_width > right_xpos)) { |
1759 | /* replace the former separator '\0' of left and | 1749 | /* replace the former separator '\0' of left and |
1760 | right string with a space */ | 1750 | right string with a space */ |
1761 | *(--format_align->right) = ' '; | 1751 | *(--format_align->right) = ' '; |
1762 | /* calculate the new width and position of the string */ | 1752 | /* calculate the new width and position of the string */ |
1763 | left_width = left_width + space_width + right_width; | 1753 | left_width = left_width + space_width + right_width; |
1764 | left_xpos = 0; | ||
1765 | /* there is no right string anymore */ | 1754 | /* there is no right string anymore */ |
1766 | right_width = 0; | 1755 | right_width = 0; |
1767 | } | 1756 | } |
1768 | /* there is no left string, move right to left */ | 1757 | /* there is no left string, move right to left */ |
1769 | if ((left_width == 0 && center_width == 0 && right_width != 0) && | 1758 | if ((left_width == 0 && center_width == 0 && right_width != 0) && |
1770 | (left_xpos + left_width > right_xpos)) { | 1759 | (left_width > right_xpos)) { |
1771 | /* move the right string to the left string */ | 1760 | /* move the right string to the left string */ |
1772 | format_align->left = format_align->right; | 1761 | format_align->left = format_align->right; |
1773 | /* calculate the new width and position of the string */ | 1762 | /* calculate the new width and position of the string */ |
1774 | left_width = right_width; | 1763 | left_width = right_width; |
1775 | left_xpos = 0; | ||
1776 | /* there is no right string anymore */ | 1764 | /* there is no right string anymore */ |
1777 | right_width = 0; | 1765 | right_width = 0; |
1778 | } | 1766 | } |
@@ -1801,7 +1789,7 @@ static void write_line(struct screen *display, | |||
1801 | /* print aligned strings */ | 1789 | /* print aligned strings */ |
1802 | if (left_width != 0) | 1790 | if (left_width != 0) |
1803 | { | 1791 | { |
1804 | display->putsxy(left_xpos, ypos, | 1792 | display->putsxy(0, ypos, |
1805 | (unsigned char *)format_align->left); | 1793 | (unsigned char *)format_align->left); |
1806 | } | 1794 | } |
1807 | if (center_width != 0) | 1795 | if (center_width != 0) |