After I made those diagrams, I added the ability to use themes. Because the code for this used $rows, I moved it up after where this variable was defined. But the value of $rows was calculated from the value of $cols, which was provided while reading the settings file, and I had moved the settings code along with the theme code. So, it was calculating $rows with the wrong value for $cols. To fix this, I moved the code for reading the settings file to an earlier part of the script.
After I made those diagrams, I added the ability to use themes. Because the code for this used $rows, I moved it up after where this variable was defined. But the value of $rows was calculated from the value of $cols, which was provided while reading the settings file, and I had moved the settings code along with the theme code. So, it was calculating $rows with the wrong value for $cols. To fix this, I moved the code for reading the settings file to an earlier part of the script.