-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
139 lines (115 loc) · 3.64 KB
/
main.cpp
File metadata and controls
139 lines (115 loc) · 3.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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <string>
#include <windows.h>
#include "mix.hpp"
#include "filetagslng.hpp"
#include "panel.hpp"
/// FAR Manager is opening the plugin's panel
HANDLE WINAPI OpenW(const OpenInfo *OInfo)
{
if (OInfo->StructSize < sizeof(OpenInfo))
return nullptr;
//open from a file panel only
PanelInfo pi = {sizeof(PanelInfo)};
::Info.PanelControl(PANEL_ACTIVE, FCTL_GETPANELINFO, 0, &pi);
if (pi.PluginHandle != 0)
return nullptr;
switch (OInfo->OpenFrom) {
case OPEN_PLUGINSMENU:
{
Panel *panel = new Panel();
if (!panel->openFromMainMenu()) {
delete panel;
return INVALID_HANDLE_VALUE;
}
return static_cast<HANDLE>(panel);
}
case OPEN_COMMANDLINE:
{
Panel *panel = new Panel();
std::wstring cmd = reinterpret_cast<OpenCommandLineInfo*>(OInfo->Data)->CommandLine;
if (!panel->openFromCommandLine(cmd)) {
delete panel;
return INVALID_HANDLE_VALUE;
}
return static_cast<HANDLE>(panel);
}
}
return nullptr;
}
/// FAR Manager is closing the plugin's panel
void WINAPI ClosePanelW(const ClosePanelInfo *Info)
{
if(Info->StructSize < sizeof(ClosePanelInfo))
return;
Panel *panel = reinterpret_cast<Panel *>(Info->hPanel);
delete panel;
}
/// FAR Manager is requesting the list of plugin panel items
intptr_t WINAPI GetFindDataW(GetFindDataInfo *Info)
{
if(Info->StructSize < sizeof(GetFindDataInfo))
return FALSE;
if (Info->OpMode & OPM_FIND) // skipping the plugin call from file search
return FALSE;
if(!Info->hPanel || INVALID_HANDLE_VALUE == Info->hPanel)
return FALSE;
Panel *panel = reinterpret_cast<Panel *>(Info->hPanel);
panel->capture(&Info->ItemsNumber, &Info->PanelItem);
return TRUE;
}
/// FAR Manager no longer needs plugin panel items, free them
void WINAPI FreeFindDataW(const FreeFindDataInfo *Info)
{
if(Info->StructSize < sizeof(FreeFindDataInfo))
return;
Panel *panel = reinterpret_cast<Panel *>(Info->hPanel);
panel->release();
}
/// FAR Manager is requesting info on the panel being opened
void WINAPI GetOpenPanelInfoW(OpenPanelInfo *Info)
{
if(Info->StructSize < sizeof(OpenPanelInfo))
return;
Panel *panel = reinterpret_cast<Panel *>(Info->hPanel);
Info->Flags = OPIF_ADDDOTS|OPIF_REALNAMES|OPIF_SHOWNAMESONLY|OPIF_USEATTRHIGHLIGHTING;
Info->CurDir = panel->buildPrompt();
Info->PanelTitle=panel->buildCaption();
if (Opt.StorePanelMode)
Info->StartPanelMode = Opt.PanelMode + '0';
}
/// FAR Manager is requesting the current folder change.
intptr_t WINAPI SetDirectoryW(const SetDirectoryInfo *Info)
{
if(Info->StructSize < sizeof(SetDirectoryInfo))
return FALSE;
if (Info->OpMode & OPM_FIND) // skipping the plugin call from file search
return FALSE;
if(!Info->hPanel || INVALID_HANDLE_VALUE == Info->hPanel)
return FALSE;
Panel *panel = reinterpret_cast<Panel *>(Info->hPanel);
return panel->changeDir(Info->Dir);
}
/// process keys
intptr_t WINAPI ProcessPanelInputW(const ProcessPanelInputInfo *Info)
{
if (Info->StructSize < sizeof(ProcessPanelInputInfo))
return 0;
Panel *panel = reinterpret_cast<Panel *>(Info->hPanel);
return panel->ProcessKey(&Info->Rec);
}
/// process redraw events
intptr_t WINAPI ProcessPanelEventW(const ProcessPanelEventInfo *Info)
{
if (Info->StructSize < sizeof(ProcessPanelEventInfo))
return 0;
Panel *panel = reinterpret_cast<Panel *>(Info->hPanel);
return panel->ProcessEvent(Info->Event, Info->Param);
}
/// process sync events (they are fired by the plugin on directory contents change)
intptr_t WINAPI ProcessSynchroEventW(const ProcessSynchroEventInfo *Info)
{
if (Info->StructSize < sizeof(ProcessSynchroEventInfo))
return 0;
Panel *panel = reinterpret_cast<Panel *>(Info->Param);
return panel->ProcessSync(Info->Event);
}