Changeset View
Changeset View
Standalone View
Standalone View
src/TerminalDisplay.cpp
Show First 20 Lines • Show All 1887 Lines • ▼ Show 20 Line(s) | 1856 | for (; x <= rect.right(); x++) { | |||
---|---|---|---|---|---|
1888 | 1888 | | |||
1889 | const bool lineDraw = _image[loc(x, y)].isLineChar(); | 1889 | const bool lineDraw = _image[loc(x, y)].isLineChar(); | ||
1890 | const bool doubleWidth = (_image[qMin(loc(x, y) + 1, _imageSize - 1)].character == 0); | 1890 | const bool doubleWidth = (_image[qMin(loc(x, y) + 1, _imageSize - 1)].character == 0); | ||
1891 | const CharacterColor currentForeground = _image[loc(x, y)].foregroundColor; | 1891 | const CharacterColor currentForeground = _image[loc(x, y)].foregroundColor; | ||
1892 | const CharacterColor currentBackground = _image[loc(x, y)].backgroundColor; | 1892 | const CharacterColor currentBackground = _image[loc(x, y)].backgroundColor; | ||
1893 | const RenditionFlags currentRendition = _image[loc(x, y)].rendition; | 1893 | const RenditionFlags currentRendition = _image[loc(x, y)].rendition; | ||
1894 | const bool rtl = isRtl(_image[loc(x, y)]); | 1894 | const bool rtl = isRtl(_image[loc(x, y)]); | ||
1895 | 1895 | | |||
1896 | if(_image[loc(x, y)].character <= 0x7e || rtl) { | 1896 | const auto isInsideDrawArea = [&](int column) { return column <= rect.right(); }; | ||
1897 | while (x + len <= rect.right() && | 1897 | const auto hasSameColors = [&](int column) { | ||
1898 | _image[loc(x + len, y)].foregroundColor == currentForeground && | 1898 | return _image[loc(column, y)].foregroundColor == currentForeground | ||
1899 | _image[loc(x + len, y)].backgroundColor == currentBackground && | 1899 | && _image[loc(column, y)].backgroundColor == currentBackground; | ||
1900 | (_image[loc(x + len, y)].rendition & ~RE_EXTENDED_CHAR) == (currentRendition & ~RE_EXTENDED_CHAR) && | 1900 | }; | ||
1901 | (_image[qMin(loc(x + len, y) + 1, _imageSize - 1)].character == 0) == doubleWidth && | 1901 | const auto hasSameRendition = [&](int column) { | ||
1902 | _image[loc(x + len, y)].isLineChar() == lineDraw && | 1902 | return (_image[loc(column, y)].rendition & ~RE_EXTENDED_CHAR) | ||
1903 | (_image[loc(x + len, y)].character <= 0x7e || rtl)) { | 1903 | == (currentRendition & ~RE_EXTENDED_CHAR); | ||
1904 | }; | ||||
1905 | const auto hasSameWidth = [&](int column) { | ||||
1906 | const int characterLoc = qMin(loc(column, y) + 1, _imageSize - 1); | ||||
1907 | return (_image[characterLoc].character == 0) == doubleWidth; | ||||
1908 | }; | ||||
1909 | const auto canBeGrouped = [&](int column) { | ||||
1910 | return _image[loc(column, y)].character <= 0x7e || rtl; | ||||
1911 | }; | ||||
1912 | | ||||
1913 | if (canBeGrouped(x)) { | ||||
1914 | while (isInsideDrawArea(x + len) && hasSameColors(x + len) | ||||
1915 | && hasSameRendition(x + len) && hasSameWidth(x + len) | ||||
1916 | && canBeGrouped(x + len)) { | ||||
1904 | const uint c = _image[loc(x + len, y)].character; | 1917 | const uint c = _image[loc(x + len, y)].character; | ||
1905 | if ((_image[loc(x + len, y)].rendition & RE_EXTENDED_CHAR) != 0) { | 1918 | if ((_image[loc(x + len, y)].rendition & RE_EXTENDED_CHAR) != 0) { | ||
1906 | // sequence of characters | 1919 | // sequence of characters | ||
1907 | ushort extendedCharLength = 0; | 1920 | ushort extendedCharLength = 0; | ||
1908 | const uint* chars = ExtendedCharTable::instance.lookupExtendedChar(c, extendedCharLength); | 1921 | const uint* chars = ExtendedCharTable::instance.lookupExtendedChar(c, extendedCharLength); | ||
1909 | if (chars != nullptr) { | 1922 | if (chars != nullptr) { | ||
1910 | Q_ASSERT(extendedCharLength > 1); | 1923 | Q_ASSERT(extendedCharLength > 1); | ||
1911 | bufferSize += extendedCharLength - 1; | 1924 | bufferSize += extendedCharLength - 1; | ||
Show All 12 Lines | 1932 | } else { | |||
1924 | } | 1937 | } | ||
1925 | } | 1938 | } | ||
1926 | 1939 | | |||
1927 | if (doubleWidth) { // assert((_image[loc(x+len,y)+1].character == 0)), see above if condition | 1940 | if (doubleWidth) { // assert((_image[loc(x+len,y)+1].character == 0)), see above if condition | ||
1928 | len++; // Skip trailing part of multi-column character | 1941 | len++; // Skip trailing part of multi-column character | ||
1929 | } | 1942 | } | ||
1930 | len++; | 1943 | len++; | ||
1931 | } | 1944 | } | ||
1945 | } else { | ||||
1946 | // Group spaces following any non-wide character with the character. This allows for | ||||
1947 | // rendering ambiguous characters with wide glyphs without clipping them. | ||||
1948 | while (!doubleWidth && isInsideDrawArea(x + len) | ||||
1949 | && _image[loc(x + len, y)].character == ' ' && hasSameColors(x + len) | ||||
1950 | && hasSameRendition(x + len)) { | ||||
1951 | // disstrU intentionally not modified - trailing spaces are meaningless | ||||
1952 | len++; | ||||
1953 | } | ||||
1932 | } | 1954 | } | ||
1933 | if ((x + len < _usedColumns) && (_image[loc(x + len, y)].character == 0u)) { | 1955 | if ((x + len < _usedColumns) && (_image[loc(x + len, y)].character == 0u)) { | ||
1934 | len++; // Adjust for trailing part of multi-column character | 1956 | len++; // Adjust for trailing part of multi-column character | ||
1935 | } | 1957 | } | ||
1936 | 1958 | | |||
1937 | const bool save__fixedFont = _fixedFont; | 1959 | const bool save__fixedFont = _fixedFont; | ||
1938 | if (lineDraw) { | 1960 | if (lineDraw) { | ||
1939 | _fixedFont = false; | 1961 | _fixedFont = false; | ||
▲ Show 20 Lines • Show All 2264 Lines • Show Last 20 Lines |