-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
52 lines (42 loc) · 1.29 KB
/
Copy pathmain.c
File metadata and controls
52 lines (42 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "common.h"
int init() {
time_t t;
t = time(NULL);
printf("> Dian Shell\nCurrent Timestamp: %lld\nPress Ctrl+C to exit.\n", t);
initBuiltin();
#ifdef X_WIN
// set windows console mode
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
DWORD modeIn, modeOut;
GetConsoleMode(hOut, &modeOut);
SetConsoleMode(hOut, modeOut | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
GetConsoleMode(hIn, &modeIn);
// SetConsoleMode(hIn, modeIn | ENABLE_VIRTUAL_TERMINAL_INPUT);
CONSOLE_SCREEN_BUFFER_INFO ptInfo;
GetConsoleScreenBufferInfo(hOut, &ptInfo);
printf(
"Console Size: %d x %d (buffer %d x %d)\n",
ptInfo.dwMaximumWindowSize.X, ptInfo.dwMaximumWindowSize.Y,
ptInfo.dwSize.X, ptInfo.dwSize.Y
);
GetConsoleMode(hIn, &modeIn);
GetConsoleMode(hOut, &modeOut);
printf("Console Mode: in 0x%04x out 0x%04x\n", modeIn, modeOut);
#endif // X_WIN
printf("Init done...\n");
return 0;
}
int main(int argc, char * argv[]) {
char line[MAX_COMMAND_LENGTH];
memset(line, 0, sizeof(line));
if(init())
return 1;
putPS1();
while(EOF != scanf("%[^\n]", &line)) {
getchar(); // read '\n'
splitCmdInput(line);
putPS1();
}
return 0;
}