-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_window.c
More file actions
69 lines (65 loc) · 1.17 KB
/
example_window.c
File metadata and controls
69 lines (65 loc) · 1.17 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdio.h>
#include <windows.h>
#include "conio.h"
#include "./src/vim.h"
void xcmd_print(const char *fmt, ...);
int xcmd_gets(char *buf, int len);
void printHEX(char *buf, int len);
int main(int argc, char *argv[]) {
vim_main(argc, argv);
return 0;
}
#include "stdarg.h"
#include "string.h"
void vim_print(const char *fmt, ...) {
char ucstring[255] = {0};
va_list arg;
va_start(arg, fmt);
vsnprintf(ucstring, 255, fmt, arg);
va_end(arg);
for (int i = 0; i < strlen(ucstring); i++) {
putchar(ucstring[i]);
}
}
int vim_gets(char *buf, int len) {
int ret = 0, iret = 0;
while (1) {
while (_kbhit()) {
buf[ret++] = _getch();
}
if (ret) {
break;
}
}
if (ret > 1 && *buf == -32) {
switch (buf[1]) {
case 72:
memcpy(buf, KEY_UP, 4);
ret=3;
break;
case 80:
memcpy(buf, KEY_DW, 4);
ret=3;
break;
case 77:
memcpy(buf, KEY_RIGHT, 4);
ret=3;
break;
case 75:
memcpy(buf, KEY_LEFT, 4);
ret=3;
break;
}
}
return ret;
}
void printHEX(char *buf, int len) {
for (int i = 0; i < len; i++) {
printf("%d ", buf[i]);
}
printf("\n");
for (int i = 0; i < len; i++) {
printf("%c", buf[i]);
}
printf("\n");
}