Changeset View
Changeset View
Standalone View
Standalone View
src/TerminalDisplay.cpp
Show First 20 Lines • Show All 777 Lines • ▼ Show 20 Line(s) | 770 | else if (0x71 <= code && code <= 0x73) { | |||
---|---|---|---|---|---|
778 | case 0x73: // BOX DRAWINGS LIGHT DIAGONAL CROSS | 778 | case 0x73: // BOX DRAWINGS LIGHT DIAGONAL CROSS | ||
779 | paint.drawLine(ex, y, x, ey); | 779 | paint.drawLine(ex, y, x, ey); | ||
780 | paint.drawLine(x, y, ex, ey); | 780 | paint.drawLine(x, y, ex, ey); | ||
781 | break; | 781 | break; | ||
782 | } | 782 | } | ||
783 | } | 783 | } | ||
784 | } | 784 | } | ||
785 | 785 | | |||
786 | static void drawBlockChar(QPainter& paint, int x, int y, int w, int h, uchar code) | ||||
787 | { | ||||
788 | const QColor color = paint.pen().color(); | ||||
789 | | ||||
790 | const float left = x - 0.5; | ||||
791 | const float top = y - 0.5; | ||||
792 | | ||||
793 | const float cx = left + w / 2; | ||||
794 | const float cy = top + h / 2; | ||||
795 | const float right = x + w - 0.5; | ||||
796 | const float bottom = y + h - 0.5; | ||||
797 | | ||||
798 | // Default rect fills entire cell | ||||
799 | QRectF rect(left, top, w, h); | ||||
800 | | ||||
801 | // LOWER ONE EIGHTH BLOCK to LEFT ONE EIGHTH BLOCK | ||||
802 | if (code >= 0x81 && code <= 0x8f) { | ||||
803 | if (code < 0x88) { // Horizontal | ||||
804 | const int height = h * (0x88 - code) / 8; | ||||
805 | rect.setY(top + height); | ||||
806 | rect.setHeight(h - height); | ||||
807 | } else if (code > 0x88) { // Vertical | ||||
808 | const int width = w * (0x90 - code) / 8; | ||||
809 | rect.setWidth(width); | ||||
810 | } | ||||
811 | | ||||
812 | paint.fillRect(rect, color); | ||||
813 | | ||||
814 | return; | ||||
815 | } | ||||
816 | | ||||
817 | // Combinations of quarter squares | ||||
818 | // LEFT ONE EIGHTH BLOCK to QUADRANT UPPER RIGHT AND LOWER LEFT AND LOWER RIGHT | ||||
819 | if (code >= 0x96 && code <= 0x9F) { | ||||
820 | bool upperLeft = false, upperRight = false, | ||||
821 | lowerLeft = false, lowerRight = false; | ||||
822 | | ||||
823 | switch(code) { | ||||
824 | case 0x96: | ||||
825 | lowerLeft = true; | ||||
826 | break; | ||||
827 | case 0x97: | ||||
828 | lowerRight = true; | ||||
829 | break; | ||||
830 | case 0x98: | ||||
831 | upperLeft = true; | ||||
832 | break; | ||||
833 | case 0x99: | ||||
834 | upperLeft = true; | ||||
835 | lowerLeft = true; | ||||
836 | lowerRight = true; | ||||
837 | break; | ||||
838 | case 0x9a: | ||||
839 | upperLeft = true; | ||||
840 | lowerRight = true; | ||||
841 | break; | ||||
842 | case 0x9b: | ||||
843 | upperLeft = true; | ||||
844 | upperRight = true; | ||||
845 | lowerLeft = true; | ||||
846 | break; | ||||
847 | case 0x9c: | ||||
848 | upperLeft = true; | ||||
849 | upperRight = true; | ||||
850 | lowerRight = true; | ||||
851 | break; | ||||
852 | case 0x9d: | ||||
853 | upperRight = true; | ||||
854 | break; | ||||
855 | case 0x9e: | ||||
856 | upperRight = true; | ||||
857 | lowerLeft = true; | ||||
858 | break; | ||||
859 | case 0x9f: | ||||
860 | upperRight = true; | ||||
861 | lowerLeft = true; | ||||
862 | lowerRight = true; | ||||
863 | break; | ||||
864 | default: | ||||
865 | break; | ||||
866 | } | ||||
867 | | ||||
868 | if (upperLeft) { | ||||
869 | paint.fillRect(QRectF(QPointF(left, top), QPointF(cx, cy)), color); | ||||
870 | } | ||||
871 | if (upperRight) { | ||||
872 | paint.fillRect(QRectF(QPointF(cx, top), QPointF(right, cy)), color); | ||||
873 | } | ||||
874 | if (lowerLeft) { | ||||
875 | paint.fillRect(QRectF(QPointF(left, cy), QPointF(cx, bottom)), color); | ||||
876 | } | ||||
877 | if (lowerRight) { | ||||
878 | paint.fillRect(QRectF(QPointF(cx, cy), QPointF(right, bottom)), color); | ||||
879 | } | ||||
880 | | ||||
881 | return; | ||||
882 | } | ||||
883 | | ||||
884 | // And the random stuff | ||||
885 | switch(code) { | ||||
886 | case 0x80: // Top half block | ||||
887 | rect.setHeight(h / 2); | ||||
888 | paint.fillRect(rect, color); | ||||
889 | return; | ||||
890 | case 0x90: // Right half block | ||||
891 | paint.fillRect(QRectF(QPointF(cx, top), QPointF(right, bottom)), color); | ||||
892 | return; | ||||
893 | case 0x94: // Top one eighth block | ||||
894 | rect.setHeight(h / 8); | ||||
895 | paint.fillRect(rect, color); | ||||
896 | return; | ||||
897 | case 0x95: { // Right one eighth block | ||||
898 | const float width = 7 * w / 8; | ||||
899 | rect.setX(left + width); | ||||
900 | rect.setWidth(w - width); | ||||
901 | paint.fillRect(rect, color); | ||||
902 | return; | ||||
903 | } | ||||
904 | case 0x91: // Light shade | ||||
905 | paint.fillRect(rect, QBrush(color, Qt::Dense6Pattern)); | ||||
906 | return; | ||||
907 | case 0x92: // Medium shade | ||||
908 | paint.fillRect(rect, QBrush(color, Qt::Dense4Pattern)); | ||||
909 | return; | ||||
910 | case 0x93: // Dark shade | ||||
911 | paint.fillRect(rect, QBrush(color, Qt::Dense2Pattern)); | ||||
912 | return; | ||||
913 | | ||||
914 | default: | ||||
915 | break; | ||||
916 | } | ||||
917 | } | ||||
918 | | ||||
786 | void TerminalDisplay::drawLineCharString(QPainter& painter, int x, int y, const QString& str, | 919 | void TerminalDisplay::drawLineCharString(QPainter& painter, int x, int y, const QString& str, | ||
787 | const Character* attributes) | 920 | const Character* attributes) | ||
788 | { | 921 | { | ||
789 | painter.save(); | 922 | painter.save(); | ||
790 | 923 | | |||
791 | // For antialiasing, we need to shift it so the single pixel width is in the middle | 924 | // For antialiasing, we need to shift it so the single pixel width is in the middle | ||
792 | painter.translate(0.5, 0.5); | 925 | painter.translate(0.5, 0.5); | ||
793 | 926 | | |||
794 | if (((attributes->rendition & RE_BOLD) != 0) && _boldIntense) { | 927 | if (((attributes->rendition & RE_BOLD) != 0) && _boldIntense) { | ||
795 | QPen boldPen(painter.pen()); | 928 | QPen boldPen(painter.pen()); | ||
796 | boldPen.setWidth(4); | 929 | boldPen.setWidth(4); | ||
797 | painter.setPen(boldPen); | 930 | painter.setPen(boldPen); | ||
798 | } | 931 | } | ||
799 | 932 | | |||
800 | 933 | | |||
801 | for (int i = 0 ; i < str.length(); i++) { | 934 | for (int i = 0 ; i < str.length(); i++) { | ||
802 | const uchar code = str[i].cell(); | 935 | const uchar code = str[i].cell(); | ||
803 | if (LineChars[code] != 0u) { | 936 | | ||
937 | if (code >= 0x80 && code <= 0x9F) { // UPPER HALF BLOCK to QUADRANT UPPER RIGHT AND LOWER LEFT AND LOWER RIGHT | ||||
hindenburg: does it make sense here to add an upper bound to make this clearer? | |||||
938 | drawBlockChar(painter, x + (_fontWidth * i), y, _fontWidth, _fontHeight, code); | ||||
939 | } else if (LineChars[code] != 0u) { | ||||
804 | drawLineChar(painter, x + (_fontWidth * i), y, _fontWidth, _fontHeight, code); | 940 | drawLineChar(painter, x + (_fontWidth * i), y, _fontWidth, _fontHeight, code); | ||
805 | } else { | 941 | } else { | ||
806 | drawOtherChar(painter, x + (_fontWidth * i), y, _fontWidth, _fontHeight, code); | 942 | drawOtherChar(painter, x + (_fontWidth * i), y, _fontWidth, _fontHeight, code); | ||
807 | } | 943 | } | ||
808 | } | 944 | } | ||
809 | 945 | | |||
810 | painter.restore(); | 946 | painter.restore(); | ||
811 | } | 947 | } | ||
▲ Show 20 Lines • Show All 3175 Lines • Show Last 20 Lines |
does it make sense here to add an upper bound to make this clearer?