mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
ide: MacOS improvements
git-svn-id: svn://ultimatepp.org/upp/trunk@12727 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
4c73023052
commit
56dbedbdf8
6 changed files with 88 additions and 36 deletions
|
|
@ -351,10 +351,18 @@ String Gdb::DoRun()
|
|||
{
|
||||
if(firstrun) {
|
||||
firstrun = false;
|
||||
#ifdef PLATFORM_LLDB
|
||||
Cmd("b main");
|
||||
String s = Cmd("r", true);
|
||||
s << Cmd("settings show prompt"); // Resync stdout
|
||||
int q = s.FindAfter("Process");
|
||||
pid = atoi(~s + q);
|
||||
#else
|
||||
Cmd("start");
|
||||
String s = Cmd("info inferior");
|
||||
int q = s.FindAfter("process");
|
||||
pid = atoi(~s + q);
|
||||
#endif
|
||||
IdeSetBar();
|
||||
}
|
||||
|
||||
|
|
@ -535,6 +543,16 @@ bool Gdb::Create(One<Host>&& _host, const String& exefile, const String& cmdline
|
|||
watches.WhenAcceptEdit = THISBACK(ObtainData);
|
||||
tab <<= THISBACK(ObtainData);
|
||||
|
||||
#ifdef PLATFORM_LLDB
|
||||
Cmd("settings set auto-confirm true");
|
||||
#if 0
|
||||
Cmd("l");
|
||||
Cmd("b main");
|
||||
Cmd("r", true); Cmd("settings show prompt");
|
||||
Cmd("bt");
|
||||
return false;
|
||||
#endif
|
||||
#else
|
||||
Cmd("set prompt " GDB_PROMPT);
|
||||
Cmd("set disassembly-flavor intel");
|
||||
Cmd("set exec-done-display off");
|
||||
|
|
@ -554,6 +572,7 @@ bool Gdb::Create(One<Host>&& _host, const String& exefile, const String& cmdline
|
|||
|
||||
if(!IsNull(cmdline))
|
||||
Cmd("set args " + cmdline);
|
||||
#endif
|
||||
|
||||
firstrun = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public:
|
|||
public:
|
||||
String DoRun();
|
||||
|
||||
bool Result(String& result, const String& s);
|
||||
bool Result(String& result, const String& s, bool run = false);
|
||||
|
||||
void AddReg(const char *reg, Label *lbl) { regname.Add(reg); reglbl.Add(lbl); }
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ public:
|
|||
void Lock();
|
||||
void Unlock();
|
||||
|
||||
String Cmd(const char *command, bool start = false);
|
||||
String Cmd(const char *command, bool run = false);
|
||||
String FastCmd(const char *command);
|
||||
|
||||
bool IsProcessExitedNormally(const String& cmd_output) const;
|
||||
|
|
|
|||
|
|
@ -91,19 +91,35 @@ void Gdb::Unlock()
|
|||
}
|
||||
}
|
||||
|
||||
bool Gdb::Result(String& result, const String& s)
|
||||
bool Gdb::Result(String& result, const String& s, bool run)
|
||||
{
|
||||
result.Cat(s);
|
||||
int l = result.GetLength();
|
||||
int q = result.Find(GDB_PROMPT, max(0, l - 50));
|
||||
if(q >= 0) {
|
||||
result.Trim(q);
|
||||
return true;
|
||||
if(run) {
|
||||
if(result.Find("stopped") >= 0 || result.Find("exited") >= 0)
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
int q = result.Find(GDB_PROMPT, max(0, l - 50));
|
||||
if(q >= 0) {
|
||||
result.Trim(q);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String Gdb::Cmd(const char *command, bool start)
|
||||
void LLDBFixResult(String& result)
|
||||
{
|
||||
int q = result.Find('\n');
|
||||
if(q >= 0 && result.StartsWith("(lldb)"))
|
||||
result = result.Mid(q + 1);
|
||||
q = result.ReverseFind('\n');
|
||||
if(q >= 0 && result.Find("(lldb)", q) == q + 1)
|
||||
result.Trim(q);
|
||||
}
|
||||
|
||||
String Gdb::Cmd(const char *command, bool run)
|
||||
{
|
||||
if(!dbg || !dbg->IsRunning() || IdeIsDebugLock()) return Null;
|
||||
TimeStop ts;
|
||||
|
|
@ -112,6 +128,10 @@ String Gdb::Cmd(const char *command, bool start)
|
|||
LLOG("========= Cmd: " << command);
|
||||
dbg->Write(String(command) + "\n");
|
||||
PutVerbose(String() << "Command: " << command);
|
||||
#ifdef PLATFORM_LLDB
|
||||
if(!run)
|
||||
dbg->Write("#" + String(GDB_PROMPT) + "\n"); // the echo will mark the end of command...
|
||||
#endif
|
||||
}
|
||||
String result;
|
||||
int ms0 = msecs();
|
||||
|
|
@ -123,16 +143,8 @@ String Gdb::Cmd(const char *command, bool start)
|
|||
LLOG("Running: " << dbg->IsRunning());
|
||||
break;
|
||||
}
|
||||
if(!s.IsEmpty() && Result(result, s)) {
|
||||
LLOG(result);
|
||||
PutVerbose(result);
|
||||
if(start) {
|
||||
start = false;
|
||||
result = s.Mid(result.GetCount());
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if(!s.IsEmpty() && Result(result, s, run))
|
||||
break;
|
||||
if(ms0 != msecs()) {
|
||||
ProcessEvents();
|
||||
ms0 = msecs();
|
||||
|
|
@ -147,8 +159,10 @@ String Gdb::Cmd(const char *command, bool start)
|
|||
if(command) {
|
||||
PutVerbose(String() << "Time of `" << command <<"` " << ts);
|
||||
}
|
||||
PutVerbose("=========== Result:");
|
||||
PutVerbose(result);
|
||||
#ifdef PLATFORM_LLDB
|
||||
LLDBFixResult(result);
|
||||
#endif
|
||||
PutVerbose("=========== Result:\n" + result);
|
||||
PutVerbose("===================");
|
||||
return result;
|
||||
}
|
||||
|
|
@ -160,6 +174,7 @@ String Gdb::FastCmd(const char *command)
|
|||
if(command) {
|
||||
dbg->Write(String(command) + "\n");
|
||||
PutVerbose(String() << "Fast Command: " << command);
|
||||
dbg->Write("#" + String(GDB_PROMPT) + "\n"); // the echo will mark the end of command...
|
||||
}
|
||||
String result;
|
||||
TimeStop ts;
|
||||
|
|
@ -176,13 +191,8 @@ String Gdb::FastCmd(const char *command)
|
|||
LLOG("Running: " << dbg->IsRunning());
|
||||
break;
|
||||
}
|
||||
if(!s.IsEmpty() && Result(result, s)) {
|
||||
LLOG(result);
|
||||
LLOG("Result length: " << result.GetLength());
|
||||
if(result.GetLength() < 1000)
|
||||
PutVerbose(result);
|
||||
if(!s.IsEmpty() && Result(result, s))
|
||||
break;
|
||||
}
|
||||
if(s.GetCount() == 0)
|
||||
Sleep(0);
|
||||
if(ts.Elapsed() > 500) {
|
||||
|
|
@ -200,7 +210,11 @@ String Gdb::FastCmd(const char *command)
|
|||
PutVerbose(String() << "Time of `" << command <<"` " << ts);
|
||||
}
|
||||
#endif
|
||||
PutVerbose("Result: " + result);
|
||||
#ifdef PLATFORM_LLDB
|
||||
LLDBFixResult(result);
|
||||
#endif
|
||||
PutVerbose("=========== Fast Result:\n" + result);
|
||||
PutVerbose("===================");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ bool TTYQuit() { return false; }
|
|||
|
||||
String GdbCommand(bool console)
|
||||
{
|
||||
#ifdef PLATFORM_COCOA
|
||||
String gdb = "/usr/local/bin/gdb ";
|
||||
#ifdef PLATFORM_LLDB
|
||||
String gdb = "/usr/bin/lldb -X ";
|
||||
#else
|
||||
String gdb = "gdb ";
|
||||
#ifdef PLATFORM_POSIX
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ void Ide::SetIdeState(int newstate)
|
|||
|
||||
void Ide::MakeIcon() {
|
||||
Image li = IdeImg::PackageLarge2();
|
||||
String mp = main;
|
||||
WString mp = main.ToWString();
|
||||
if(!IsNull(mp))
|
||||
{
|
||||
Size isz = li.GetSize();
|
||||
|
|
@ -565,20 +565,39 @@ void Ide::MakeIcon() {
|
|||
int fh = DPI(13);
|
||||
Size sz;
|
||||
Font font;
|
||||
while(fh > 8) {
|
||||
while(fh > DPI(8)) {
|
||||
font = StdFont(fh);
|
||||
sz = GetTextSize(mp, font);
|
||||
sz.cx = min(sz.cx + 4, isz.cx);
|
||||
sz.cy += 2;
|
||||
if(sz.cx < isz.cx)
|
||||
sz = GetTextSize(mp, font) + Size(4, 2);
|
||||
if(sz.cx <= isz.cx)
|
||||
break;
|
||||
fh--;
|
||||
}
|
||||
Font font2;
|
||||
int cx1 = 0;
|
||||
WString mp2;
|
||||
Size sz2;
|
||||
if(sz.cx > isz.cx && mp.GetCount() > 2) {
|
||||
mp2 = mp.Mid(1);
|
||||
mp.Trim(1);
|
||||
cx1 = GetTextSize(mp, font).cx;
|
||||
while(fh > DPI(5)) {
|
||||
font2 = StdFont(fh);
|
||||
sz = GetTextSize(mp2, font2) + Size(4, 2);
|
||||
sz.cx += cx1;
|
||||
sz.cy = font.GetCy();
|
||||
if(sz.cx <= isz.cx)
|
||||
break;
|
||||
fh--;
|
||||
}
|
||||
}
|
||||
int x = (isz.cx - sz.cx) / 2;
|
||||
int y = isz.cy - sz.cy;
|
||||
idraw.DrawRect(x, y, sz.cx, sz.cy, White);
|
||||
mdraw.DrawRect(x, y, sz.cx, sz.cy, White);
|
||||
idraw.DrawText(x + 2, y + 1, mp, font, Black);
|
||||
if(cx1)
|
||||
idraw.DrawText(x + 2 + cx1, y + 1 + font.GetAscent() - font2.GetAscent(),
|
||||
mp2, font2, Black);
|
||||
DrawFrame(idraw, x, y, sz.cx, sz.cy, LtBlue);
|
||||
if(state_icon)
|
||||
idraw.DrawImage(0, 0, decode(state_icon, 1, IdeImg::IconDebuggingLarge2(),
|
||||
|
|
|
|||
|
|
@ -659,7 +659,7 @@ Ide::Ide()
|
|||
|
||||
#ifdef PLATFORM_COCOA
|
||||
WhenDockMenu = [=](Bar& bar) {
|
||||
bar.Add("New Window", [=] {
|
||||
bar.Add("Open main package..", [=] {
|
||||
CreateHost(false, false)->Launch(GetExeFilePath() + " --nosplash");
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue