X-Git-Url: https://gitweb.ps.run/iftint/blobdiff_plain/4b2f1911caaea89383e2d7b91f442a79793ee0d8..343de1d73b29b83db7ea5ecf9b6d18fe50733f22:/main3.c?ds=sidebyside diff --git a/main3.c b/main3.c index 1911016..7929e67 100644 --- a/main3.c +++ b/main3.c @@ -85,7 +85,7 @@ void vt100Escape(const char * str, ...) { void vt100ClearScreen() { vt100Escape("[2J"); } void vt100CursorHome() { vt100Escape("[H"); } -void vt100CursorPos(int v, int h) { vt100Escape("[%d;%dH", v, h); } +void vt100CursorPos(int v, int h) { vt100Escape("[%d;%df", v, h); } void vt100SaveCursor() { vt100Escape("7"); } void vt100RestoreCursor() { vt100Escape("8"); } void vt100EnableAlternateBuffer() { vt100Escape("[?1049h"); } @@ -235,8 +235,8 @@ void NodeDraw(Node *n) { #define PRINTF(...) do { if (n == g_NodeDrawSelected) vt100EnableNegative(); printf(__VA_ARGS__); vt100DisableNegative(); } while(0); switch (n->kind) { - case NK_Namespace: { PRINTF("namespace"); printf(" %s {", n->data); indent++; for (int i = 0; i < n->childCount; i++) { INDENT NodeDraw(NodeGetChild(n, i)); } indent--; INDENT printf("}\n"); break; } - case NK_Struct: { PRINTF("struct"); printf(" %s {", n->data); indent++; for (int i = 0; i < n->childCount; i++) { INDENT NodeDraw(NodeGetChild(n, i)); } indent--; INDENT printf("}\n"); break; } + case NK_Namespace: { PRINTF("namespace"); printf(" %s {", n->data); indent++; for (int i = 0; i < n->childCount; i++) { INDENT NodeDraw(NodeGetChild(n, i)); } indent--; INDENT printf("}"); break; } + case NK_Struct: { PRINTF("struct"); printf(" %s {", n->data); indent++; for (int i = 0; i < n->childCount; i++) { INDENT NodeDraw(NodeGetChild(n, i)); } indent--; INDENT printf("}"); break; } case NK_Func: { PRINTF("fn"); printf(" %s ", n->data); NodeDraw(NodeGetChild(n, 0)); NodeDraw(NodeGetChild(n, 1)); break; } case NK_VarList: case NK_ExprList: { PRINTF("("); for (int i = 0; i < n->childCount; i++) { if (i != 0) printf(", "); NodeDraw(NodeGetChild(n, i)); } PRINTF(")"); break; } @@ -244,7 +244,7 @@ void NodeDraw(Node *n) { case NK_VarDecl: { PRINTF("[%s : ", n->data); NodeDraw(NodeGetChild(n, 0)); printf("]"); break; } case NK_VarType: case NK_Type: { PRINTF("%s", n->data); for (int i = 0; i < n->childCount; i++) { printf("%s", i == 0 ? "<" : ", "); NodeDraw(NodeGetChild(n, i)); if (i == n->childCount-1) printf(">"); } break; } - case NK_Body: { PRINTF("{"); indent++; for (int i = 0; i < n->childCount; i++) { INDENT NodeDraw(NodeGetChild(n, i)); } indent--; INDENT PRINTF("}\n"); break; } + case NK_Body: { PRINTF("{"); indent++; for (int i = 0; i < n->childCount; i++) { INDENT NodeDraw(NodeGetChild(n, i)); } indent--; INDENT PRINTF("}"); break; } case NK_If: { PRINTF("if"); printf(" "); NodeDraw(NodeGetChild(n, 0)); INDENT NodeDraw(NodeGetChild(n, 1)); break; } case NK_While: { PRINTF("while"); printf(" "); NodeDraw(NodeGetChild(n, 0)); INDENT NodeDraw(NodeGetChild(n, 1)); break; } case NK_Num: { PRINTF("%s", n->data); break; } @@ -404,13 +404,13 @@ void DrawInfo(InputAction actions[NK_COUNT][IN_COUNT], NodeKind nk, InputMode mo int line = 2; - vt100CursorPos(line++, h-30); + vt100CursorPos(line++, h-10); printf("%s:%s", NK_STRINGS[nk], (mode == IM_Normal ? "" : " (editing)")); for (int i = IN_L+1; i < IN_COUNT; i++) { InputAction action = actions[nk][i]; if (action != IA_None) { - vt100CursorPos(line++, h-30); + vt100CursorPos(line++, h-10); printf("%s %s", IN_STRINGS[i], IA_STRINGS[action]); } } @@ -585,6 +585,7 @@ int main() { vt100ShowCursor(); NodeDraw(n); + printf("\n"); return 0; }