Skip to content

Commit fd8951b

Browse files
committed
print tabs with space chars
1 parent cf7dae0 commit fd8951b

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

libogc/console.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include <stdlib.h>
32
#include <string.h>
43
#include <reent.h>
@@ -769,6 +768,8 @@ void newRow()
769768

770769
void consolePrintChar(int c)
771770
{
771+
int tabspaces;
772+
772773
if (c==0) return;
773774

774775
switch(c) {
@@ -786,7 +787,7 @@ void consolePrintChar(int c)
786787

787788
if(currentConsole->cursorX < 1) {
788789
if(currentConsole->cursorY > 1) {
789-
currentConsole->cursorX = currentConsole->windowWidth - 1;
790+
currentConsole->cursorX = currentConsole->windowWidth;
790791
currentConsole->cursorY--;
791792
} else {
792793
currentConsole->cursorX = 1;
@@ -797,7 +798,10 @@ void consolePrintChar(int c)
797798
break;
798799

799800
case 9:
800-
currentConsole->cursorX += currentConsole->tabSize - ((currentConsole->cursorX)%(currentConsole->tabSize));
801+
tabspaces = currentConsole->tabSize - ((currentConsole->cursorX - 1) % currentConsole->tabSize);
802+
if (currentConsole->cursorX + tabspaces > currentConsole->windowWidth)
803+
tabspaces = currentConsole->windowWidth - currentConsole->cursorX;
804+
for(int i=0; i<tabspaces; i++) consolePrintChar(' ');
801805
break;
802806
case 10:
803807
newRow();

0 commit comments

Comments
 (0)