How to make it easier to calculate the cursor position in the console if there are tabs in the text?
I must say right away that getting a position using standard means (csrlin, pos) is sooooo slow (it's just not applicable in this case). Therefore, I understand that only the manual version is needed. Assume that the tab character is always 4.
That is: there is, say, a text (more precisely, a buffer):
aa9a9aaa9a
Get the text on the screen:
Code: Select all
aa a aaa a
Only the full calculation of the line from the beginning comes to mind (earch for all tab characters, calculating each until we reach the desired position). But it's kind of long if the string is long. When moving through the lines it will be quite "hard". And so the console draws slowly, and then there is such a load with a full line calculation every time for any operation.