-
Bacspacing tab
If the user presses TAB the cursor will go forward (8-(CURRENT_COLUMN_IN_THE_SCREEN%8)) spaces. Now, when I press TAB and then backspace what would be the ideal thing to count how many columns should the cursor go back (the string that the user is typing is in memory)?
-
you should count the number of '\t' (note not "\t") there is before the test cursor, and the beginning of the line. How to count these? Find the beginning of the line, check next char, if its a '\t', check the next, and so on. If there is another charachter than '\t' you could say that the action (backspace+tab) isn't valid. well how you define the rules for that is up to you.
-
But this might not be the answer you seek, if you don't use '\t'. (which I just realised you might not!)