diff --git a/uppsrc/Core/LocalProcess.h b/uppsrc/Core/LocalProcess.h index 370ce891e..a976ff59a 100644 --- a/uppsrc/Core/LocalProcess.h +++ b/uppsrc/Core/LocalProcess.h @@ -67,7 +67,7 @@ public: #endif #ifdef PLATFORM_WIN32 - int GetProcessHandle() const { return hProcess; } + HANDLE GetProcessHandle() const { return hProcess; } #endif LocalProcess& ConvertCharset(bool b = true) { convertcharset = b; return *this; } diff --git a/uppsrc/TextDiffCtrl/TextCtrl.cpp b/uppsrc/TextDiffCtrl/TextCtrl.cpp index 54b2f51ab..e8f7d0296 100644 --- a/uppsrc/TextDiffCtrl/TextCtrl.cpp +++ b/uppsrc/TextDiffCtrl/TextCtrl.cpp @@ -21,6 +21,23 @@ TextCompareCtrl::TextCompareCtrl() gutter_width = 0; gutter_bg = Color(151, 190, 239); gutter_fg = SGreen; + cursor = anchor = Null; +} + +void TextCompareCtrl::DoSelection(int y, bool shift) +{ + int ii = scroll.Get().y + y / letter.cy; + if(ii >= 0 && ii < lines.GetCount()) { + int i = lines[ii].number; + if(!IsNull(i)) { + if(shift) + cursor = i; + else + cursor = anchor = i; + Refresh(); + scroll.ScrollIntoY(i); + } + } } void TextCompareCtrl::LeftDown(Point pt, dword keyflags) @@ -33,21 +50,51 @@ void TextCompareCtrl::LeftDown(Point pt, dword keyflags) int page_lines = sz.cy / letter.cy; scroll.SetY(line - page_lines / 2); } + else { + DoSelection(pt.y, keyflags & K_SHIFT); + SetCapture(); + } SetWantFocus(); } +void TextCompareCtrl::MouseMove(Point pt, dword) +{ + if(HasCapture()) + DoSelection(pt.y, true); +} + void TextCompareCtrl::LeftUp(Point pt, dword keyflags) { ReleaseCapture(); } -void TextCompareCtrl::MouseMove(Point pt, dword keyflags) +void TextCompareCtrl::Copy() { - if(HasCapture()) { - LeftDown(pt, keyflags); + int sell, selh; + if(GetSelection(sell, selh)) { + String clip; + for(int i = 0; i < lines.GetCount(); i++) { + const Line& l = lines[i]; + if(l.number >= sell && l.number <= selh) { + clip << l.text; + #ifdef PLATFORM_WIN32 + clip << "\r\n"; + #else + clip << "\n"; + #endif + } + } + ClearClipboard(); + AppendClipboardText(clip); } } +void TextCompareCtrl::RightDown(Point p, dword keyflags) +{ + MenuBar b; + b.Add(cursor != anchor, t_("Copy"), CtrlImg::copy(), THISBACK(Copy)).Key(K_CTRL_C); + b.Execute(); +} bool TextCompareCtrl::Key(dword key, int repcnt) { @@ -65,6 +112,9 @@ bool TextCompareCtrl::Key(dword key, int repcnt) case K_END: newpos.x = maxwidth - page.x; break; case K_CTRL_HOME: newpos.y = 0; break; case K_CTRL_END: newpos.y = lines.GetCount() - page.y; break; + case K_CTRL_C: + Copy(); + break; case K_F3: { bool found = false; int i = max(pos.y + 2, 0); @@ -153,11 +203,19 @@ void TextCompareCtrl::Paint(Draw& draw) draw.DrawText(0, y + number_yshift, FormatInt(l.number), number_font, l.color); } draw.Clip(number_width, 0, sz.cx - gutter_width - number_width, sz.cy); + int sell, selh; + GetSelection(sell, selh); for(int i = first_line; i <= last_line; i++) { const Line& l = lines[i]; int y = i * letter.cy - offset.cy; - draw.DrawRect(0, y, sz.cx, letter.cy, SWhite()); - draw.DrawText(number_width - offset.cx, y, ExpandTabs(l.text), l.level == 1 ? ifont : font, l.color); + Color ink = l.color; + Color paper = SColorPaper(); + if(!IsNull(l.number) && l.number >= sell && l.number <= selh) { + ink = SColorHighlightText; + paper = SColorHighlight; + } + draw.DrawRect(0, y, sz.cx, letter.cy, paper); + draw.DrawText(number_width - offset.cx, y, ExpandTabs(l.text), l.level == 1 ? ifont : font, ink); } int lcy = lcnt * letter.cy - offset.cy; draw.DrawRect(0, lcy, sz.cx, sz.cy - lcy, SGray()); @@ -258,6 +316,17 @@ int TextCompareCtrl::MeasureLength(const char *text) const return pos; } +bool TextCompareCtrl::GetSelection(int& l, int& h) +{ + if(IsNull(cursor)) { + l = h = -1; + return false; + } + l = min(cursor, anchor); + h = max(cursor, anchor); + return true; +} + String TextCompareCtrl::ExpandTabs(const char *text) const { String out; diff --git a/uppsrc/TextDiffCtrl/TextDiffCtrl.h b/uppsrc/TextDiffCtrl/TextDiffCtrl.h index ad4c8a2a0..c70b21b91 100644 --- a/uppsrc/TextDiffCtrl/TextDiffCtrl.h +++ b/uppsrc/TextDiffCtrl/TextDiffCtrl.h @@ -32,6 +32,7 @@ public: virtual void MouseMove(Point pt, dword keyflags); virtual void LeftDown(Point pt, dword keyflags); virtual void LeftUp(Point pt, dword keyflags); + virtual void RightDown(Point p, dword keyflags); virtual bool Key(dword key, int repcnt); private: @@ -40,6 +41,9 @@ private: void UpdateWidth(); String ExpandTabs(const char *line) const; int MeasureLength(const char *line) const; + bool GetSelection(int& l, int& h); + void DoSelection(int y, bool shift); + void Copy(); private: struct Line { @@ -62,6 +66,8 @@ private: int number_width; int number_yshift; int gutter_width; + int cursor; + int anchor; typedef TextCompareCtrl CLASSNAME; @@ -98,6 +104,9 @@ public: int GetSb() const { return scroll.Get().y; } void SetSb(int y) { scroll.Set(0, y); } + + void ClearSelection() { cursor = Null; Refresh(); } + void SetSelection(int l, int h) { cursor = l; anchor = h; } Callback ScrollWhen(TextCompareCtrl& pair) { return THISBACK1(PairScroll, &pair); } diff --git a/uppsrc/ide/Debuggers/Gdb_MI2.cpp b/uppsrc/ide/Debuggers/Gdb_MI2.cpp index e22a57d4a..2c047eff6 100644 --- a/uppsrc/ide/Debuggers/Gdb_MI2.cpp +++ b/uppsrc/ide/Debuggers/Gdb_MI2.cpp @@ -168,9 +168,9 @@ bool Gdb_MI2::InterruptDebugger(void) } #endif -#ifdef PLATFORM_POSIX void Gdb_MI2::AsyncBrk() { +#ifdef PLATFORM_POSIX // data must be refreshed dataSynced = false; @@ -187,8 +187,8 @@ void Gdb_MI2::AsyncBrk() if(stopped) break; } -} #endif +} void Gdb_MI2::Stop() {