-
Notifications
You must be signed in to change notification settings - Fork 0
/
SMenuConsole.c
122 lines (111 loc) · 3.19 KB
/
SMenuConsole.c
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <assert.h>
#include <windows.h>
#include <stdio.h>
#include <strsafe.h>
#include "fzf\\fzf.h"
#include "SMenu.h"
#include <assert.h>
#include <synchapi.h>
#include <commctrl.h>
#include <conio.h>
MenuView *mView;
void onEscape(void)
{
PostQuitMessage(0);
}
void onSelection(char *stdOut)
{
printf("%s", stdOut);
ShowWindow(mView->hwnd, SW_HIDE);
_getch();
MenuDefinition *menuDefinition2 = calloc(1, sizeof(MenuDefinition));
menuDefinition2->onEscape = onEscape;
menuDefinition2->onSelection = onSelection;
MenuDefinition_AddNamedCommand(menuDefinition2, "ld:fd . c:\\", FALSE, TRUE);
MenuDefinition_ParseAndAddLoadCommand(menuDefinition2, "ld");
menu_run_definition(mView, menuDefinition2);
}
int main(int argc, char* argv[])
{
SetProcessDPIAware();
int top = 250;
int left = 250;
int height = 940;
int width = 2050;
TCHAR title[BUF_LEN] = L"Blah";
mView = menu_create_with_size(top, left, width, height, title);
MenuDefinition *menuDefinition = menu_definition_create(mView);
menuDefinition->onSelection = onSelection;
menuDefinition->onEscape = onEscape;
for(int i = 0; i < argc; i++)
{
if(strcmp(argv[i], "--loadCommand") == 0)
{
if(i + 1 < argc)
{
i++;
MenuDefinition_ParseAndAddLoadCommand(menuDefinition, argv[i]);
}
}
if(strcmp(argv[i], "--bind") == 0)
{
if(i + 1 < argc)
{
i++;
MenuDefinition_ParseAndAddKeyBinding(menuDefinition, argv[i], FALSE);
}
}
if(strcmp(argv[i], "--bindNoReload") == 0)
{
if(i + 1 < argc)
{
i++;
MenuDefinition_ParseAndAddKeyBinding(menuDefinition, argv[i], FALSE);
}
}
if(strcmp(argv[i], "--bindLoadCommand") == 0)
{
if(i + 1 < argc)
{
i++;
MenuDefinition_ParseAndAddKeyBinding(menuDefinition, argv[i], TRUE);
}
}
if(strcmp(argv[i], "--bindExecuteAndQuit") == 0)
{
if(i + 1 < argc)
{
i++;
MenuDefinition_ParseAndAddKeyBinding(menuDefinition, argv[i], FALSE);
}
}
if(strcmp(argv[i], "--namedCommand") == 0)
{
if(i + 1 < argc)
{
i++;
MenuDefinition_AddNamedCommand(menuDefinition, argv[i], FALSE, TRUE);
}
}
if(strcmp(argv[i], "--returnRange") == 0)
{
if(i + 1 < argc)
{
i++;
MenuDefinition_ParseAndSetRange(menuDefinition, argv[i]);
}
}
if(strcmp(argv[i], "--hasHeader") == 0)
{
mView->itemsView->hasHeader = TRUE;
}
}
menu_run_definition(mView, menuDefinition);
MSG Msg;
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return 0;
}