This PR is an attempt at cleaning up the RTL code and documentation a bit so it's easier to understand (that's subjective, I know).
Renamed containsRTL to lineContainsRTL_ and checked for lineContainsRTL_ || isRTL() in breakLine.
This way, a few RTL words in a wrapped LTR message won't affect the lines below.
Renamed first and FirstWord to textDirection_ and Direction respectively.
That's what they are about. first also "leaks" how it's detected (finding the first word that has a direction).
Added isRTL, isLTR, and isNeutral to check the text direction.
Moved from int to size_t and qsizetype (for signed values).
Added some assertions in addElement to check for weird usages of elements.
Moved from std containers (vector/stack) to QVarLengthArray.
Single lines usually have very few elements, so we can store them on the stack (if that's not enough, the container will allocate).
Moved wasPrevReversed_ from a member to a local variable (isReversing)
Updated documentation for addElement and reorderRTL (and the other stuff I added)
Added basic tests for reordering.
The tests only test the reordering on a single line. The line must have a username element. They're still a bit WIP, as e.g. images and mentions aren't tested.
This PR is an attempt at cleaning up the RTL code and documentation a bit so it's easier to understand (that's subjective, I know).
containsRTL
tolineContainsRTL_
and checked forlineContainsRTL_ || isRTL()
inbreakLine
. This way, a few RTL words in a wrapped LTR message won't affect the lines below.first
andFirstWord
totextDirection_
andDirection
respectively. That's what they are about.first
also "leaks" how it's detected (finding the first word that has a direction).isRTL
,isLTR
, andisNeutral
to check the text direction.int
tosize_t
andqsizetype
(for signed values).addElement
to check for weird usages of elements.QVarLengthArray
. Single lines usually have very few elements, so we can store them on the stack (if that's not enough, the container will allocate).wasPrevReversed_
from a member to a local variable (isReversing
)addElement
andreorderRTL
(and the other stuff I added)They're still a bit WIP, as e.g. images and mentions aren't tested.