fixed tab handling + made things look nicer
parent
849b4139df
commit
5ed3ab8aa6
17
c_print.c
17
c_print.c
|
@ -1,11 +1,26 @@
|
|||
void
|
||||
print_with_fixed_tabs(Row *row) {
|
||||
for (int i = 0; i < ROW_SIZE; i++) {
|
||||
if(row->text[i] == 0) break;
|
||||
if (row->text[i] == '\t') printf(" ");
|
||||
else printf("%c", row->text[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
c_print(char *c) {
|
||||
Row *row = buffer;
|
||||
int line = 1;
|
||||
for (;; line++) {
|
||||
printf("%4.4i| %s\n", line, row->text);
|
||||
printf("%3.i| ", line);
|
||||
print_with_fixed_tabs(row);
|
||||
puts("");
|
||||
if (row->n == NULL) break;
|
||||
row = row -> n;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
5
main.c
5
main.c
|
@ -1,8 +1,9 @@
|
|||
int
|
||||
main(int argc, char **argv) {
|
||||
static char buf[256];
|
||||
static char buf[COM_BUF_SIZE];
|
||||
while(1) {
|
||||
memset(buf, 0, sizeof(buf));
|
||||
printf(" > ");
|
||||
char *com = fgets(buf, sizeof(buf), stdin);
|
||||
for (int i = 0; i < sizeof(buf); i++)
|
||||
if (buf[i] == '\n')
|
||||
|
@ -15,3 +16,5 @@ char *com = fgets(buf, sizeof(buf), stdin);
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue