mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-05 17:44:55 -06:00
ide: Context goto now able to detect files / links
git-svn-id: svn://ultimatepp.org/upp/trunk@13969 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
f2560b4546
commit
da2abe8911
2 changed files with 25 additions and 1 deletions
|
|
@ -91,12 +91,35 @@ String RemoveTemplateParams(const String& s)
|
|||
return ParseTemplatedType(s, dummy);
|
||||
}
|
||||
|
||||
bool Ide::OpenLink(const String& s, int pos)
|
||||
{ // try to find link at cursor, either http, https or file
|
||||
auto IsLinkChar = [](int c) { return findarg(c, '\'', '\"', '\t', ' ', '\0') < 0; };
|
||||
int b = pos;
|
||||
while(b > 0 && IsLinkChar(s[b - 1]))
|
||||
b--;
|
||||
int e = pos;
|
||||
while(IsLinkChar(s[e]))
|
||||
e++;
|
||||
String link = s.Mid(b, e - b);
|
||||
if(link.StartsWith("http://") || link.StartsWith("https://"))
|
||||
LaunchWebBrowser(link);
|
||||
else
|
||||
if(FileExists(link))
|
||||
EditFile(link);
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Ide::ContextGoto0(int pos)
|
||||
{
|
||||
if(designer)
|
||||
return;
|
||||
int li = editor.GetLine(pos);
|
||||
int lp = pos;
|
||||
int li = editor.GetLinePos(lp);
|
||||
String l = editor.GetUtf8Line(li);
|
||||
if(OpenLink(l, lp))
|
||||
return;
|
||||
if(IsPif(l) || IsPelse(l)) {
|
||||
int lvl = 0;
|
||||
while(li + 1 < editor.GetLineCount()) {
|
||||
|
|
|
|||
|
|
@ -939,6 +939,7 @@ public:
|
|||
bool SwapSIf(const char *cref);
|
||||
void SwapS();
|
||||
void FindId(const String& id);
|
||||
bool OpenLink(const String& s, int pos);
|
||||
void ContextGoto0(int pos);
|
||||
void ContextGoto();
|
||||
void GoToLine();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue