-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdmenu.cpp
More file actions
65 lines (59 loc) · 1.64 KB
/
dmenu.cpp
File metadata and controls
65 lines (59 loc) · 1.64 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
#include "dmenu.hpp"
#include "filetagslng.hpp"
#include "guid.hpp"
#include "mix.hpp"
bool DescrMenu::show() {
intptr_t breakCode;
intptr_t cursor = 0;
std::wstring cursorTag;
do {
FarMenuItem *items = new FarMenuItem[m_tags.size()];
memset(items, 0, sizeof(FarMenuItem) * m_tags.size());
size_t i = 0;
for (Tags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) {
const std::wstring &tag = *it;
if (m_tagsToSet.find(tag) != m_tagsToSet.end())
items[i].Flags = '+';
if (m_tagsToClear.find(tag) != m_tagsToClear.end())
items[i].Flags = '-';
if (i == cursor)
items[i].Flags |= MIF_SELECTED;
items[i].Text = tag.c_str();
i++;
}
struct FarKey breakKeys[4] = {{VK_ADD, 0}, {VK_SUBTRACT, 0}, {VK_SPACE, 0}, {0, 0}};
cursor = ::Info.Menu(&MainGuid, &DescrMenuGuid, -1, -1, 0, FMENU_WRAPMODE,
GetMsg(MDescrMenuCaption), GetMsg(MDescrMenuHint), L"DescriptionMenu",
breakKeys, &breakCode,
items, m_tags.size());
if (cursor >= 0) {
cursorTag = std::wstring(items[cursor].Text);
switch (breakCode) {
case 0: //gray +
m_tagsToSet.insert(cursorTag);
m_tagsToClear.erase(cursorTag);
break;
case 1: //gray -
m_tagsToSet.erase(cursorTag);
m_tagsToClear.insert(cursorTag);
break;
case 2: //Space
m_tagsToSet.erase(cursorTag);
m_tagsToClear.erase(cursorTag);
break;
case -1: //Enter
if ((items[cursor].Flags & 0xFFFF) != '-') {
m_tagsToSet.insert(cursorTag);
m_tagsToClear.erase(cursorTag);
}
delete[] items;
return true;
default:
break;
}
}
delete[] items;
} while (cursor >= 0);
//Escape
return false;
}