MCPcopy Create free account
hub / github.com/devkitPro/libctru / consolePrintChar

Function consolePrintChar

libctru/source/console.c:841–896  ·  view source on GitHub ↗

---------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

839
840//---------------------------------------------------------------------------------
841void 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//---------------------------------------------------------------------------------

Callers 3

consoleClsFunction · 0.85
consoleClearLineFunction · 0.85
con_writeFunction · 0.85

Calls 3

consoleDrawCharFunction · 0.85
newRowFunction · 0.85
gfxFlushBuffersFunction · 0.85

Tested by

no test coverage detected