File indexing completed on 2024-05-05 05:53:44

0001 /*
0002     SPDX-FileCopyrightText: 2019 Mariusz Glebocki <mglb@arccos-1.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef LINEBLOCKCHARACTERS_H
0008 #define LINEBLOCKCHARACTERS_H
0009 
0010 // Qt
0011 #include <QPainter>
0012 
0013 namespace Konsole
0014 {
0015 /**
0016  * Helper functions for drawing characters from "Box Drawing" and "Block Elements" Unicode blocks.
0017  */
0018 namespace LineBlockCharacters
0019 {
0020 /**
0021  * Returns true if the character can be drawn by draw() function.
0022  *
0023  * @param ucs4cp Character to test's UCS4 code point
0024  */
0025 inline static bool canDraw(uint ucs4cp)
0026 {
0027     return (0x2500 <= ucs4cp && ucs4cp <= 0x259F);
0028 }
0029 
0030 /**
0031  * Returns true if the character is a Legacy Computing Symbol and can be drawn by draw() function.
0032  *
0033  * @param ucs4cp Character to test's UCS4 code point
0034  */
0035 inline static bool isLegacyComputingSymbol(uint ucs4cp)
0036 {
0037     return (0x1fb00 <= ucs4cp && ucs4cp <= 0x1fb8b);
0038 }
0039 
0040 /**
0041  * Draws character.
0042  *
0043  * @param paint QPainter to draw on
0044  * @param cellRect Rectangle to draw in
0045  * @param chr Character to be drawn
0046  * @param bold Whether the character should be boldface
0047  */
0048 void draw(QPainter &paint, const QRect &cellRect, const uint &chr, bool bold);
0049 
0050 } // namespace LineBlockCharacters
0051 } // namespace Konsole
0052 
0053 #endif // LINEBLOCKCHARACTERS_H