ide: Fixed Alt+J on #include <gtk/gtk.h> (pkg_config issue)

This commit is contained in:
Mirek Fidler 2022-11-24 14:58:59 +01:00
parent 7c93f2ac9a
commit 1bc11e08ab
6 changed files with 43 additions and 43 deletions

View file

@ -2,7 +2,7 @@
namespace Upp {
#define LLOG(x) // DLOG(x)
#define LLOG(x) // DLOG(x)
Ptr<Ctrl> Ctrl::focusCtrl;
Ptr<Ctrl> Ctrl::focusCtrlWnd;
@ -87,7 +87,7 @@ bool Ctrl::DispatchKey(dword keycode, int count)
if(p->IsEnabled() && p->Key(p->unicode ? keycode : k, count))
{
LLOG("Ctrl::DispatchKey(" << FormatIntHex(keycode) << ", " << GetKeyDesc(keycode)
<< "): eaten in " << Desc(p));
<< "): consumed in " << Desc(p));
if(Ini::user_log)
USRLOG(" -> " << Desc(p));
eventCtrl = focusCtrl;
@ -387,14 +387,14 @@ void Ctrl::AnimateCaret()
void Ctrl::PaintCaret(SystemDraw& w)
{
GuiLock __;
LLOG("PaintCaret " << Name() << ", caretCtrl: " << caretCtrl << ", WndCaretVisible: " << WndCaretVisible);
// LLOG("PaintCaret " << Name() << ", caretCtrl: " << caretCtrl << ", WndCaretVisible: " << WndCaretVisible);
if(this == caretCtrl && WndCaretVisible)
w.DrawRect(GetCaret(), InvertColor);
}
void Ctrl::SyncCaret() {
GuiLock __;
LLOG("SyncCaret");
// LLOG("SyncCaret");
if(focusCtrl != caretCtrl) {
LLOG("SyncCaret DO " << Upp::Name(caretCtrl) << " -> " << Upp::Name(focusCtrl));
RefreshCaret();

View file

@ -646,7 +646,8 @@ void Ctrl::Proc()
GDKEY(5), GDKEY(6), GDKEY(7), GDKEY(8), GDKEY(9) }) {
GdkKeymapKey *keys;
gint n_keys;
if(gdk_keymap_get_entries_for_keyval(NULL, k, &keys, &n_keys)) {
if(gdk_keymap_get_entries_for_keyval(gdk_keymap_get_for_display(gdk_display_get_default()), k, &keys, &n_keys)) {
for(int j = 0; j < n_keys; j++)
if(keys[j].group == 0)
hwkv.Add(keys[j].keycode, k);
@ -658,6 +659,7 @@ void Ctrl::Proc()
}
kv += K_DELTA;
}
GetKeyDesc(kv);
if(GetShift() && kv != K_SHIFT_KEY)
kv |= K_SHIFT;
if(GetCtrl() && kv != K_CTRL_KEY)

View file

@ -93,9 +93,8 @@ String NoCr(const char *s)
return out;
}
void MakeBuild::CreateHost(Host& host, bool darkmode, bool disable_uhd)
void MakeBuild::CreateHost(Host& host, const String& method, bool darkmode, bool disable_uhd)
{
SetupDefaultMethod();
VectorMap<String, String> bm = GetMethodVars(method);
{
VectorMap<String, String> env = clone(Environment());
@ -135,6 +134,12 @@ void MakeBuild::CreateHost(Host& host, bool darkmode, bool disable_uhd)
}
}
void MakeBuild::CreateHost(Host& host, bool darkmode, bool disable_uhd)
{
SetupDefaultMethod();
CreateHost(host, method, darkmode, disable_uhd);
}
One<Builder> MakeBuild::CreateBuilder(Host *host)
{
SetupDefaultMethod();

View file

@ -65,6 +65,7 @@ public:
bool makefile_svn_revision = true;
void CreateHost(Host& host, const String& method, bool darkmode, bool disable_uhd);
void CreateHost(Host& host, bool darkmode = false, bool disable_uhd = false);
const TargetMode& GetTargetMode();

View file

@ -853,28 +853,44 @@ String Ide::GetIncludePath()
}
}
}
IncludeAddPkgConfig(include_path, Null);
// TODO: replicate with clang
return include_path;
}
void Ide::IncludeAddPkgConfig(String& include_path, const String& clang_method)
{
#ifdef PLATFORM_POSIX
const Workspace& wspc = GetIdeWorkspace();
Host dummy_host;
One<Builder> b = CreateBuilder(&dummy_host);
Host host;
if(clang_method.GetCount())
CreateHost(host, clang_method, false, false);
else
CreateHost(host, false, false);
One<Builder> b = CreateBuilder(&host);
Index<String> pkg_config;
Index<String> cfg = PackageConfig(wspc, max(GetPackageIndex(), 0), GetMethodVars(method), mainconfigparam, host, *b);
for(int i = 0; i < wspc.GetCount(); i++) {
const Package& pkg = wspc.GetPackage(i);
for(int j = 0; j < pkg.include.GetCount(); j++)
MergeWith(include_path, ";", SourcePath(wspc[i], pkg.include[j].text));
for(String h : Split(Gather(pkg.pkg_config, b->config.GetKeys()), ' '))
for(String h : Split(Gather(pkg.pkg_config, cfg.GetKeys()), ' '))
pkg_config.FindAdd(h);
}
#ifdef PLATFORM_POSIX
for(String s : pkg_config)
for(String p : Split(Sys("pkg-config --cflags " + s), ' '))
static VectorMap<String, String> cflags;
for(String s : pkg_config) {
int q = cflags.Find(s);
if(q < 0) {
q = cflags.GetCount();
cflags.Add(s, Sys("pkg-config --cflags " + s));
}
for(String p : Split(cflags[q], CharFilterWhitespace))
if(p.TrimStart("-I"))
MergeWith(include_path, ";", p);
}
#endif
return include_path;
}
String Ide::GetCurrentIncludePath()
@ -903,33 +919,8 @@ String Ide::GetCurrentIncludePath()
}
include_path = Join(GetUppDirs(), ";") + ';' + bm.Get("INCLUDE", "");
const Workspace& wspc = GetIdeWorkspace();
Host host;
CreateHost(host, false, false);
One<Builder> b = CreateBuilder(&host);
Index<String> cfg = PackageConfig(wspc, max(GetPackageIndex(), 0), GetMethodVars(method), mainconfigparam, host, *b);
Index<String> pkg_config;
for(int i = 0; i < wspc.GetCount(); i++) {
const Package& pkg = wspc.GetPackage(i);
for(int j = 0; j < pkg.include.GetCount(); j++)
MergeWith(include_path, ";", SourcePath(wspc[i], pkg.include[j].text));
for(String h : Split(Gather(pkg.pkg_config, cfg.GetKeys()), ' '))
pkg_config.FindAdd(h);
}
static VectorMap<String, String> cflags;
for(String s : pkg_config) {
int q = cflags.Find(s);
if(q < 0) {
q = cflags.GetCount();
cflags.Add(s, Sys("pkg-config --cflags " + s));
}
for(String p : Split(cflags[q], CharFilterWhitespace))
if(p.TrimStart("-I"))
MergeWith(include_path, ";", p);
}
IncludeAddPkgConfig(include_path, clang_method);
return include_path;
}

View file

@ -1166,6 +1166,7 @@ public:
void ShowTopics();
void ShowTopicsWin();
void IncludeAddPkgConfig(String& include_path, const String& clang_method);
String GetIncludePath();
String GetCurrentIncludePath();
String GetCurrentDefines();