breakUpBySubstrings method

void breakUpBySubstrings()

Implementation

void breakUpBySubstrings() {
  var newSubMobjects = <SingleStringMathTex>[];
  var currentIndex = 0;

  for (var texString in texStrings) {
    var subTexMob = SingleStringMathTex(texString, environment: environment);
    var numSubmobs = subTexMob.submobjects.length;
    var newIndex =
        currentIndex + numSubmobs + argSeparator.split(' ').join('').length;

    if (numSubmobs == 0) {
      subTexMob.submobjects = [VectorizedPoint()];
      var lastSubMobIndex = min(currentIndex, submobjects.length - 1);
      subTexMob.moveToMobject(submobjects[lastSubMobIndex],
          alignedEdge: RIGHT);
    } else {
      subTexMob.submobjects =
          submobjects.getRange(currentIndex, newIndex).toList();
    }

    newSubMobjects.add(subTexMob);
    currentIndex = newIndex;
  }

  submobjects = newSubMobjects;
}