2727#include < far3/current_editor_impl.h>
2828#include < far3/error.h>
2929#include < far3/guid.h>
30+ #include < far3/help.h>
3031#include < far3/plugin_sdk/api.h>
3132#include < far3/text.h>
3233#include < far3/wide_string.h>
5556#include < unordered_map>
5657#include < unordered_set>
5758
59+ namespace Help = Far3::Help;
60+
5861using WideString = Far3::WideString;
5962using Far3::ToString;
6063using Far3::ToStdString;
@@ -812,19 +815,19 @@ struct MI{
812815
813816using MenuList = std::vector<MI >;
814817
815- std::pair<int , int > Menu (const wchar_t *title, MenuList const & lst, int sel, FarKey const * breakKeys)
818+ std::pair<int , int > Menu (const wchar_t *title, const wchar_t *help, MenuList const & lst, int sel, FarKey const * breakKeys)
816819{
817820 std::vector<FarMenuItem> menu (lst.size ());
818821 std::transform (lst.begin (), lst.end (), menu.begin (), [sel](MI const & mi) {return mi.GetFarItem (sel);});
819822 intptr_t bkey = -1 ;
820823 auto res=I.Menu (&PluginGuid, &CtagsMenuGuid, -1 , -1 , 0 , FMENU_WRAPMODE , title, L" " ,
821- L" content " , breakKeys, &bkey, &menu[0 ], lst.size ());
824+ help , breakKeys, &bkey, &menu[0 ], lst.size ());
822825 return std::make_pair (res == -1 ? -1 : lst.at (res).data , static_cast <int >(bkey));
823826}
824827
825- int Menu (const wchar_t *title, MenuList const & lst, int sel = 0 )
828+ int Menu (const wchar_t *title, const wchar_t *help, MenuList const & lst, int sel = 0 )
826829{
827- return Menu (title, lst, sel, nullptr ).first ;
830+ return Menu (title, help, lst, sel, nullptr ).first ;
828831}
829832
830833std::unique_ptr<BreakKeys> CreateLookupBreakKeys (UseLayouts useLayouts)
@@ -973,7 +976,7 @@ static LookupResult LookupTagsMenu(TagsViewer const& viewer, TagInfo& tag, std::
973976 ResetSelected (menu, selected);
974977 intptr_t bkey = -1 ;
975978 selected = I.Menu (&PluginGuid, &CtagsMenuGuid,-1 ,-1 ,0 ,FMENU_WRAPMODE |FMENU_SHOWAMPERSAND ,ftitle.c_str (),
976- GetMsg (MLookupMenuBottom),L" content " , breakKeys.GetBreakKeys (),&bkey, menu.empty () ? nullptr : &menu[0 ],menu.size ());
979+ GetMsg (MLookupMenuBottom), Help::Contents, breakKeys.GetBreakKeys (), &bkey, menu.empty () ? nullptr : &menu[0 ], menu.size ());
977980 if (selected == -1 && bkey == -1 ) return LookupResult::Cancel;
978981 auto selectedTag = selected >= 0 ? tagsView[menu[selected].UserData ].GetTag () : nullptr ;
979982 auto event = breakKeys.GetEvent (static_cast <int >(bkey));
@@ -1003,6 +1006,7 @@ static LookupResult LookupTagsMenu(TagsViewer const& viewer, TagInfo& tag, std::
10031006 {
10041007 ResetCacheCountersOnTimeout (*selectedTag);
10051008 Storage->EraseCachedTag (*selectedTag, FlushTagsCache);
1009+ break ;
10061010 }
10071011 if (selectedTag && event == KeyEvent::CtrlR)
10081012 {
@@ -1095,7 +1099,7 @@ static void ManageRepositories()
10951099 auto regulars_count = std::distance (repositories.begin (), std::stable_partition (repositories.begin (), repositories.end (), [](Tags::RepositoryInfo const & repo) {return repo.Type == Tags::RepositoryType::Regular;}));
10961100 auto history = LoadHistory ();
10971101 for (size_t i = 0 ; i < history.size () / 2 ; std::swap (history[i], history[history.size () - 1 - i]), ++i);
1098- auto res = Menu (GetMsg (MUnloadTagsFile), GetRepoMenuList (repositories, history), selected, breakKeys->GetBreakKeys ());
1102+ auto res = Menu (GetMsg (MUnloadTagsFile), Help::Contents, GetRepoMenuList (repositories, history), selected, breakKeys->GetBreakKeys ());
10991103 if (res.first == -1 )
11001104 return ;
11011105
@@ -1373,7 +1377,7 @@ static void NavigationHistory(bool setPanelDir)
13731377
13741378 auto selected = NavigatorInstance->CurrentHistoryIndex ();
13751379 selected = selected == size && size > 0 ? size - 1 : selected;
1376- auto index = Menu (GetMsg (MNavigationHistoryMenuTitle), menuList, static_cast <int >(selected));
1380+ auto index = Menu (GetMsg (MNavigationHistoryMenuTitle), Help::Contents, menuList, static_cast <int >(selected));
13771381 if (index < 0 )
13781382 return ;
13791383
@@ -1500,7 +1504,7 @@ static WideString SelectTags(std::vector<WideString> const& foundTags)
15001504 for (auto const & tagsFile : foundTags)
15011505 lst.push_back (MI (tagsFile, i++));
15021506
1503- auto res = Menu (GetMsg (MSelectTags), lst);
1507+ auto res = Menu (GetMsg (MSelectTags), Help::Contents, lst);
15041508 if (res < 0 )
15051509 return WideString ();
15061510
@@ -1525,7 +1529,7 @@ static WideString IndexSelectedRepository(std::vector<WideString> const& reposit
15251529 for (auto const & str : repositories)
15261530 lst.push_back (MI (str, i++));
15271531
1528- auto res = Menu (GetMsg (MAskIndexFoundRepositories), lst);
1532+ auto res = Menu (GetMsg (MAskIndexFoundRepositories), Help::Contents, lst);
15291533 if (res < 0 )
15301534 return WideString ();
15311535
@@ -1868,7 +1872,7 @@ HANDLE WINAPI OpenW(const struct OpenInfo *info)
18681872 , MI::Separator ()
18691873 , MI (MPluginConfiguration, miPluginConfiguration, ' C' )
18701874 };
1871- int res=Menu (GetMsg (MPlugin),ml,miReindexFile);
1875+ int res=Menu (GetMsg (MPlugin), Help::Editor, ml, miReindexFile);
18721876 if (res==-1 )return nullptr ;
18731877 if ((res == miFindSymbol
18741878 || res == miComplete
@@ -1956,7 +1960,7 @@ HANDLE WINAPI OpenW(const struct OpenInfo *info)
19561960 {
19571961 enum {miLoadFromHistory,miLoadTagsFile,miUnloadTagsFile, miReindexRepo,
19581962 miCreateTagsFile,miAddPermanentRepository, miLookupSymbol, miSearchFile,
1959- miPluginConfiguration, miNavigationHistory,
1963+ miPluginConfiguration, miNavigationHistory, miHelp
19601964 };
19611965 MenuList ml = {
19621966 MI (MLookupSymbol, miLookupSymbol, ' 1' )
@@ -1971,9 +1975,10 @@ HANDLE WINAPI OpenW(const struct OpenInfo *info)
19711975 , MI (MCreateTagsFile, miCreateTagsFile, ' 7' )
19721976 , MI (MReindexRepo, miReindexRepo, ' 8' )
19731977 , MI::Separator ()
1978+ , MI (MHelp, miHelp, ' ?' )
19741979 , MI (MPluginConfiguration, miPluginConfiguration, ' C' )
19751980 };
1976- int rc=Menu (GetMsg (MPlugin),ml,miReindexRepo);
1981+ int rc=Menu (GetMsg (MPlugin), Help::PanelMenu, ml, miReindexRepo);
19771982 switch (rc)
19781983 {
19791984 case miLoadFromHistory:
@@ -2022,6 +2027,10 @@ HANDLE WINAPI OpenW(const struct OpenInfo *info)
20222027 {
20232028 SafeCall (ConfigurePlugin, Err);
20242029 }break ;
2030+ case miHelp:
2031+ {
2032+ I.ShowHelp (reinterpret_cast <wchar_t const *>(&PluginGuid), Help::Contents, FHELP_GUID );
2033+ }break ;
20252034 }
20262035 }
20272036 if (OpenFrom == OPEN_COMMANDLINE )
0 commit comments