---------------------------------------------------------------------------------
| 839 | |
| 840 | //--------------------------------------------------------------------------------- |
| 841 | void consolePrintChar(int c) { |
| 842 | //--------------------------------------------------------------------------------- |
| 843 | int tabspaces; |
| 844 | |
| 845 | if (c==0) return; |
| 846 | |
| 847 | if(currentConsole->PrintChar) |
| 848 | if(currentConsole->PrintChar(currentConsole, c)) |
| 849 | return; |
| 850 | |
| 851 | switch(c) { |
| 852 | /* |
| 853 | The only special characters we will handle are tab (\t), carriage return (\r), line feed (\n) |
| 854 | and backspace (\b). |
| 855 | Carriage return & line feed will function the same: go to next line and put cursor at the beginning. |
| 856 | For everything else, use VT sequences. |
| 857 | |
| 858 | Reason: VT sequences are more specific to the task of cursor placement. |
| 859 | The special escape sequences \b \f & \v are archaic and non-portable. |
| 860 | */ |
| 861 | case 8: |
| 862 | currentConsole->cursorX--; |
| 863 | |
| 864 | if(currentConsole->cursorX < 1) { |
| 865 | if(currentConsole->cursorY > 1) { |
| 866 | currentConsole->cursorX = currentConsole->windowWidth; |
| 867 | currentConsole->cursorY--; |
| 868 | } else { |
| 869 | currentConsole->cursorX = 1; |
| 870 | } |
| 871 | } |
| 872 | |
| 873 | consoleDrawChar(' '); |
| 874 | break; |
| 875 | |
| 876 | case 9: |
| 877 | tabspaces = currentConsole->tabSize - ((currentConsole->cursorX - 1) % currentConsole->tabSize); |
| 878 | for(int i=0; i<tabspaces; i++) consolePrintChar(' '); |
| 879 | break; |
| 880 | case 10: |
| 881 | newRow(); |
| 882 | case 13: |
| 883 | currentConsole->cursorX = 1; |
| 884 | gfxFlushBuffers(); |
| 885 | break; |
| 886 | default: |
| 887 | if(currentConsole->cursorX > currentConsole->windowWidth) { |
| 888 | currentConsole->cursorX = 1; |
| 889 | |
| 890 | newRow(); |
| 891 | } |
| 892 | consoleDrawChar(c); |
| 893 | ++currentConsole->cursorX ; |
| 894 | break; |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | //--------------------------------------------------------------------------------- |
no test coverage detected