mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
ide: Navigator context menu
This commit is contained in:
parent
085475e9a7
commit
4bfe5fe8c6
7 changed files with 55 additions and 16 deletions
|
|
@ -101,6 +101,7 @@ enum CtrlCoreFlags : dword {
|
|||
K_PEN = 0x80,
|
||||
|
||||
IK_DBL_CLICK = 0x40000001, // this is just to get the info that the entry is equal to dbl-click to the menu
|
||||
IK_CLICK = 0x40000002, // this is just to get the info that the entry is equal to dbl-click to the menu
|
||||
|
||||
K_MOUSE_FORWARD = 0x40000002,
|
||||
K_MOUSE_BACKWARD = 0x40000003
|
||||
|
|
|
|||
|
|
@ -410,6 +410,7 @@ Tuple<dword, const char *> KeyNames__[ ] = {
|
|||
#ifdef GUI_COCOA
|
||||
{ K_OPTION_KEY, tt_("key\vOption") },
|
||||
#endif
|
||||
{ IK_CLICK, tt_("key\v[click]") },
|
||||
{ IK_DBL_CLICK, tt_("key\v[double-click]") },
|
||||
{ (dword)K_MOUSE_FORWARD, tt_("key\v[Forward]") },
|
||||
{ (dword)K_MOUSE_BACKWARD, tt_("key\v[Backward]") },
|
||||
|
|
|
|||
|
|
@ -225,6 +225,8 @@ Bar::Item& Bar::Item::RightLabel(const char *text)
|
|||
}
|
||||
|
||||
Bar::Item& Bar::Item::Key(KeyInfo& (*key)()) {
|
||||
if(!key)
|
||||
return *this;
|
||||
KeyInfo& k = (*key)();
|
||||
return Key(k.key[0]).Key(k.key[1]).Key(k.key[2]).Key(k.key[3]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ struct Navigator {
|
|||
void NaviSort();
|
||||
|
||||
void Navigate();
|
||||
void Navigate(bool usage);
|
||||
void NavigatorClick();
|
||||
void NavigatorEnter();
|
||||
void SyncCursor();
|
||||
|
|
|
|||
|
|
@ -73,9 +73,26 @@ Navigator::Navigator()
|
|||
{
|
||||
list.NoHeader();
|
||||
list.AddRowNumColumn().SetDisplay(navidisplay);
|
||||
list.SetLineCy(max(16, GetStdFontCy()));
|
||||
list.SetLineCy(max(DPI(16), GetStdFontCy()));
|
||||
list.NoWantFocus();
|
||||
list.WhenLeftClick = THISBACK(NavigatorClick);
|
||||
list.WhenBar = [=](Bar& bar) {
|
||||
if(!theide)
|
||||
return;
|
||||
int kind = KIND_NEST;
|
||||
String name;
|
||||
int ii = list.GetCursor();
|
||||
if(ii >= 0 && ii < litem.GetCount()) {
|
||||
const NavItem& m = *litem[ii];
|
||||
kind = m.kind;
|
||||
name = m.name;
|
||||
}
|
||||
bar.Add(kind != KIND_NEST, "Go to", [=] { Navigate(false); })
|
||||
.Key(IK_CLICK);
|
||||
bar.Add(kind >= 0, "Usage", [=] { Navigate(true); })
|
||||
.Key(K_ALT|IK_CLICK);
|
||||
theide->OnlineSearchMenu(bar, name, false);
|
||||
};
|
||||
|
||||
scope.NoHeader();
|
||||
scope.AddColumn().AddIndex().SetDisplay(Single<ScopeDisplay>());
|
||||
|
|
@ -142,7 +159,7 @@ void Navigator::SyncCursor()
|
|||
}
|
||||
}
|
||||
|
||||
void Navigator::Navigate()
|
||||
void Navigator::Navigate(bool usage)
|
||||
{
|
||||
if(navigating)
|
||||
return;
|
||||
|
|
@ -186,14 +203,12 @@ void Navigator::Navigate()
|
|||
else
|
||||
if(m.kind == KIND_LINE) {
|
||||
theide->GotoPos(Null, m.pos);
|
||||
if(m.kind == KIND_LINE) { // Go to line - restore file view
|
||||
search.Clear();
|
||||
Search();
|
||||
navigating = false;
|
||||
}
|
||||
search.Clear(); // Go to line - restore file view
|
||||
Search();
|
||||
navigating = false;
|
||||
}
|
||||
else
|
||||
if(GetAlt())
|
||||
if(usage)
|
||||
theide->Usage(m.id, m.name, m.pos);
|
||||
else
|
||||
if(IsNull(search)) // current file - do not cycle
|
||||
|
|
@ -205,6 +220,11 @@ void Navigator::Navigate()
|
|||
SyncCursor();
|
||||
}
|
||||
|
||||
void Navigator::Navigate()
|
||||
{
|
||||
Navigate(GetAlt());
|
||||
}
|
||||
|
||||
void Navigator::NavigatorClick()
|
||||
{
|
||||
if(dlgmode)
|
||||
|
|
@ -408,11 +428,11 @@ void Navigator::Search()
|
|||
int all_count = 0;
|
||||
String usearch_nest = ToUpper(search_nest);
|
||||
String usearch_name = ToUpper(search_name);
|
||||
if(!IsNull(lineno)) {
|
||||
if(!IsNull(lineno) && lineno > 0) {
|
||||
NavItem& m = nitem.Add();
|
||||
m.pretty = "Go to line " + AsString(lineno);
|
||||
m.kind = KIND_LINE;
|
||||
m.pos.y = lineno;
|
||||
m.pos.y = lineno - 1;
|
||||
m.pos.x = 0;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -207,6 +207,11 @@ void WebSearchTab::Save()
|
|||
}
|
||||
|
||||
void Ide::OnlineSearchMenu(Bar& menu)
|
||||
{
|
||||
OnlineSearchMenu(menu, Nvl(editor.GetSelection(), editor.GetWord()), true);
|
||||
}
|
||||
|
||||
void Ide::OnlineSearchMenu(Bar& menu, const String& what, bool accel)
|
||||
{
|
||||
static Time search_engines_tm = Null;
|
||||
static Value search_engines;
|
||||
|
|
@ -225,11 +230,11 @@ void Ide::OnlineSearchMenu(Bar& menu)
|
|||
}
|
||||
}
|
||||
|
||||
bool b = editor.IsSelection() || IsAlNum(editor.GetChar()) || editor.GetChar() == '_';
|
||||
bool b = what.GetCount(); // editor.IsSelection() || IsAlNum(editor.GetChar()) || editor.GetChar() == '_';
|
||||
|
||||
auto OnlineSearch = [=](const String& url) {
|
||||
String h = url;
|
||||
h.Replace("%s", UrlEncode(Nvl(editor.GetSelection(), editor.GetWord())));
|
||||
h.Replace("%s", UrlEncode(what));
|
||||
LaunchWebBrowser(h);
|
||||
};
|
||||
|
||||
|
|
@ -258,10 +263,18 @@ void Ide::OnlineSearchMenu(Bar& menu)
|
|||
|
||||
using namespace IdeKeys;
|
||||
|
||||
menu.Add(b, "Search on " + name, Nvl(m, CtrlImg::Network()), [=] { OnlineSearch(uri); }).Key(AK_GOOGLE);
|
||||
menu.Add(b, AK_GOOGLEUPP, IdeImg::GoogleUpp(), [=] {
|
||||
OnlineSearch("https://www.google.com/search?q=%s&sitesearch=ultimatepp.org");
|
||||
});
|
||||
{
|
||||
auto& x = menu.Add(b, "Search on " + name, Nvl(m, CtrlImg::Network()), [=] { OnlineSearch(uri); });
|
||||
if(accel)
|
||||
x.Key(AK_GOOGLE);
|
||||
}
|
||||
{
|
||||
auto& x = menu.Add(b, AK_GOOGLEUPP, IdeImg::GoogleUpp(), [=] {
|
||||
OnlineSearch("https://www.google.com/search?q=%s&sitesearch=ultimatepp.org");
|
||||
});
|
||||
if(accel)
|
||||
x.Key(AK_GOOGLEUPP);
|
||||
}
|
||||
|
||||
if(!menu.IsMenuBar() || search_engines.GetCount() < 2)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -893,6 +893,7 @@ public:
|
|||
void ReformatComment();
|
||||
String FindClangFormatPath(bool local = false);
|
||||
|
||||
void OnlineSearchMenu(Bar& menu, const String& what, bool accel);
|
||||
void OnlineSearchMenu(Bar& menu);
|
||||
|
||||
String GetFoundText(const ArrayCtrl& list);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue