You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Const small booleans that can be
* Preparatory refactoring
* Normal/narrow characters are far more popular right now, check them first
* Added correct calculation of X for the variable-width characters
* Clean up debug echoes
* Variable renaming improvements
* Make selection select the next character when it is selected over half
* Remove debug statement
* Remove duplication & fix other hardcoded width=1 cases
* Don't select from the middle of a character - doesn't work in right to left selection
// mk_wcwidth returns -1 (on error), 0 on a control or combining
506
-
// diacritical codepoint or 1 for a normal character or 2 on a wide
507
-
// character.
508
-
// mk_wcwidth_cjk does the same except it returns 2 instead of 1 for
509
-
// characters that have an "ambiguous" East Asian width:
510
-
// replaced by wide_wcwidth which returns 1 or 2 or a number of
511
-
// (negative) special values:
512
-
// mWideAmbigousWidthGlyphs
513
-
switch (widechar_wcwidth(unicode)) {
514
-
case2: // Draw as wide
515
-
charWidth = 2;
516
-
break;
517
-
case1: // Draw as normal/narrow
518
-
charWidth = 1;
519
-
break;
520
-
case widechar_nonprint: // -1 = The character is not printable.
521
-
qDebug().nospace().noquote() << "TTextEdit::drawGrapheme(...) WARN - trying to draw a Unicode character which is unprintable, codepoint number: U+" << QString::number(unicode, 16) << ".";
522
-
charWidth = 1;
523
-
break;
524
-
case widechar_combining: // -2 = The character is a zero-width combiner.
525
-
qWarning().nospace().noquote() << "TTextEdit::drawGrapheme(...) WARN - trying to draw a Unicode character which is a zero width combiner, codepoint number: U+" << QString::number(unicode, 16) << ".";
526
-
charWidth = 1; // Previous code treated this as a normal width character
527
-
break;
528
-
case widechar_ambiguous: // -3 = The character is East-Asian ambiguous width.
529
-
charWidth = mWideAmbigousWidthGlyphs ? 2 : 1;
530
-
break;
531
-
case widechar_private_use: // -4 = The character is for private use - we cannot know for certain what width to used
532
-
charWidth = 1;
533
-
qDebug().nospace().noquote() << "TTextEdit::drawGrapheme(...) WARN - trying to draw a Private User Character, we cannot know how wide it is, codepoint number: U+" << QString::number(unicode, 16) << ".";
534
-
break;
535
-
case widechar_unassigned: // -5 = The character is unassigned.
536
-
qWarning().nospace().noquote() << "TTextEdit::drawGrapheme(...) WARN - trying to draw a Unicode character which was not previously assigned and we do not know how wide it is, codepoint number: U+" << QString::number(unicode, 16) << ".";
537
-
charWidth = 1; // Previous code treated this as a normal width character
538
-
break;
539
-
case widechar_widened_in_9: // -6 = Width is 1 in Unicode 8, 2 in Unicode 9+.
540
-
if (mUseOldUnicode8) {
541
-
charWidth = 1;
542
-
} else {
543
-
charWidth = 2;
544
-
}
545
-
break;
546
-
default:
547
-
Q_UNREACHABLE(); // Got an uncoded return value from widechar_wcwidth(...)
// mk_wcwidth returns -1 (on error), 0 on a control or combining
555
+
// diacritical codepoint or 1 for a normal character or 2 on a wide
556
+
// character.
557
+
// mk_wcwidth_cjk does the same except it returns 2 instead of 1 for
558
+
// characters that have an "ambiguous" East Asian width:
559
+
// replaced by wide_wcwidth which returns 1 or 2 or a number of
560
+
// (negative) special values:
561
+
// mWideAmbigousWidthGlyphs
562
+
switch (widechar_wcwidth(unicode)) {
563
+
case1: // Draw as normal/narrow
564
+
return1;
565
+
case2: // Draw as wide
566
+
return2;
567
+
case widechar_nonprint: // -1 = The character is not printable.
568
+
qDebug().nospace().noquote() << "TTextEdit::drawGrapheme(...) WARN - trying to draw a Unicode character which is unprintable, codepoint number: U+" << QString::number(unicode, 16) << ".";
569
+
return1;
570
+
case widechar_combining: // -2 = The character is a zero-width combiner.
571
+
qWarning().nospace().noquote() << "TTextEdit::drawGrapheme(...) WARN - trying to draw a Unicode character which is a zero width combiner, codepoint number: U+" << QString::number(unicode, 16) << ".";
572
+
return1; // Previous code treated this as a normal width character
573
+
case widechar_ambiguous: // -3 = The character is East-Asian ambiguous width.
574
+
returnmWideAmbigousWidthGlyphs ? 2 : 1;
575
+
case widechar_private_use: // -4 = The character is for private use - we cannot know for certain what width to used
576
+
qDebug().nospace().noquote() << "TTextEdit::drawGrapheme(...) WARN - trying to draw a Private User Character, we cannot know how wide it is, codepoint number: U+" << QString::number(unicode, 16) << ".";
577
+
return1;
578
+
case widechar_unassigned: // -5 = The character is unassigned.
579
+
qWarning().nospace().noquote() << "TTextEdit::drawGrapheme(...) WARN - trying to draw a Unicode character which was not previously assigned and we do not know how wide it is, codepoint number: U+" << QString::number(unicode, 16) << ".";
580
+
return1;
581
+
case widechar_widened_in_9: // -6 = Width is 1 in Unicode 8, 2 in Unicode 9+.
582
+
if (mUseOldUnicode8) {
583
+
return1;
584
+
} else {
585
+
return2;
586
+
}
587
+
default:
588
+
return1; // Got an uncoded return value from widechar_wcwidth(...)
0 commit comments