- Optimized extractCursorPosition to scan lines in reverse order for improved performance.
get_commands