Skip to content

Commit dfc509a

Browse files
Introduce help
1 parent 0cc7963 commit dfc509a

9 files changed

Lines changed: 181 additions & 17 deletions

File tree

far_plugin/facade/far3/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ add_library(ctags SHARED ${SOURCES})
2727
target_link_libraries(ctags ctags_static)
2828

2929
set(PLUGIN_DIR ${CMAKE_BINARY_DIR}/$<CONFIG>/ctags CACHE STRING "Plugin release folder")
30+
configure_file(src/tagseng.hlf.in tagseng.hlf)
3031
file(GLOB README_FILES "${CMAKE_SOURCE_DIR}/README*.md")
3132
add_custom_command(TARGET ctags POST_BUILD
3233
COMMAND ${CMAKE_COMMAND} -E make_directory ${PLUGIN_DIR}
34+
COMMAND ${CMAKE_COMMAND} -E copy tagseng.hlf ${PLUGIN_DIR}
3335
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/src/tagseng.lng ${PLUGIN_DIR}
3436
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:ctags> ${PLUGIN_DIR}
3537
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/COPYING ${PLUGIN_DIR}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
namespace Far3
4+
{
5+
namespace Help
6+
{
7+
wchar_t const* const Contents = L"Contents";
8+
wchar_t const* const PanelMenu = L"PanelMenu";
9+
wchar_t const* const Editor = L"Editor";
10+
wchar_t const* const Config = L"Config";
11+
}
12+
}

far_plugin/facade/far3/include/far3/text.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,5 @@ enum{
9595
MTooManyLinesInConfigFile,
9696
MFailedLoadConfig,
9797
MDefault,
98+
MHelp,
9899
};

far_plugin/facade/far3/src/config_menu.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <far3/config_menu.h>
22
#include <far3/config_value_dialog.h>
33
#include <far3/guid.h>
4+
#include <far3/help.h>
45
#include <far3/plugin_sdk/api.h>
56
#include <far3/text.h>
67
#include <far3/wide_string.h>
@@ -14,6 +15,8 @@
1415

1516
namespace
1617
{
18+
namespace Help = Far3::Help;
19+
1720
using Far3::Guid;
1821
using Far3::ToString;
1922
using Far3::WideString;
@@ -36,11 +39,11 @@ namespace
3639
{ID::threshold_filter_len, MThresholdFilterLen},
3740
{ID::platform_language_lookup, MPlatformLanguageLookup},
3841
separator,
39-
{ID::reset_cache_counters_timeout_hours, MResetCountersAfter},
4042
{ID::casesens, MCaseSensFilt},
4143
{ID::sort_class_members_by_name, MSortClassMembersByName },
4244
{ID::cur_file_first, MCurFileFirst},
4345
{ID::cached_tags_on_top, MCachedTagsOnTop},
46+
{ID::reset_cache_counters_timeout_hours, MResetCountersAfter},
4447
{ID::index_edited_file, MIndexEditedFile},
4548
{ID::wordchars, MWordChars},
4649
separator,
@@ -162,7 +165,7 @@ namespace
162165
FMENU_WRAPMODE,
163166
menuTitle.c_str(),
164167
bottomText,
165-
L"configmenu",
168+
Help::Config,
166169
breakKeys,
167170
&breakKey,
168171
farMenuItems.data(),

far_plugin/facade/far3/src/config_value_dialog.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <far3/config_value_dialog.h>
22
#include <far3/guid.h>
3+
#include <far3/help.h>
34
#include <far3/plugin_sdk/api.h>
45
#include <far3/text.h>
56
#include <far3/wide_string.h>
@@ -11,6 +12,8 @@
1112

1213
namespace
1314
{
15+
namespace Help = Far3::Help;
16+
1417
using Far3::Guid;
1518
using Far3::ToString;
1619
using Far3::ToStdString;
@@ -99,7 +102,7 @@ namespace
99102
autocenterY,
100103
Width,
101104
Bottom() + 2,
102-
nullptr,
105+
Help::Config,
103106
Items.data(),
104107
Items.size(),
105108
0,

far_plugin/facade/far3/src/plugin.cpp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
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>
@@ -55,6 +56,8 @@
5556
#include <unordered_map>
5657
#include <unordered_set>
5758

59+
namespace Help = Far3::Help;
60+
5861
using WideString = Far3::WideString;
5962
using Far3::ToString;
6063
using Far3::ToStdString;
@@ -812,19 +815,19 @@ struct MI{
812815

813816
using 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

830833
std::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)
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
.Language=English,English
2+
.Options CtrlColorChar=\
3+
.Options CtrlStartPosChar=^<wrap>
4+
5+
@ Contents=Contents
6+
@ About=About
7+
@ Usage=Usage
8+
@ Macro=Macro
9+
@ Features=Features
10+
@ Config=Config
11+
@ PanelMenu=PanelMenu
12+
@ Editor=Editor
13+
14+
@Contents
15+
$^#Ctags Source Navigator
16+
$^#${CTAGS_VERSION_MAJOR}.${CTAGS_VERSION_MINOR}.${CTAGS_VERSION_REVISION}.${CTAGS_VERSION_BUILD}
17+
18+
#Table of contents#
19+
20+
~About~@ About@
21+
22+
~How to use~@ Usage@
23+
24+
~Panel menu~@ PanelMenu@
25+
26+
~Editor menu~@ Editor@
27+
28+
~Configuration menu~@ Config@
29+
30+
~Macro~@ Macro@
31+
32+
~Features~@ Features@
33+
34+
35+
36+
37+
@About
38+
$^#Ctags Source Navigator
39+
$^#${CTAGS_VERSION_MAJOR}.${CTAGS_VERSION_MINOR}.${CTAGS_VERSION_REVISION}.${CTAGS_VERSION_BUILD}
40+
41+
#About this plugin#
42+
43+
This is a #Far Manager# plugin for browsing source code indexed by #Ctags# utility (~https://en.wikipedia.org/wiki/Ctags~@https://en.wikipedia.org/wiki/Ctags@).
44+
45+
#Plugin Homepage:# ~https://github.com/EugeneManushkin/CtagsSourceNavigator~@https://github.com/EugeneManushkin/CtagsSourceNavigator@
46+
47+
#Far PlugRing:# ~https://plugring.farmanager.com/plugin.php?pid=478~@https://plugring.farmanager.com/plugin.php?pid=478@
48+
49+
#Discussion Thread:# ~https://forum.farmanager.com/viewtopic.php?f=5&t=6394~@https://forum.farmanager.com/viewtopic.php?f=5&t=6394@
50+
51+
If you found a bug or you need a feature please create an issue (~https://github.com/EugeneManushkin/CtagsSourceNavigator/issues/new~@https://github.com/EugeneManushkin/CtagsSourceNavigator/issues/new@)
52+
53+
Please click on the Star button on the plugin's GitHub page, I appreciate it.
54+
55+
~Table of contents~@ Contents@
56+
57+
58+
59+
60+
@Usage
61+
$^#Ctags Source Navigator
62+
$^#${CTAGS_VERSION_MAJOR}.${CTAGS_VERSION_MINOR}.${CTAGS_VERSION_REVISION}.${CTAGS_VERSION_BUILD}
63+
64+
#How to use#
65+
66+
TBD
67+
68+
~Table of contents~@ Contents@
69+
70+
71+
72+
73+
@PanelMenu
74+
$^#Ctags Source Navigator
75+
$^#${CTAGS_VERSION_MAJOR}.${CTAGS_VERSION_MINOR}.${CTAGS_VERSION_REVISION}.${CTAGS_VERSION_BUILD}
76+
77+
#Panel menu#
78+
79+
TBD
80+
81+
~Table of contents~@ Contents@
82+
83+
84+
85+
86+
@Editor
87+
$^#Ctags Source Navigator
88+
$^#${CTAGS_VERSION_MAJOR}.${CTAGS_VERSION_MINOR}.${CTAGS_VERSION_REVISION}.${CTAGS_VERSION_BUILD}
89+
90+
#Editor menu#
91+
92+
TBD
93+
94+
~Table of contents~@ Contents@
95+
96+
97+
98+
99+
@Config
100+
$^#Ctags Source Navigator
101+
$^#${CTAGS_VERSION_MAJOR}.${CTAGS_VERSION_MINOR}.${CTAGS_VERSION_REVISION}.${CTAGS_VERSION_BUILD}
102+
103+
#Configuration menu#
104+
105+
TBD
106+
107+
~Table of contents~@ Contents@
108+
109+
110+
111+
112+
@Macro
113+
$^#Ctags Source Navigator
114+
$^#${CTAGS_VERSION_MAJOR}.${CTAGS_VERSION_MINOR}.${CTAGS_VERSION_REVISION}.${CTAGS_VERSION_BUILD}
115+
116+
#Macro#
117+
118+
TBD
119+
120+
~Table of contents~@ Contents@
121+
122+
123+
124+
125+
@Features
126+
$^#Ctags Source Navigator
127+
$^#${CTAGS_VERSION_MAJOR}.${CTAGS_VERSION_MINOR}.${CTAGS_VERSION_REVISION}.${CTAGS_VERSION_BUILD}
128+
129+
#Features#
130+
131+
TBD
132+
133+
~Table of contents~@ Contents@

far_plugin/facade/far3/src/tagseng.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,4 @@
9494
"Too many lines in config file.\nPlease remove config file"
9595
"Failed to load config"
9696
"&Default"
97+
"Help"

far_plugin/include/plugin/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ namespace Plugin
2121
size_t threshold = 500;
2222
size_t threshold_filter_len = 3;
2323
ThreeStateFlag platform_language_lookup = ThreeStateFlag::Undefined;
24-
size_t reset_cache_counters_timeout_hours = 12;
2524
bool casesens = false;
2625
bool sort_class_members_by_name = false;
2726
bool cur_file_first = true;
2827
bool cached_tags_on_top = true;
28+
size_t reset_cache_counters_timeout_hours = 12;
2929
bool index_edited_file = true;
3030
std::string wordchars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~$_";
3131
std::string tagsmask = "tags,*.tags";
@@ -45,11 +45,11 @@ namespace Plugin
4545
threshold,
4646
threshold_filter_len,
4747
platform_language_lookup,
48-
reset_cache_counters_timeout_hours,
4948
casesens,
5049
sort_class_members_by_name,
5150
cur_file_first,
5251
cached_tags_on_top,
52+
reset_cache_counters_timeout_hours,
5353
index_edited_file,
5454
wordchars,
5555
tagsmask,

0 commit comments

Comments
 (0)