Skip to content

Commit 88f4f44

Browse files
committed
cls命令
1 parent 9bee564 commit 88f4f44

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

18_day/bootpack.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "bootpack.h"
44
#include <stdio.h>
5+
#include <string.h>
56

67
void make_window8(unsigned char *buf, int xsize, int ysize, char *title, char act);
78
void putfonts8_asc_sht(struct SHEET *sht, int x, int y, int c, int b, char *s, int l);
@@ -378,6 +379,7 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
378379
int i, fifobuf[128], cursor_x = 16, cursor_y = 28, cursor_c = -1;
379380
char s[30], cmdline[30];
380381
struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
382+
int x, y;
381383

382384
fifo32_init(&task->fifo, 128, fifobuf, task);
383385
timer = timer_alloc();
@@ -431,7 +433,7 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
431433
cmdline[cursor_x / 8 - 2] = 0;
432434
cursor_y = cons_newline(cursor_y, sheet);
433435
/*执行命令*/
434-
if (cmdline[0] == 'm' && cmdline[1] == 'e' && cmdline[2] == 'm' && cmdline[3] == 0) {
436+
if (strcmp(cmdline, "mem") == 0) {
435437
/* mem命令*/
436438
sprintf(s, "total %dMB", memtotal / (1024 * 1024));
437439
putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, s, 30);
@@ -440,7 +442,16 @@ void console_task(struct SHEET *sheet, unsigned int memtotal)
440442
putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, s, 30);
441443
cursor_y = cons_newline(cursor_y, sheet);
442444
cursor_y = cons_newline(cursor_y, sheet);
443-
} else if (cmdline[0] != 0) {
445+
} else if (strcmp(cmdline, "cls") == 0) {
446+
/* cls命令*/
447+
for (y = 28; y < 28 + 128; y++) {
448+
for (x = 8; x < 8 + 240; x++) {
449+
sheet->buf[x + y * sheet->bxsize] = COL8_000000;
450+
}
451+
}
452+
sheet_refresh(sheet, 8, 28, 8 + 240, 28 + 128);
453+
cursor_y = 28;
454+
} else if (cmdline[0] != 0) {
444455
/*不是命令,也不是空行 */
445456
putfonts8_asc_sht(sheet, 8, cursor_y, COL8_FFFFFF, COL8_000000, "Bad command.", 12);
446457
cursor_y = cons_newline(cursor_y, sheet);

0 commit comments

Comments
 (0)